我遇到了不清楚的 sql server 2008 死锁。
我有两张桌子:
T1: ID – bigint (PK), JOBID – bigint, X- bigint
T2: ID – bigint (PK), JOBID – bigint, X- bigint
sql server 错误日志描述如下:
Spid 233 is running this query:
SELECT TOP(500) FROM T1.X INNER JOIN T2 ON T1.X = T2.X WHERE T2.ID>-1 AND T2.ID<=10000
Spid 234 is running this query:
DELETE FROM T2 WHERE (X=1) OR (X=7) OR ( X=1233) OR X(=7878) OR (X=33) OR (X=776) OR (X=112)
Spid 233 is waiting for a Shared KEY lock on index t2.PK_T2. (Spid 234 holds a conflicting X lock.)
Spid 234 is waiting for an eXclusive KEY lock on index t2.PK_T2. (Spid 233 holds a conflicting S lock.)
PK_X 是标识列(ID 是自动递增列)上的聚集升序索引。T2 还有另一个索引,它是 JOBID 和 X 上的非聚集索引。
为什么两个进程都是同一对象(T2.PK_T2)上的锁的所有者?
请帮忙,多伦