We have a print queue process that acquires a user lock via dbms_lock.allocate_unique. It performs the work and then releases the lock. The process works very well.

Today, we have a process that allocated a lock, as seen in this output from dbms_lock_allocated:

printer_lock    1073741825  11/30/2013 9:35:46 AM

Whatever session has this hasn't released the lock. Is there any way we can find the session that allocated this lock, so we can end their session and release the lock?


Querying DBA_LOCKS does not show any sessions with the lock type of 'PL/SQL User Lock'.


3 Answers 3


These locks can be selected from V$LOCK (or GV$LOCK for RAC)

SELECT * FROM gv$lock WHERE lock_type = 'UL' AND '1073741825' like id1||'%'

1073741825 - is lockid column from dbms_lock_allocated table or you may get it by dbms_lock.allocate_unique('YOUR_LOCK_NAME',:lock_id);


The type of locks you are referring to are stored in table (not view) SYS.DBMS_LOCK_ALLOCATED. I believe they only have a "handle", but not a specific owner, i.e.: they all belong to SYS. That said, if you have active blocking situation going on (someone is waiting for the lock and it's not getting released by the session who allocated the lock) then this query might show what's going on:

SELECT blocker.username blocker, blocker.sid blocker_session
     , blocked.username blocked, blocked.sid blocked_session
  FROM v$session blocked
  JOIN v$session blocker
  ON (blocked.blocking_session = blocker.sid)
 WHERE blocked.wait_class = 'Application'
   AND blocked.event='enq: UL - contention';

You can get this info from DBA_LOCKS.

select *
where LOCK_TYPE = 'PL/SQL User Lock';

DBA_LOCKS has the SESSION_ID and the lock id.

  • 1
    Thanks, Phil. I've seen that suggestion before, but it does not show any locks of that type.
    – DCookie
    Nov 20, 2013 at 17:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.