When two programs want incompatible locks, someone waits. If the wait is a cycle, IRLM calls it a deadlock and picks a victim. If the wait simply lasts too long, it is a timeout. Utilities do not use those row locks to empty a partition; they drain claims. This page ties IS/IX/SIX, timeout detection, claim classes, and data-sharing contention together for DB2 for z/OS.
The Internal Resource Lock Manager serializes Db2 transaction locks (and drain locks). Db2 asks IRLM for S, U, X, IS, IX, SIX, and related modes. If the lock is free, IRLM grants it. If not, the thread is suspended. IRLM also runs a timer loop:
| Control | Meaning |
|---|---|
| IRLMRWT | Default lock timeout seconds (installation; often 30) |
| DEADLOK (START irlmproc) | How often IRLM hunts deadlocks and overdue timeouts (often 1 second, can be 100 ms) |
| CURRENT LOCK TIMEOUT | Session override: null = IRLMRWT, 0 = NOWAIT, -1 = WAIT forever, 1–32767 seconds |
| NUMLKUS / NUMLKTS | Lock ceilings per user / per table space (escalation vs -904) |
IS, IX, and SIX are the parent intent locks described on the lock-types page. They show up in timeout traces because a drain or LOCK TABLE that needs a gross S/X will wait on those intent locks just as a row X waits on a row S.
A timeout is “this request waited longer than allowed.” IRLMRWT (RESOURCE TIMEOUT on DSNTIPI) is the subsystem default, commonly 30 seconds. IRLM notices overdue waiters on the same interval it uses for deadlock detection (DEADLOK on the IRLM start procedure).
SET CURRENT LOCK TIMEOUT overrides the wait for this session (APPLCOMPAT V13R1M500 and later for the full register behavior):
1234SET CURRENT LOCK TIMEOUT = 5; -- seconds SET CURRENT LOCK TIMEOUT = 0; -- NOT WAIT: fail immediately SET CURRENT LOCK TIMEOUT = WAIT; -- or -1: do not time out VALUES CURRENT LOCK TIMEOUT;
CURRENT LOCK TIMEOUT also covers many claim and drain waits, not only row locks. It does not apply to P-locks or some plan/package allocation locks.
Typical timeout story: program 2 wants a lock program 1 holds and will not commit for minutes. Program 2 waits, then Db2 returns an error. Fix the holder (commit more often, shorter UR, avoid lock escalation) rather than only raising IRLMRWT to 300 seconds.
A deadlock is a cycle. Program 1 holds page A and wants page B; program 2 holds B and wants A. Neither timeout clock needs to expire: on the DEADLOK interval IRLM finds the cycle and fails one request so the other can run.
The victim sees SQLCODE -911 or -913 (SQLSTATE 40001 is the usual deadlock/timeout state). -911 rolls back the whole unit of work to the last commit. -913 rolls back the statement and leaves the rest of the UR for the program to COMMIT or ROLLBACK. Know which one your bind/environment produces before you write retry logic.
| SQLCODE | Typical meaning |
|---|---|
| -911 | Deadlock or timeout; unit of work rolled back |
| -913 | Deadlock or timeout; statement rolled back, UR may continue |
| -904 | Resource unavailable (lock, drain, max locks, …) |
Prevention: lock the same objects in the same order, prefer row locks on hot pages, keep URs short, avoid RR unless you need it, and do not mix LOCK TABLE with random row updates. Db2 13 adds DEADLOCK_RESOLUTION_PRIORITY so a chosen process is less likely to be the victim — useful for scheduled DDL, not a license to ignore access order.
Isolation changes how often you wait:
Currently committed and SKIP LOCKED DATA (CS/RS) are ways to not wait on some insert/delete or locked rows. They trade completeness for progress.
A claim is not a row lock. It is a flag that this unit of work is using a page set or partition. Claims are taken on first access and released at the next commit — except WITH HOLD cursors and utility claimers. They exist so a REORG can wait for “everyone out” without hunting every row lock.
| Class | Who takes it | Drain implication |
|---|---|---|
| Write | INSERT, UPDATE, DELETE | DRAIN WRITERS stops changers; readers may continue |
| Repeatable read | Reads under RR isolation | Needed when the drainer must block RR readers |
| Cursor stability read | Reads under RS, CS, or UR | DRAIN ALL includes this class plus write and RR |
DISPLAY DATABASE(…) CLAIMERS shows who is holding claims when a utility will not start.
A drain takes over an object: acquire drain locks for the classes you need, refuse new claims of those classes, wait until existing claims of those classes are gone, then run. Applications may still hold transaction locks on rows, but they cannot make a new claim until the drainer finishes.
Drain locks are real IRLM locks in write, repeatable-read, and cursor-stability-read classes. If applications never commit, the drain waits until timeout (utility RETRY/TIMEOUT options, IRLMRWT, or CURRENT LOCK TIMEOUT). WITH HOLD cursors are a classic reason a “I committed!” batch still blocks REORG: the claim survived the commit.
Partition independence: drain part 3, leave part 4’s claimers running. That only works when the table space is partitioned and the utility states the part.
In data sharing, a lock may be granted locally and still wait in the coupling facility.Global contention is that real cross-member wait (XES contention plus IRLM contention). Tune commit rate, lock size, and GBP so members are not fighting over the same hot page.
False contention is a hash collision in the lock structure: two different resources map to one table entry. The workload is not actually conflicting; the structure is too small or poorly proportioned. Enlarge the lock structure / lock table. Do not “fix” false contention by making every program UR.
A timeout is waiting for the bathroom until a timer rings and you give up. A deadlock is two people each standing in a doorway the other needs — a teacher picks one person to step back. A claim is a sticky note on the classroom door saying “someone is still inside.” A drain is the janitor putting up “no new sticky notes” and waiting until the last kid leaves before mopping. False contention is two different classrooms sharing one coat-hook number by mistake and arguing about a coat that is not even theirs.
1. What is IRLM’s role in a timeout?
2. SQLCODE -911 versus -913 typically means:
3. A CS claim is taken when:
4. What does a drain do?
5. False contention in data sharing is: