Locking of Table

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
Sreenivasulu
Premium Member
Premium Member
Posts: 892
Joined: Thu Oct 16, 2003 5:18 am

Locking of Table

Post by Sreenivasulu »

Hi All,

I am updating/inserting in a table with a single server Job (There are two target stages for the same table) - one with an update on one condition and another with insert with another condition. Both constraints result in two different targets. But the table(not job) gets locked. Hence the job
hangs.

Regards
sanjay
Premium Member
Premium Member
Posts: 203
Joined: Fri Apr 23, 2004 2:22 am

Re: Locking of Table

Post by sanjay »

Try creating a separate job for insert and upate because constraint does n't wait for insert or update to happen first. that is why table get locked

Sanjay
Sreenivasulu wrote:Hi All,

I am updating/inserting in a table with a single server Job (There are two target stages for the same table) - one with an update on one condition and another with insert with another condition. Both constraints result in two different targets. But the table(not job) gets locked. Hence the job
hangs.

Regards
Sreenivasulu
Premium Member
Premium Member
Posts: 892
Joined: Thu Oct 16, 2003 5:18 am

Post by Sreenivasulu »

Thanks Sanjay.
Creating a seperate job for these works but i wonder why it does not
work in a single job since datastage processes records one after another
(In server jobs)

Regards
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The separate links attempt to open separate cursors into the table. Whichever operates first manages to set an exclusive update lock on the table until the COMMIT arrives, which means that the other can not.

An even better approach is not to insert or update rows at all, but to create two separate data files for the bulk loader. Run the bulk loader to perform the inserts first, then run the bulk loader again to perform the updates.
Last edited by ray.wurlod on Wed Jun 09, 2004 5:23 pm, edited 1 time in total.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Re: Locking of Table

Post by chulett »

Sreenivasulu wrote:I am updating/inserting in a table with a single server Job (There are two target stages for the same table) - one with an update on one condition and another with insert with another condition. Both constraints result in two different targets. But the table(not job) gets locked. Hence the job hangs.
You've gotten good advice about separating processes like this. The odd thing is what you are doing should generally work fine. :? We do it all the time for small record sets.

Are you sure your updates and inserts are distinct transactions and are not colliding with each other? What does your DBA say is going on in the database when the job hangs? Is it truly a table lock or are you actually getting row deadlocks? I'd also check your Update Actions, make sure you are not using 'Completely replace existing row'...

One typically sure-fire way to fix it is to set your Transaction Size to 1 so that each row commits as it is written, but that's less than ideal. :wink: Speaking of which, what kind of Array Sizes are you using?
-craig

"You can never have too many knives" -- Logan Nine Fingers
sara123
Participant
Posts: 1
Joined: Tue Feb 03, 2004 2:18 pm

Re: Locking of Table

Post by sara123 »

Hi ,

While doing Update/Insert on same table.

1) Create single Target

2) Create two links to single Target Stage ( Insert Link & update link)

3) Please check Parameter Array size and transaction size ( example: 125 and 500 per transaction size).


if you use this technique you should not get locking issue.



Thank you
kn


Sreenivasulu wrote:Hi All,

I am updating/inserting in a table with a single server Job (There are two target stages for the same table) - one with an update on one condition and another with insert with another condition. Both constraints result in two different targets. But the table(not job) gets locked. Hence the job
hangs.

Regards
bapajju
Participant
Posts: 82
Joined: Wed Nov 19, 2003 11:58 pm

Post by bapajju »

Ray,
Kindly let us know if there is any round about way to handle Update and Insert in a single job.


Thanks
bapajju
Participant
Posts: 82
Joined: Wed Nov 19, 2003 11:58 pm

Post by bapajju »

Ray,
Kindly let us know if there is any round about way to handle Update and Insert in a single job.


Thanks
bapajju
Participant
Posts: 82
Joined: Wed Nov 19, 2003 11:58 pm

Re: Locking of Table

Post by bapajju »

Hi Srini,
We r also getting the same Lock Issue. Kindly let us know if you have got solution to this by now.

Thanks
rasi
Participant
Posts: 464
Joined: Fri Oct 25, 2002 1:33 am
Location: Australia, Sydney

Post by rasi »

Send the insert and update to two different text file and use them in the same job to do insert and update. This will be the work around if you want that to happen in the same job.

Cheers
Rasi
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

bapajju wrote:Ray,
Kindly let us know if there is any round about way to handle Update and Insert in a single job.
Thanks
Run the inserts into a bulk loader stage with automatic run, and the updates into a sequential file stage, then use an after-job subroutine to trigger the bulk load of the updates.
This is one solution. There are almost certainly others. I didn't give it a great deal of thought, as I'm catching up on a week away from DSXChange.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

bapajju wrote:Kindly let us know if there is any round about way to handle Update and Insert in a single job.
It's already been mentioned by Sara123. I've used it extensively and don't have any 'locking' issues. The key is to use two links to a single target stage, not two seperate target stages.

:!: There may still be issues with certain databases for all I know, but can tell you this technique works fine in Oracle.
-craig

"You can never have too many knives" -- Logan Nine Fingers
jiegao
Premium Member
Premium Member
Posts: 46
Joined: Fri Sep 22, 2006 6:12 pm

Re: Locking of Table

Post by jiegao »

I have the same lock issue. Most of the times it works fine. But sometimes it just hangs there waiting for lock to release. I am wondering if array size afffects the locks. Currently my array size is larger than 0 and rows per transaction are all set to 1.
Thanks in advance.

sara123 wrote:Hi ,

While doing Update/Insert on same table.

1) Create single Target

2) Create two links to single Target Stage ( Insert Link & update link)

3) Please check Parameter Array size and transaction size ( example: 125 and 500 per transaction size).


if you use this technique you should not get locking issue.



Thank you
kn


Sreenivasulu wrote:Hi All,

I am updating/inserting in a table with a single server Job (There are two target stages for the same table) - one with an update on one condition and another with insert with another condition. Both constraints result in two different targets. But the table(not job) gets locked. Hence the job
hangs.

Regards
Regards
Jie
sachin1
Participant
Posts: 325
Joined: Wed May 30, 2007 7:42 am
Location: india

Re: Locking of Table

Post by sachin1 »

i daily use this kind of situation regarding insert and update, with Array Size:1500 and Transaction Size:50, I never get a lock issue, Array Size and Transaction Size need to be checked, i agree with sara123.
Post Reply