如何使用跟蹤標記 1204

2021-08-29 11:36:52 字數 3709 閱讀 6831

如何使用跟蹤標記 1204

--測試環境

usetempdb

go createtableta(idint)

inserttaselect1

createtabletb(idint)

inserttbselect1

go --開啟死鎖記錄

dbcctraceon(1204,3605,-1)

go --產生死鎖(查詢視窗a)

setlock_timeout-1

settransactionisolationlevel

repeatableread

begintran

select*fromtawhereid=1

waitfordelay'00:05:00'

updatetbsetid=2whereid=1

committran

go --產生死鎖(查詢視窗b)

setlock_timeout-1

setdeadlock_prioritylow

settransactionisolationlevel

repeatableread

begintran

select*fromtbwhereid=1

updatetasetid=2whereid=1

committran

go --關閉死鎖記錄

dbcctraceoff(1204,3605)

go --清除測試

droptableta,tb

go --1204產生的日誌記錄資訊

2005-08-2508:16:21.85spid4node:1

2005-08-2508:16:21.85spid4rid:2:1:28:0cleancnt:2mode:uflags:0x2

2005-08-2508:16:21.85spid4grantlist0::

2005-08-2508:16:21.85spid4owner:0x1998aec0mode:s***:0x0ref:1life:02000000spid:52ecid:0

2005-08-2508:16:21.85spid4spid:52ecid:0statementtype:updateline#:1

2005-08-2508:16:21.85spid4inputbuf:languageevent:setlock_timeout-1

settransactionisolationlevel

repeatableread

begintran

select*fromtbwhereid=1

waitfordelay'00:01:00'

updatetasetid=2whereid=1

committran

2005-08-2508:16:21.85spid4requestedby:

2005-08-2508:16:21.85spid4restype:lockownerstype:'or'mode:xspid:51ecid:0ec:(0x19b5b558)value:0x1997b2c0cost:(1/0)

2005-08-2508:16:21.85spid4node:2

2005-08-2508:16:21.85spid4rid:2:1:15:0cleancnt:2mode:uflags:0x2

2005-08-2508:16:21.85spid4grantlist0::

2005-08-2508:16:21.85spid4owner:0x1997b3e0mode:s***:0x0ref:1life:02000000spid:51ecid:0

2005-08-2508:16:21.85spid4spid:51ecid:0statementtype:updateline#:1

2005-08-2508:16:21.85spid4inputbuf:languageevent:

setlock_timeout-1

setdeadlock_prioritylow

settransactionisolationlevel

repeatableread

begintran

select*fromtawhereid=1

waitfordelay'00:01:00'

updatetbsetid=2whereid=1

committran

2005-08-2508:16:21.85spid4requestedby:

2005-08-2508:16:21.85spid4restype:lockownerstype:'or'mode:xspid:52ecid:0ec:(0x1a24d558)value:0x1998cfa0cost:(0/0)

2005-08-2508:16:21.85spid4victimresourceowner:

2005-08-2508:16:21.85spid4restype:lockownerstype:'or'mode:xspid:51ecid:0ec:(0x19b5b558)value:0x1997b2c0cost:(1/0)

--分析日誌記錄資訊,以分析node:1為例,--**標註的是說明

--**node:x在死鎖的鏈中表示專案號(x)。

2005-08-2508:16:21.85spid4node:1

2005-08-2508:16:21.85spid4rid:2:1:28:0cleancnt:2mode:uflags:0x2

--**lists,可以是授權(grant)、轉換(convert)和等待(wait),grantlist列舉當前授權的所有者.

2005-08-2508:16:21.85spid4grantlist0::

2005-08-2508:16:21.85spid4owner:0x1998aec0mode:s***:0x0ref:1life:02000000spid:52ecid:0

--**在並行程序情況下,標識系統程序id執行緒。條目spidxecid0表示主線程,而spidxecid>0表示同一spid的子執行緒。

--**statementtype:語句型別

--**line#:死鎖發生時,正在執行的語句的行號

2005-08-2508:16:21.85spid4spid:52ecid:0statementtype:updateline#:1

--**inputbuf列出當前批處理中所有的語句。

2005-08-2508:16:21.85spid4inputbuf:languageevent:

setlock_timeout-1

settransactionisolationlevel

repeatableread

begintran

select*fromtbwhereid=1

waitfordelay'00:01:00'

updatetasetid=2whereid=1

committran

2005-08-2508:16:21.85spid4requestedby:

--**mode為執行緒請求、授權或等待的特定資源,指定鎖的型別。模式可以是is(意向共享)、s(共享)、u(更新)、ix(意向獨佔)、six(與意向獨佔共享)和x(獨佔)

2005-08-2508:16:21.85spid4restype:lockownerstype:'or'mode:xspid:51ecid:0ec:(0x19b5b558)value:0x1997b2c0cost:(1/0)

trackback:

如何使用跟蹤標記 1204

如何使用跟蹤標記 1204 測試環境 use tempdb go create table ta id int insert ta select 1 create table tb id int insert tb select 1 go 開啟死鎖記錄 dbcc traceon 1204,3605,...

如何使用跟蹤標記 1204

如何使用跟蹤標記 1204 測試環境 use tempdb go create table ta id int insert ta select 1 create table tb id int insert tb select 1 go 開啟死鎖記錄 dbcc traceon 1204,3605,...

如何使用跟蹤標記 1204

如何使用跟蹤標記 1204 測試環境 usetempdb go createtableta idint inserttaselect1 createtabletb idint inserttbselect1 go 開啟死鎖記錄 dbcctraceon 1204,3605,1 go 產生死鎖 查詢視窗...