Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Resolving deadlock in CICS

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CICS
View previous topic :: :: View next topic  
Author Message
ramvivek

New User


Joined: 23 Oct 2006
Posts: 13

PostPosted: Wed Aug 08, 2007 1:39 pm    Post subject: Resolving deadlock in CICS
Reply with quote

Hi,

I have a deadlock problem in CICS. Two files are being read with update option in two diff pgms. So I am running into a deadlock situation.Is there any way to handle this ?

Thanks,
Ramkumar M.
Back to top
View user's profile Send private message

Earl

Active User


Joined: 17 Jun 2007
Posts: 148
Location: oklahoma

PostPosted: Wed Aug 08, 2007 8:50 pm    Post subject:
Reply with quote

yes, review EXEC CICS ENQ and EXEC CICS DEQ commands,
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Aug 09, 2007 12:19 am    Post subject:
Reply with quote

Hello,

You may need to change one of the programs so that locking will be in the same order as the "other" program. This may cause things to slow down, but will prevent the deadlock.
Back to top
View user's profile Send private message
Earl

Active User


Joined: 17 Jun 2007
Posts: 148
Location: oklahoma

PostPosted: Thu Aug 09, 2007 12:50 am    Post subject:
Reply with quote

enq
read update
rewrite
deq

is the normal suggested method to prevent deadlock's
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Aug 09, 2007 2:52 am    Post subject:
Reply with quote

Hello,

If there is a separate enq/deq placed around each of the updates (2 different files), will there still not be a deadlock?

Is the enq mechanism "smart enough" to abend the transaction that issues the 4th enq that would cause the deadlock?
Back to top
View user's profile Send private message
Earl

Active User


Joined: 17 Jun 2007
Posts: 148
Location: oklahoma

PostPosted: Thu Aug 09, 2007 3:32 am    Post subject:
Reply with quote

only 1 enq / deq for multiple files, use in both of the problem programs.

ENQ
read file ('file1') update
rewrite
read file ('file2') update
rewrite
read file ('file3') update
rewrite
read file ('file4') update
rewrite
DEQ

normally for deadlock, different tasks trying to update the same file and program logic is performing other long running process in between EXEC CICS UPDATE and EXEC CICS REWRITE.

enq/deq will force program logic in both programs to in effect' go single thread, first come, first service.

1st task that enq's on a resource owns it, and any other task that enq's on the same resource will wait until the resource has been deq'd.
Back to top
View user's profile Send private message
Earl

Active User


Joined: 17 Jun 2007
Posts: 148
Location: oklahoma

PostPosted: Thu Aug 09, 2007 3:36 am    Post subject:
Reply with quote

can you explain logic of problem programs a little more.

you should be able to update the same file with 2 different programs, without using enq/deq.

the deadlock could be caused from some other logic problem .

is either of the programs trying to read or browse the same file in between the
exec cics read update
and
exec cics rewrite

???
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Aug 09, 2007 3:36 am    Post subject:
Reply with quote

Can't remember, but does not VSAM provide a return which can be interpreted as a deadlock situation?

In DB2, if a task receives notification of timeout or deadlock, we do a rollback to allow the other task to complete, WAIT a few seconds then RESTART the Unit of Work. Yeah, I know, gotta keep track, so you can restart. AND these are not two instances of the same program.

If multiple instances of the same program are causing deadlocks, you have a design problem.
Back to top
View user's profile Send private message
Earl

Active User


Joined: 17 Jun 2007
Posts: 148
Location: oklahoma

PostPosted: Thu Aug 09, 2007 3:45 am    Post subject:
Reply with quote

no return code from vsam (that I know of , indicating deadlock).
DINO, is correct, could be some design issues here.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Aug 09, 2007 5:40 am    Post subject:
Reply with quote

Hello,

Yes, one issue is that one program reads file1 for update and the other reads file2 for update (at pretty much the same time). Then program1 tries to read what program2 has already read for update. Finally (again, at the same time) program2 needs to read what program1 has already "locked" - hence the deadlock (or deadly embrace). All good database systems terminate the last process that would have completed the ermbrace. With vsam, they lock.

As Earl has mentioned, all of the processing could be serialized, but the backup in the processes may not be acceptable.

If one or the other program was changed to lock in the same order as the other, it would be a degredation, but hopefully, not as severe as completely single-threading.
Back to top
View user's profile Send private message
Earl

Active User


Joined: 17 Jun 2007
Posts: 148
Location: oklahoma

PostPosted: Thu Aug 09, 2007 6:33 am    Post subject:
Reply with quote

no wonder there is deadlock.


read for update puts an exclusive hold on the record until
exec cics rewrite
exec cics delete
exec cics release
or
task ends (normally or abnormally)

which is why IBM
recommends:
the only thing that should logically follow a "read for update"
is moving the changed record to the buffer,
and
then exec cics rewrite.

looks like a design problem, put in extra reads (without read for update).
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CICS All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Date and time format in CICS Chandru3183 CICS 2 Sat Mar 18, 2017 12:46 pm
No new posts Asynchronous CICS Processing Question moezbud CICS 0 Mon Mar 06, 2017 6:13 pm
No new posts CICS Question RE: Browse, Readnext an... moezbud CICS 7 Sun Mar 05, 2017 5:45 am
No new posts how to send just 10 rows in a CICS sc... Megha Gupta CICS 5 Thu Feb 23, 2017 6:57 pm
No new posts Mainframe Interview Questions CICS,CO... akshathan Mainframe Interview Questions 6 Thu Feb 09, 2017 6:38 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us