How to Find Locks Held by a Specific Process in SAP ASE

When an SAP transaction is stuck waiting for the database, you may need to find which ASE session is holding the lock. You can do this from isql without interrupting any session.

Identify the process

sp_who
go

Look for the affected session and the blocking SPID in the blk_spid column. A process can be holding locks even when it is not currently executing a statement.

Display locks for the SPID

Replace 57 with the process ID found in your own system.

sp_lock 57
go

Review the database, object identifier, lock type and page or row information. The result is a point-in-time view and may change while transactions are running.

Use the monitoring table

For releases supporting the monLocks MDA table, an account with the necessary monitoring privileges can also run:

select *
from master..monLocks
where SPID = 57
go

Use the relevant DBACOCKPIT performance and session views to correlate the database process with the SAP workload. Do not terminate the blocking session just because it holds locks: check the transaction owner, business impact and possible rollback duration first.

References

SAP Note: 3792611

SAP Help: sp_lock

SAP Help: monLocks

You May Also Like

Leave a Reply?