如何使用跟蹤標記 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,-1)
go -- 產生死鎖 (查詢視窗a)
set lock_timeout -1
set transaction isolation level
repeatable read
begin tran
select * from ta where id=1
waitfor delay '00:05:00'
update tb set id=2 where id=1
commit tran
go -- 產生死鎖 (查詢視窗b)
set lock_timeout -1
set deadlock_priority low
set transaction isolation level
repeatable read
begin tran
select * from tb where id=1
update ta set id=2 where id=1
commit tran
go -- 關閉死鎖記錄
dbcc traceoff(1204,3605)
go -- 清除測試
drop table ta,tb
go -- 1204 產生的日誌記錄資訊
2005-08-25 08:16:21.85 spid4 node:1
2005-08-25 08:16:21.85 spid4 rid: 2:1:28:0 cleancnt:2 mode: u flags: 0x2
2005-08-25 08:16:21.85 spid4 grant list 0::
2005-08-25 08:16:21.85 spid4 owner:0x1998aec0 mode: s ***:0x0 ref:1 life:02000000 spid:52 ecid:0
2005-08-25 08:16:21.85 spid4 spid: 52 ecid: 0 statement type: update line #: 1
2005-08-25 08:16:21.85 spid4 input buf: language event: set lock_timeout -1
set transaction isolation level
repeatable read
begin tran
select * from tb where id=1
waitfor delay '00:01:00'
update ta set id=2 where id=1
commit tran
2005-08-25 08:16:21.85 spid4 requested by:
2005-08-25 08:16:21.85 spid4 restype:lockowner stype:'or' mode: x spid:51 ecid:0 ec:(0x19b5b558) value:0x1997b2c0 cost:(1/0)
2005-08-25 08:16:21.85 spid4 node:2
2005-08-25 08:16:21.85 spid4 rid: 2:1:15:0 cleancnt:2 mode: u flags: 0x2
2005-08-25 08:16:21.85 spid4 grant list 0::
2005-08-25 08:16:21.85 spid4 owner:0x1997b3e0 mode: s ***:0x0 ref:1 life:02000000 spid:51 ecid:0
2005-08-25 08:16:21.85 spid4 spid: 51 ecid: 0 statement type: update line #: 1
2005-08-25 08:16:21.85 spid4 input buf: language event:
set lock_timeout -1
set deadlock_priority low
set transaction isolation level
repeatable read
begin tran
select * from ta where id=1
waitfor delay '00:01:00'
update tb set id=2 where id=1
commit tran
2005-08-25 08:16:21.85 spid4 requested by:
2005-08-25 08:16:21.85 spid4 restype:lockowner stype:'or' mode: x spid:52 ecid:0 ec:(0x1a24d558) value:0x1998cfa0 cost:(0/0)
2005-08-25 08:16:21.85 spid4 victim resource owner:
2005-08-25 08:16:21.85 spid4 restype:lockowner stype:'or' mode: x spid:51 ecid:0 ec:(0x19b5b558) value:0x1997b2c0 cost:(1/0)
-- 分析日誌記錄資訊, 以分析 node:1 為例, --** 標註的是說明
--** node:x 在死鎖的鏈中表示專案號 (x)。
2005-08-25 08:16:21.85 spid4 node:1
2005-08-25 08:16:21.85 spid4 rid: 2:1:28:0 cleancnt:2 mode: u flags: 0x2
--** lists, 可以是授權(grant)、轉換(convert)和等待(wait),grant list列舉當前授權的所有者.
2005-08-25 08:16:21.85 spid4 grant list 0::
2005-08-25 08:16:21.85 spid4 owner:0x1998aec0 mode: s ***:0x0 ref:1 life:02000000 spid:52 ecid:0
--** 在並行程序情況下,標識系統程序 id 執行緒。條目 spid x ecid 0 表示主線程,而 spid x ecid > 0 表示同一 spid 的子執行緒。
--** statement type: 語句型別
--** line #:死鎖發生時,正在執行的語句的行號
2005-08-25 08:16:21.85 spid4 spid: 52 ecid: 0 statement type: update line #: 1
--** input buf 列出當前批處理中所有的語句。
2005-08-25 08:16:21.85 spid4 input buf: language event:
set lock_timeout -1
set transaction isolation level
repeatable read
begin tran
select * from tb where id=1
waitfor delay '00:01:00'
update ta set id=2 where id=1
commit tran
2005-08-25 08:16:21.85 spid4 requested by:
--** mode 為執行緒請求、授權或等待的特定資源,指定鎖的型別。模式可以是 is(意向共享)、s(共享)、u(更新)、ix(意向獨佔)、six(與意向獨佔共享)和 x(獨佔)
如何使用跟蹤標記 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 產生死鎖 查詢視窗...
如何使用跟蹤標記 1204
如何使用跟蹤標記 1204 測試環境 usetempdb go createtableta idint inserttaselect1 createtabletb idint inserttbselect1 go 開啟死鎖記錄 dbcctraceon 1204,3605,1 go 產生死鎖 查詢視窗...