View previous topic :: View next topic |
Author |
Message |
onesource Beginner
Joined: 26 Jan 2011 Posts: 6 Topics: 3
|
Posted: Fri Jan 28, 2011 1:09 pm Post subject: Need help to avoid deadlock and row level lock |
|
|
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 |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Fri Jan 28, 2011 1:24 pm Post subject: Re: Need help to avoid deadlock and row level lock |
|
|
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 |
|
 |
onesource Beginner
Joined: 26 Jan 2011 Posts: 6 Topics: 3
|
Posted: Fri Jan 28, 2011 1:38 pm Post subject: |
|
|
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 |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Fri Jan 28, 2011 1:57 pm Post subject: |
|
|
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 |
|
 |
IEFBR14 Beginner

Joined: 13 Aug 2008 Posts: 17 Topics: 0 Location: SYS1.LINKLIB
|
Posted: Sat Jan 29, 2011 6:52 pm Post subject: |
|
|
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 |
|
 |
papadi Supermod
Joined: 20 Oct 2009 Posts: 594 Topics: 1
|
Posted: Sat Jan 29, 2011 10:04 pm Post subject: |
|
|
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 |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Sat Jan 29, 2011 10:21 pm Post subject: |
|
|
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 |
|
 |
|
|