AD2Z: Db2 deadlock rollback failed
An AD2Z abend means Db2 detected a deadlock, the CICS Db2 attachment tried to roll back the unit of work because the DB2ENTRY or pool says DROLLBACK(YES), and that rollback failed. The usual reason is a DPL server program that isn't allowed to issue syncpoints.
Other names for this code
Also written as AD2Z abend, CICS AD2Z, abend AD2Z, AD2Z DROLLBACK, DFHDB2070.
What it means
When Db2 breaks a deadlock, it picks one of the threads as the victim. For CICS transactions, the DROLLBACK attribute decides what happens next. It is set on the DB2ENTRY for entry threads and on the DB2CONN for pool threads. With DROLLBACK(YES), the CICS Db2 attachment doesn't simply pass the error back. It first issues a SYNCPOINT ROLLBACK for the transaction, so CICS and Db2 back out together, and then returns SQLCODE -911 to the program.
AD2Z means that rollback itself failed. The attachment writes message DFHDB2070 to transient data with the transaction ID and the EIBRESP2 value from the failed rollback. Then it abends the transaction and takes a transaction dump. The module that issues it is DFHD2EX1.
The common case is distributed program link. A program run in another region by EXEC CICS LINK without the SYNCONRETURN option is part of the calling program's unit of work, so it may not take a syncpoint or roll back on its own. The attachment's rollback is refused and AD2Z follows. IBM names this case in the abend description.
Common causes
- A Db2 deadlock in a DPL server program that was called without SYNCONRETURN, while the DB2ENTRY or pool used by the mirror transaction has DROLLBACK(YES).
- Any other situation where a SYNCPOINT ROLLBACK isn't allowed or doesn't work for the task. EIBRESP2 in DFHDB2070 tells you which.
- Behind both, a real deadlock in Db2. Programs that update the same tables in a different order, or hold locks for a long time, make deadlocks more likely.
How to find the problem
- Find
DFHDB2070in the transient data queue the DB2CONN definition names in its MSGQUEUE attributes. Note the transaction ID and the EIBRESP2 value. - Check whether the failing transaction was running as a DPL server, for example as the mirror transaction. If so, check the client program's LINK command for SYNCONRETURN.
- Run
CEMT INQUIRE DB2ENTRY(xxxxxxxx)for the entry the transaction uses, orCEMT INQUIRE DB2CONNfor pool threads, and check Drollback. - On the Db2 side, the deadlock message DSNT375I in the Db2 master address space log names the plans and correlation IDs involved, which shows what the transaction collided with.
How to fix it
- Add SYNCONRETURN to the LINK if the server program can commit its own work separately from the client. The server's work then commits when it returns, not with the client's unit of work.
- If the server must stay part of the client's unit of work, set DROLLBACK(NO) on the DB2ENTRY it uses. The attachment then returns SQLCODE -913 without rolling back, and the program must pass the error to the client so the client can roll back.
- Reduce deadlocks at the source. Access tables and rows in the same order in every program, commit sooner in long update loops, and review lock sizes with your Db2 team.
- Make sure the programs check for -911 and -913 and handle them, rather than carrying on as if the update worked.
IBM documentation
IBM documentation: AD2Z. Use the documentation for your installed release.
Related codes
Questions
What does DROLLBACK do?
It tells the CICS Db2 attachment whether to roll back the whole unit of work when Db2 picks the transaction as a deadlock victim. With YES the program gets -911 after the rollback. With NO it gets -913 and has to roll back itself.
Why does AD2Z mostly happen with DPL?
A program called by DPL without SYNCONRETURN can't issue a syncpoint or rollback of its own. The attachment's rollback fails, and that failure is AD2Z.
How is AD2Z different from AEY9?
AEY9 means the program made a Db2 call while CICS wasn't connected to Db2. AD2Z means the call reached Db2, hit a deadlock, and the rollback that followed failed.