Lock tracking
By setting a connection attribute, KDB can be instructed to track row locks and error any attempt to unlock, update or delete a row that had not been previously held. It will also error an attempt to lock a row that has already been locked. There is a slight performance overhead for lock tracking so it is not the default.
To enable tracking set the _KDB_CONN_ATTR_LOCKS attribute to TRUE for the connection handle using KI_CONNECT_SET_ATTR e.g.
CALL KI_CONNECT_SET_ATTR conn, _KDB_CONN_ATTR_LOCKS, TRUE TO s
An entry will be added to the error log if a handle is closed with locks outstanding.
There are also KI calls to manually manipulate the list of tracked locks on a handle: KI_ADD_TRACKED_LOCK, KI_DROP_TRACKED_LOCK, and KI_GET_TRACKED_LOCKS. You probably do not want to use these except in the most exceptional of circumstances.