How to fix Error 10660 on Windows Server 2025 / Windows 11

Troubleshooting Guide: Error 10660 — Online Index Build Chosen as Deadlock Victim

Why This Error Happens

This error occurs when an online index rebuild operation repeatedly conflicts with concurrent transactions attempting to modify the same row(s), causing SQL Server’s lock manager to resolve the deadlock by killing the index build process. It typically happens when long-running or frequent DML operations (INSERT/UPDATE/DELETE) hold row-level or page-level locks on the underlying table while the online index operation attempts to acquire a schema modification (Sch-M) or update lock during its final phase. High-concurrency OLTP workloads with poor transaction isolation settings or excessively long-running transactions are the most common triggers.

Step-by-Step Resolution Guide

Step 1: Identify the Blocking Session

  • Open SQL Server Management Studio (SSMS) and run sp_whoisactive or query sys.dm_exec_requests joined with sys.dm_os_waiting_tasks to find sessions blocking the index operation.
  • Look specifically for sessions with wait_type values like LCK_M_SCH_M or LCK_M_U tied to the table being indexed.
  • Note the blocking_session_id and the SPID of the online index build.

Step 2: Reduce Lock Contention During the Build

  • Re-run the index operation with a lower concurrency footprint using the MAX_DURATION and WAIT_AT_LOW_PRIORITY options (available in SQL Server 2025):
  ALTER INDEX IX_YourIndex ON dbo.YourTable
  REBUILD WITH (ONLINE = ON (WAIT_AT_LOW_PRIORITY (MAX_DURATION = 5 MINUTES, ABORT_AFTER_WAIT = SELF)));
  • This forces the operation to wait briefly for a low-priority lock slot instead of forcibly deadlocking out other transactions.

Step 3: Schedule the Rebuild During Low-Traffic Windows

  • Use SQL Server Agent (via SSMS or sqlcmd) to schedule the index rebuild job during off-peak hours when transaction volume is lower.
  • Navigate to SQL Server Agent > Jobs > New Job in SSMS and set the schedule under the Schedules tab.
  • Confirm the Windows Server 2025 task scheduler isn’t running conflicting maintenance plans at the same time via Task Scheduler > Task Scheduler Library.

Step 4: Adjust Transaction Isolation Level on Competing Queries

  • Check the application code or stored procedures running concurrently and consider setting READ_COMMITTED_SNAPSHOT ON at the database level to reduce blocking:
  ALTER DATABASE YourDatabase SET READ_COMMITTED_SNAPSHOT ON;
  • This shifts read operations to use row versioning instead of shared locks, reducing contention with the online index build.

Step 5: Shorten Long-Running Transactions

  • Audit application logic for transactions that remain open longer than necessary (e.g., missing COMMIT statements or long-held explicit transactions).
  • Use DBCC OPENTRAN to check for any old open transactions holding locks on the target table before retrying the index operation.

Alternative or Verification Steps

  • Re-run the ALTER INDEX ... REBUILD command and monitor sys.dm_exec_requests for the operation completing without hitting Error 10660 again.
  • If the issue persists, consider rebuilding the index offline during a maintenance window (ONLINE = OFF) as a fallback, since offline rebuilds are not subject to the same row-level deadlock victim selection.