How do I handle DEADLOCKs in CICS/DB2 on-line applications? Typically, I would like to report an error only after...
By submitting your personal information, you agree that TechTarget and its partners may contact you regarding relevant content, products and special offers.
a certain number of tries. Can this be handled by altering CICS settings? How do I handle this programmatically?
I assume you have read the chapter on "Handling deadlocks in the CICS DB2 environment" in the CICS DB2 Guide (SC34-6014 for CICS TS V2.2, SC33-1939 for CICS TS V1.3).
There is no way to configure CICS to retry multiple times before reporting the error.
There are two way you can handle this programmatically. The first is by changing the application to respond to the -911 or -913 SQL response code that DB2 returns to the program that has been chosen to be sacrificed to relieve the deadlock. The application could (after rolling back any changes if necessary) start again from the beginning, keeping a count of retries so that the application can give up after a certain number of tries.
Alternatively you could exploit the CICS transaction restart capability. This is described in detail in the CICS Customization Guide (SC34-5989 for CICS TS V2.2, SC33-1683 for CICS TS V1.3). In short, if the transaction is defined with RESTART(YES) then CICS invokes the DFHREST user replaceable module if the transaction abends. The user replaceable module determines if the transaction is to be restarted, usually based on the abend code. It is advisable to have unique abend codes for the abends that are caused by retryable situations, such as deadlocks, so that DFHREST can easily determine if there is any chance that the transaction would succeed at a second attempt. If DFHREST indicates that the transaction is to be restarted CICS will complete the abend of the failing task and then attach a new transaction instance with the same principal facility and input message as the initial instance.The interface to DFHREST includes a retry count so that DFHREST can avoid an infinite loop of abending tasks. There are some restrictions that result in this technique not being applicable for all applications so you will need to read the documentation carefully. CICS supplies a sample DFHREST that provides a retry capability for DBCTL and VSAM deadlocks and which should help you write your own version.
Dig Deeper on IBM system z and mainframe systems
Related Q&A from Robert Crawford
For better mainframe capacity planning, how do I convert CPU hours to MIPS? And is there a way to calculate the relationship between MIPS and MSUs?continue reading
I have two years of experience in mainframe technology, currently working as a mainframe developer. I want to change to Java technology.continue reading
I want to replicate DB2 from the mainframe to an AIX box since it's cheaper and the copy can be used for testing. Is this possible?continue reading
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.