Error codes, cause and example of deadlock in DB2


A DEADLOCK condition occurs when two applications lock the data that is needed by each other. Both the applications wait for the other one to release the lock and hence deadlock occurs.

Let us see an example to understand this better:

There are two COBOL-DB2 programs in execution: PROG A and PROG B.

The PROG A is holding an UPDATE LOCK in ORDERS table while PROG B is holding a UPDATE LOCK in TRANSACTION table. At some point of time, PROG A requires an UPDATE LOCK on TRANSACTION TABLE and PROG B requires an UPDATE LOCK on ORDERS table but two application programs cannot place an UPDATE LOCK on the same page.

Hence both the programs will wait for each other to release the lock and ultimately enter in DEADLOCK state.

The COBOL-DB2 program fails with error code -911 and -913 in case the program enters in DEADLOCK condition. -911 signifies that DB2 issued an automatic roll back while -913 signifies that automatic roll back is not issued by DB2 (not possible by DB2).

Updated on: 30-Nov-2020

986 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements