SQL Server error 3960: Snapshot isolation update conflict
Under SNAPSHOT isolation, this transaction tried to change a row another transaction changed after this one started. Retry the transaction.
- Error number
3960- Severity
- 16
- Category
- Transactions and locking
What it means
A transaction at SNAPSHOT isolation reads data as it was when the transaction started. If it then updates or deletes a row that another transaction has modified and committed since then, SQL Server can't apply the change without losing the other update, so it rolls the transaction back with 3960. This is optimistic concurrency working as designed. Read committed snapshot isolation (RCSI) doesn't raise 3960; only the SNAPSHOT level does.
Common causes
- Two
SNAPSHOTtransactions updating the same row concurrently. - A long
SNAPSHOTtransaction that reads, waits, then writes rows that others are actively changing.
How to fix it
-
Retry the whole transaction; it will see the newer data the second time.
-
Keep snapshot transactions short, especially between the read and the write.
-
For hot rows, take an update lock when reading so the conflict becomes a short wait instead of a rollback.
SELECT Balance FROM dbo.Accounts WITH (UPDLOCK) WHERE AccountId = 1;
Related errors
1205Deadlocked and chosen as the victim40001PostgreSQL: could not serialize accessORA-08177Oracle: can't serialize access for this transaction
More transactions and locking errors
266Transaction count mismatch after EXECUTE1222Lock request time out period exceeded3930Transaction cannot be committed3902COMMIT has no corresponding BEGIN3903ROLLBACK has no corresponding BEGIN3609Transaction ended in the trigger3616Error raised during trigger execution6401No transaction or savepoint found
The code and message text are from the Microsoft Database Engine events and errors reference. Browse the full SQL Server error list or search every database error.
Work on SQL Server in SQLly
A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for SQL Server and the other databases you use.