MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Need help to avoid deadlock and row level lock

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
onesource
Beginner


Joined: 26 Jan 2011
Posts: 6
Topics: 3

PostPosted: Fri Jan 28, 2011 1:09 pm    Post subject: Need help to avoid deadlock and row level lock Reply with quote

Hi

I have a DB2 table with Key + Sequence number. I need to update a unique seq number in o/p file and need to avoid duplicate numbers to be supplied. There are more than 5 parrellel batch jobs wil access the table to get sequence number at the same time.

I need to lock the row which matched key and have to release that row once committed.

I have to comit only after the successful execution of batch job. If job fails, everything should be roll back.

Each job has millions of records in the input file and hv to get sequence number for each record.

Can anyone explain me how to achieve this process without deadlock and waiting time should be very minimal time ( COBOL + DB2 Environment).

I would appreciate your help on this.

Thanks,
Onesource
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Fri Jan 28, 2011 1:24 pm    Post subject: Re: Need help to avoid deadlock and row level lock Reply with quote

onesource wrote:
Hi

I need to update a unique seq number in o/p file and need to avoid duplicate numbers to be supplied. There are more than 5 parrellel batch jobs wil access the table to get sequence number at the same time.

I need to lock the row which matched key and have to release that row once committed.

I have to comit only after the successful execution of batch job. If job fails, everything should be roll back.

Each job has millions of records in the input file and hv to get sequence number for each record.


onesource,


Something does NOT add up. If you are just updating the output file, why do you need to commit?

If you are just writing records to an output file reading a DB2 table, I suggest that you look into Unloading the data and run it thru an utility to generate the seqnum.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
onesource
Beginner


Joined: 26 Jan 2011
Posts: 6
Topics: 3

PostPosted: Fri Jan 28, 2011 1:38 pm    Post subject: Reply with quote

Thanks for reply and sorry for missed some more process.

I need to update DB2 table with last used sequence number for every use of sequence number. Each input record will be written to output file with unique sequence number. Sequence number should not be duplicate in any of the records and also any of jobs output file.

I hope this will make more sense.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Fri Jan 28, 2011 1:57 pm    Post subject: Reply with quote

onesource,

You need to re-design your process. You are wasting resources reading the DB2 table in 5 different process to update 1 row at the end of each process.

1. Unload the DB2 table
2. Run the file thru an utility which will generate the unique seqnum for each file and also generate a update SQL statement to update the DB2 table.

Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
IEFBR14
Beginner


Joined: 13 Aug 2008
Posts: 17
Topics: 0
Location: SYS1.LINKLIB

PostPosted: Sat Jan 29, 2011 6:52 pm    Post subject: Reply with quote

onesource wrote:
Each input record will be written to output file with unique sequence number.
Sequence number should not be duplicate in any of the records and also any of jobs output file.


Isn't this a contradiction?
Back to top
View user's profile Send private message
papadi
Supermod


Joined: 20 Oct 2009
Posts: 594
Topics: 1

PostPosted: Sat Jan 29, 2011 10:04 pm    Post subject: Reply with quote

If there is a "control value" somewhere that contains the "next available", one way to get what is wanted is to lock the "next available" value, update it, commit the update, and move on with the process that will use this value.

Once assigned, a value would not be used again.
_________________
All the best,

di
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Sat Jan 29, 2011 10:21 pm    Post subject: Reply with quote

IEFBR14 wrote:
onesource wrote:
Each input record will be written to output file with unique sequence number.
Sequence number should not be duplicate in any of the records and also any of jobs output file.


Isn't this a contradiction?


OP has 5 different parallel process which needs to generate the unique sequence numbers in the output file.

Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group