The
DBMS_LOCK
package provides an interface to Oracle Lock Management services. You can request a lock of a specific mode, give it a unique name recognizable in another procedure in the same or another instance, change the lock mode, and release it.
DBMS Locks are allocated via
DBMS_LOCK.allocate_unique(lockname => c_lock_name, lockhandle => tmp_lock_handle);
You cannot see them in V$lock and they stay in place through a Shutdown and Restart
You can find them in sys.dbms_lock_allocated
SQL> select * from sys.dbms_lock_allocated ;
NAME LOCKID EXPIRATIO
------------------ ---------- ---------
EOD_LOCK 1073741824 15-JUL-11
You can clear them by running:
DBMS_LOCK.release(id => 1073741824);
Reason I am posting this is that on the 15th of July 2011 one of our core systems failed during the End of Day process. (hardware error)
When it was eventually brought back up, the Business attempted to resume the End of Day but were told: "EOD already in progress"
This left the DBA on call (Me) scratching my head as there was nothing in v$lock and:
select sesion.sid,
sql_text,
sesion.username,
sesion.OSUSER,
sesion.process,
sesion.MACHINE,
sesion.PROGRAM
from v$sqltext sqltext, v$session sesion
where sesion.sql_hash_value = sqltext.hash_value
and sesion.sql_address = sqltext.address
order by sid, sqltext.piece
/
was returning nothing.
Eventually after looking through the EOD package I discovered the DBMS_LOCK.
Pain.....