SQL DeadLock涉及两个不同的表

时间:2014-05-15 06:38:01

标签: sql sql-server deadlock

我从生产服务器那里得到了死锁。

        05/15/2014 10:25:28,spid29s,Unknown,waiter id=process95ca94988 mode=RangeS-U requestType=wait
        05/15/2014 10:25:28,spid29s,Unknown,waiter-list
        05/15/2014 10:25:28,spid29s,Unknown,owner id=process4761948 mode=X
        05/15/2014 10:25:28,spid29s,Unknown,owner-list
        05/15/2014 10:25:28,spid29s,Unknown,keylock hobtid=72057594753449984 dbid=5 objectname=LiveDB.dbo.Grsc indexname=PK_Grsc id=lock545d65e80 mode=X associatedObjectId=72057594753449984
        05/15/2014 10:25:28,spid29s,Unknown,waiter id=process4761948 mode=Sch-S requestType=wait
        05/15/2014 10:25:28,spid29s,Unknown,waiter-list
        05/15/2014 10:25:28,spid29s,Unknown,owner id=process95ca94988 mode=Sch-M
        05/15/2014 10:25:28,spid29s,Unknown,owner-list
        05/15/2014 10:25:28,spid29s,Unknown,objectlock lockPartition=7 objid=2127359389 subresource=FULL dbid=5 objectname=LiveDB.dbo.Assets id=lock4d7548900 mode=Sch-M associatedObjectId=2127359389
        05/15/2014 10:25:28,spid29s,Unknown,resource-list
        05/15/2014 10:25:28,spid29s,Unknown,Proc [Database Id = 5 Object Id = 1648073703]
        05/15/2014 10:25:28,spid29s,Unknown,inputbuf
        05/15/2014 10:25:28,spid29s,Unknown,EXEC usp_Grsc_1 @POID<c/>@PODetailIDString<c/>@UserID<c/>@ProcessID
        05/15/2014 10:25:28,spid29s,Unknown,frame procname=LiveDB.dbo.usp_CScGr line=59 stmtstart=6770 stmtend=7156 sqlhandle=0x03000500e79b3b62b09a2d0125a300000100000000000000
        05/15/2014 10:25:28,spid29s,Unknown,UPDATE Grsc SET ForexID = @ForexGRNID WHERE PODtlInv IN (12632,12311,23134)
        05/15/2014 10:25:28,spid29s,Unknown,frame procname=LiveDB.dbo.usp_Grsc_1 line=493 stmtstart=69646 stmtend=70004 sqlhandle=0x0300050068a4f1565a9e2d0125a300000100000000000000
        05/15/2014 10:25:28,spid29s,Unknown,executionStack
        05/15/2014 10:25:28,spid29s,Unknown,process id=process95ca94988 taskpriority=0 logused=22088 waitresource=KEY: 5:72057594753449984 (4bbc256675eb) waittime=882 ownerId=15915819604 transactionname=CreateScgrPOdtl lasttranstarted=2014-05-15T10:25:21.887 XDES=0x10f760ce80 lockMode=RangeS-U schedulerid=37 kpid=10788 status=suspended spid=257 sbid=2 ecid=0 priority=0 trancount=2 lastbatchstarted=2014-05-15T10:25:21.883 lastbatchcompleted=2014-05-15T10:25:21.883 clientapp=.Net SqlClient Data Provider hostname=P2 hostpid=6672 loginname=xxx isolationlevel=serializable (4) xactid=15915819604 currentdb=5 lockTimeout=4294967295 clientoption1=673185824 clientoption2=128056
        05/15/2014 10:25:28,spid29s,Unknown,Proc [Database Id = 5 Object Id = 1648073703]
        05/15/2014 10:25:28,spid29s,Unknown,inputbuf
        05/15/2014 10:25:28,spid29s,Unknown,EXEC usp_Grsc_1 @POID<c/>@PODetailIDString<c/>@UserID<c/>@ProcessID
        05/15/2014 10:25:28,spid29s,Unknown,frame procname=LiveDB.dbo.usp_CScGr line=59 stmtstart=6770 stmtend=7156 sqlhandle=0x03000500e79b3b62b09a2d0125a300000100000000000000
        05/15/2014 10:25:28,spid29s,Unknown,executionStack
        05/15/2014 10:25:28,spid29s,Unknown,process id=process4761948 taskpriority=0 logused=1132 waitresource=OBJECT: 5:2127359389:7  waittime=2806 ownerId=15915837882 transactionname=CreateScgrPOdtl lasttranstarted=2014-05-15T10:25:25.080 XDES=0x11add9ef30 lockMode=Sch-S schedulerid=8 kpid=17484 status=suspended spid=216 sbid=2 ecid=0 priority=0 trancount=1 lastbatchstarted=2014-05-15T10:25:25.080 lastbatchcompleted=2014-05-15T10:25:25.080 clientapp=.Net SqlClient Data Provider hostname=P2 hostpid=6672 loginname=xxx isolationlevel=read committed (2) xactid=15915837882 currentdb=5 lockTimeout=4294967295 clientoption1=673185824 clientoption2=128056
        05/15/2014 10:25:28,spid29s,Unknown,process-list
        05/15/2014 10:25:28,spid29s,Unknown,deadlock victim=process4761948
        05/15/2014 10:25:28,spid29s,Unknown,deadlock-list
        05/15/2014 10:25:28,spid12s,Unknown,ResType:LockOwner Stype:'OR'Xdes:0x00000011ADD9EF30 Mode: Sch-S SPID:216 BatchID:2 ECID:0 TaskProxy:(0x00000011AEA4A538) Value:0xc42d9a80 Cost:(0/1132)
        05/15/2014 10:25:28,spid12s,Unknown,Victim Resource Owner:
        05/15/2014 10:25:28,spid12s,Unknown,Log Viewer could not read information for this log entry. Cause: Data is Null. This method or property cannot be called on Null values.. Content:
        05/15/2014 10:25:28,spid12s,Unknown,ResType:LockOwner Stype:'OR'Xdes:0x00000010F760CE80 Mode: RangeS-U SPID:257 BatchID:2 ECID:0 TaskProxy:(0x00000010F5236538) Value:0xd21ab800 Cost:(0/22088)
        05/15/2014 10:25:28,spid12s,Unknown,Requested by:
        05/15/2014 10:25:28,spid12s,Unknown,Input Buf: RPC Event: Proc [Database Id = 5 Object Id = 1648073703]
        05/15/2014 10:25:28,spid12s,Unknown,SPID: 216 ECID: 0 Statement Type: ALTER TABLE Line #: 262
        05/15/2014 10:25:28,spid12s,Unknown,Owner:0x0000000696120E40 Mode: X        Flg:0x40 Ref:0 Life:02000000 SPID:216 ECID:0 XactLockInfo: 0x00000011ADD9EF70
        05/15/2014 10:25:28,spid12s,Unknown,Grant List 0:
        05/15/2014 10:25:28,spid12s,Unknown,KEY: 5:72057594753449984 (4bbc256675eb) CleanCnt:2 Mode:X Flags: 0x1
        05/15/2014 10:25:28,spid12s,Unknown,Node:2
        05/15/2014 10:25:28,spid12s,Unknown,Log Viewer could not read information for this log entry. Cause: Data is Null. This method or property cannot be called on Null values.. Content:
        05/15/2014 10:25:28,spid12s,Unknown,ResType:LockOwner Stype:'OR'Xdes:0x00000011ADD9EF30 Mode: Sch-S SPID:216 BatchID:2 ECID:0 TaskProxy:(0x00000011AEA4A538) Value:0xc42d9a80 Cost:(0/1132)
        05/15/2014 10:25:28,spid12s,Unknown,Requested by:
        05/15/2014 10:25:28,spid12s,Unknown,Input Buf: RPC Event: Proc [Database Id = 5 Object Id = 1648073703]
        05/15/2014 10:25:28,spid12s,Unknown,SPID: 257 ECID: 0 Statement Type: UPDATE Line #: 493
        05/15/2014 10:25:28,spid12s,Unknown,Owner:0x0000000622725340 Mode: Sch-M    Flg:0x40 Ref:0 Life:20000000 SPID:257 ECID:0 XactLockInfo: 0x00000010F760CEC0
        05/15/2014 10:25:28,spid12s,Unknown,Grant List 2:
        05/15/2014 10:25:28,spid12s,Unknown,OBJECT: 5:2127359389:7         CleanCnt:2 Mode:Sch-M Flags: 0x1
        05/15/2014 10:25:28,spid12s,Unknown,Node:1
        05/15/2014 10:25:28,spid12s,Unknown,Log Viewer could not read information for this log entry. Cause: Data is Null. This method or property cannot be called on Null values.. Content:
        05/15/2014 10:25:28,spid12s,Unknown,Wait-for graph
        05/15/2014 10:25:28,spid12s,Unknown,Deadlock encountered .... Printing deadlock information

任何人都可以在这里向我解释这个场景,因为这是两个不同的表... 由于语句而更新列值和Assets表时涉及表Grsc         ALTER TABLE资产启用TRIGGER ALL 即使在Trigger过程中,也没有对Grsc表的引用。 这些update和alter语句都在相同的存储过程中。

现在我的问题是,是否有可能因为锁定分区,出现死锁情况? 由于涉及两个不同的表,为什么首先会出现死锁。 抓我的头,任何人都可以帮忙吗?

谢谢和问候,

Amit Jog

0 个答案:

没有答案