Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
  <deadlock victim="process14012e08">
      <process id="process14012e08" taskpriority="0" logused="148" 
               waitresource="PAGE: 28:1:762341" waittime="6583" 
               ownerId="54542271281" transactionname="DELETE" 
               lasttranstarted="2013-06-22T01:04:20.450" XDES="0x64de49950" 
               lockMode="S" schedulerid="26" kpid="13336" status="suspended" spid="1239" 
               sbid="0" ecid="0" priority="0" trancount="2" 
               lastbatchcompleted="2013-06-22T01:00:19.117" hostpid="15675" 
               isolationlevel="read committed (2)" xactid="54542271281" currentdb="28" 
               lockTimeout="4294967295" clientoption1="671350816" clientoption2="128056">
          <frame procname="adhoc" line="3" stmtstart="134" stmtend="332" 
            delete from grid_col where grid_col_id not in (select grid_col_id from grid)
          set rowcount 10000
          while 1 = 1
          begin delete from grid_col where grid_col_id not in (select grid_col_id from grid)
          if @@rowcount = 0
          set rowcount 0
      <process id="process10031288" taskpriority="0" logused="912" 
               waitresource="OBJECT: 28:731149650:16 " waittime="40270" 
               ownerId="54542276360" transactionname="insertRows" 
               lasttranstarted="2013-06-22T01:04:23.753" XDES="0x1641ef9400" 
               lockMode="IS" schedulerid="17" kpid="29104" status="suspended" spid="351" 
               sbid="0" ecid="0" priority="0" trancount="2" 
               isolationlevel="read committed (2)" xactid="54542276360" 
               lockTimeout="4294967295" clientoption1="671088672" clientoption2="128056">
          <frame procname="check_grid_col" line="1" stmtstart="226" stmtend="376" 
            SELECT @retval = COUNT(*) from grid_col where grid_col_id = @grid_col
          <frame procname="adhoc" line="1" stmtstart="34376" stmtend="35270" 
            INSERT INTO grid (grid_id,grid_col_id,value) VALUES ( @P2 , @grid_col_id,@P3)
          (@P0 bigint,@P1 int,@P2 char(300))
      <pagelock fileid="1" pageid="762341" dbid="28" objectname="grid" 
                id="lock1cb9187500" mode="IX" associatedObjectId="72057594070695936">
          <owner id="process10031288" mode="IX" />
          <waiter id="process14012e08" mode="S" requestType="wait" />
      <objectlock lockPartition="16" objid="731149650" subresource="FULL" 
                  dbid="28" objectname="grid_col" id="lock12e6c78f00" mode="X" 
          <owner id="process14012e08" mode="X" />
          <waiter id="process10031288" mode="IS" requestType="wait" />
share|improve this question
Your deadlock is not on a single resource. Both grid_col and grid are involved. – Martin Smith Jul 4 '13 at 11:02
@ypercube, he edited the post – Paul Jul 4 '13 at 11:08

An example of how it can happen:

Two processes, each one has a shared lock on the same page, then an exclusive lock is needed by each process. Each process can't exclusively lock the page because of the shared row locks.

So, a deadlock happens on the same page.

More examples here from @AlexK

share|improve this answer

Page 28:1:762341 is owned by INSERT in IX mode and wanted by DELETE in S mode. Object 731149650 (grid_col) is owned by DELETE in X mode and wanted by INSERT in IS mode (for the CHECK SELECT).

You have a SELECT COUNT(*) from grid_col as check condition on a column in grid. And a deprecated ROWCOUNT restricted anti join DELETE, which appears to do scan to boot. In other words you are begging for deadlocks.

Fix your schema and data design.

  • Do not use check conditions that select cross table. Use foreign key constraints, change the data model design to accommodate a foreign key constraint.
  • Use TOP clause to restrict the DELETE.
  • Very likely the indexes on the grid and grid_col are missing or incorrect.
share|improve this answer
>>>> Use foreign key constraints, change the data model design to accommodate a foreign key constraint. But the problem is my schema for grid_col with columns as (col_id,f_id,f_value) has (col_id,f_id) as primary key. So I cant add a foreign key constraint. But If I do select grid_col_id into ##temp from grid. then do delete from grid_col where grid_col_id not in (select top 1000 grid_col_id from ##temp) delete top 1000 ##temp – Dumper Jul 4 '13 at 12:16

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.