Page 1 of 1

Deadlocked on lock resource while selecting & updating

Posted: Thu Aug 22, 2013 10:32 pm
by Roopanwita
Hi,

In a job , I am selecting from a table and after few transformation , trying to update 1 field of same table (i.e. updating the same table where I am selecting records from). My database is SQLSERVER 2008 and in select query I am using WITH (NOLOCK) and in update query , I am using WITH (UPDLOCk).

My process is failing with error :
Transaction (Process ID #) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction. (CC_OdbcDBStatement::executeUpdate, file CC_OdbcDBStatement.cpp, line #)
I am using ODBC connector stage both in source and Target and my update key is properly defined (not duplicate , unique).

I tried to change Array Size andAuto Commit & Isolation Level options in target ODBC connector but still no luck .

I need to update the same table I am selecting records from.

Can anybody please help me .

Thank you in Advance,

Posted: Thu Aug 22, 2013 11:42 pm
by ArndW
In PX jobs, your SELECT and UPDATE stages are going to be different processes that will access your table, and if you have multiple nodes then there will be multiple processes for each stage as well. There is no need to use the hint "WITH (UPDLOCK)" on your update statement, as it does result in one process holding a lock when it shouldn't be.

One question - are you running multiple nodes and if yes, what is your partitioning key (hint: it should be hashed to the unique key of your table and not round-robin).

Posted: Fri Aug 23, 2013 9:33 am
by Roopanwita
Thank you for your reply .

I am running the job in default node (my Apt_config file has 2 nodes).

I tried to do hash partition on unique key column also , still it not working.

Thanks,

Posted: Fri Aug 23, 2013 10:36 am
by ArndW
Did you the remove the hint (nolock)?

Posted: Mon Aug 26, 2013 12:44 am
by arunkumarmm
Did you mean to say UPDLOCK?

Posted: Mon Aug 26, 2013 7:12 am
by ArndW
Sorry, yes; I meant to remove the explicit updlock reference.