Monitoring locks
You can analyze information about locks and monitor locks by viewing information in the internal lock table that contains stored locks.
View the lock table with onstat -k. onstat -k output shows sample output for onstat
-k.
In this example, a user is inserting one row in a table.
The user holds the following locks (described in the order shown):
- A shared lock on the database
- A shared lock on a row in the systables system catalog table
- An intent-exclusive lock on the table
- An exclusive lock on the row
To determine the table to which the lock applies, execute
the following SQL statement.
For tblsnum, substitute the value shown in the tblsnum field
in the onstat -k output.
SELECT *
FROM SYSTABLES
WHERE HEX(PARTNUM) = "tblsnum";
Where tblsnum is
the modified value that onstat -k returns. For example, if onstat
-k returns 10027f
, tbslnum is 0x0010027F
.You can also query the syslocks table in the sysmaster database to obtain information about each active lock. The syslocks table contains the following columns.
Column | Description |
---|---|
dbsname | Database on which the lock is held |
tabname | Name of the table on which the lock is held |
rowidlk | ID of the row on which the lock is held (0 indicates a table lock.) |
keynum | The key number for the row |
type | Type of lock |
owner | Session ID of the lock owner |
waiter | Session ID of the first waiter on the lock |