Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Updlock and Readpast Table Hints

Author  Topic 

dim
Yak Posting Veteran

57 Posts

Posted - 2011-01-17 : 13:11:05
Hi,

I am working on a job fail problem where there is a query deadlock. My query is trying to update the table which is already being used by other resource it seems.

I have modified my query to include updlock.

The query is as below:

UPDATE TRP.dbo.Cont with (updlock)
SET
contact_Updated_ind = 'Y'
FROM
TRP.dbo.Cont C with (updlock)
INNER JOIN
Ph_Type WPT
ON WPT.Cont_ID = C.Cont_ID
INNER JOIN
Ph_T_Type WP -- 06.01.0003 modification
ON WPT.Ph_id = WP.Ph_id
AND WP.IsValid = 1
WHERE
WPT.Cont_ID IS NOT NULL
AND
WPT.P_nbr_ID IS NOT NULL
AND
WPT.Ph_ID IS NULL

My concerns:

1. Will updlock help resolve the deadlock and obtain the update lock for the table?

2. Do I need to use the readpast along with the updlock?

Please advice

Thank you,
dim

Dp

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-01-17 : 13:13:45
A UPDLOCK will not resolve this.

READPAST should be used for queue tables as far as I know. Is that the case here?

Have you figured out who the deadlock owner is? You'll need the info in order to troubleshoot this. You can use trace flag 1222 or Profiler's deadlock graph to obtain the deadlock info. Once you have that, please post it here.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

dim
Yak Posting Veteran

57 Posts

Posted - 2011-01-17 : 15:24:03

Hi tkizer,

This is what is mentioned in the log file:
Msg 1205, Sev 13, State 52, Line 235 : Transaction (Process ID 139) was deadlocked on lock | communication buffer resources with another process and has been chosen as the deadlock victim. Rerun the transaction. [SQLSTATE 40001]

Is this enough information? The dba had not set the profiler on.


Dp
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-01-17 : 16:41:08
That is not enough information. We already know there was a deadlock. A deadlock involves two parties: the owner and the victim. The query you posted is the victim. We need the owner. You need to get the DBA involved in this in order to identify the owner query. Once you have that, post it in this thread.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -