Readers block writers, writers block readers, and the code base is full of NOLOCK. Read committed snapshot isolation (RCSI) removes reader-writer blocking with one database option. It also changes what every default-isolation query sees. Work through this checklist before you flip it.
Confirm RCSI will fix your blocking
RCSI only removes shared (S) lock conflicts. Writer-writer blocking stays. Sample current blocking first:
SELECT r.session_id, r.blocking_session_id, r.wait_type, r.wait_time,
r.wait_resource, r.transaction_isolation_level, t.text
FROM sys.dm_exec_requests r
CROSS APPLY sys.dm_exec_sql_text(r.sql_handle) t
WHERE r.blocking_session_id <> 0;
| Wait on the blocked session | Does RCSI help? |
|---|---|
LCK_M_S, LCK_M_IS | Yes, when the reader runs at read committed |
LCK_M_U, LCK_M_X, LCK_M_IX | Not directly; look at indexes, transaction length and escalation |
LCK_M_SCH_S, LCK_M_SCH_M | No; versioned reads still take Sch-S |
LCK_M_S from a REPEATABLE READ or SERIALIZABLE session | No; those levels are unchanged |
- Most blocked time is readers waiting on writers.
- Sessions really use read committed (
transaction_isolation_level = 2). Some ORMs and distributed transactions default to serializable.
Check the current state
SELECT name, is_read_committed_snapshot_on, snapshot_isolation_state_desc,
is_accelerated_database_recovery_on, compatibility_level
FROM sys.databases
WHERE database_id > 4;
ALLOW_SNAPSHOT_ISOLATION is a separate option. You don't need it for RCSI. Azure SQL Database has RCSI on by default for new databases, so a migration from an RCSI-off server is an unplanned RCSI rollout.
Audit the code for logic that relied on blocking
Under RCSI each statement sees committed data as of the statement's start. A reader no longer waits for an in-flight change; it sees the previous committed version. Code that used that wait as a mutex breaks without an error.
Check-then-act patterns
-- Two sessions can both see enough stock
IF (SELECT qty FROM dbo.Stock WHERE sku = @sku) >= @n
UPDATE dbo.Stock SET qty = qty - @n WHERE sku = @sku;
This was already racy under locking read committed because the S lock is released before the update. RCSI widens the window. Make it one atomic statement:
UPDATE dbo.Stock
SET qty = qty - @n
WHERE sku = @sku AND qty >= @n;
IF @@ROWCOUNT = 0 THROW 50001, 'Insufficient stock', 1;
When the check reads a different table from the one you write, take an explicit lock on the row you depend on:
BEGIN TRAN;
SELECT @status = status
FROM dbo.Account WITH (UPDLOCK, HOLDLOCK)
WHERE account_id = @id;
-- dependent insert here
COMMIT;
Trigger-enforced rules
Triggers that validate by reading another table can read a stale version while a concurrent transaction changes it. Replace them with declared constraints where possible. Foreign key validation by the engine still reads the current committed row under locks. For triggers you must keep, add READCOMMITTEDLOCK to the validating read and test it with two concurrent sessions.
Multi-table updates
In UPDATE a ... FROM a JOIN b, the target rows are located with update locks on current data. Table b is read from versions. Derived columns calculated from b can therefore use values that are committed but out of date. Add WITH (READCOMMITTEDLOCK) to b if this matters.
Queue tables
READPAST cannot be combined with plain read committed behaviour when RCSI is on. Specify the locking hint:
;WITH next AS (
SELECT TOP (1) id, payload, state
FROM dbo.WorkQueue WITH (UPDLOCK, ROWLOCK, READPAST, READCOMMITTEDLOCK)
WHERE state = 0
ORDER BY id
)
UPDATE next SET state = 1
OUTPUT inserted.id, inserted.payload;
Find candidates across the database:
SELECT OBJECT_SCHEMA_NAME(object_id) AS sch, OBJECT_NAME(object_id) AS obj
FROM sys.sql_modules
WHERE definition LIKE '%READPAST%'
OR definition LIKE '%NOLOCK%'
OR definition LIKE '%READUNCOMMITTED%';
Warning
NOLOCKstill performs dirty reads after RCSI is on. Remove the hints, or you pay for versioning and keep the wrong results.
- Check-then-act code rewritten or protected.
- Triggers reviewed and tested with two sessions.
- Queue readers carry
READCOMMITTEDLOCK. - Application SQL outside the database searched too.
Size the version store and the row overhead
Versioned rows carry up to 14 extra bytes, added when a row is inserted or next modified. Existing rows are not rewritten at the switch; they grow over time. On full pages that growth causes page splits. For update-heavy indexes at fill factor 100, rebuild with a lower value (for example 95) after the switch.
Without accelerated database recovery (ADR), versions live in tempdb. With ADR, they live in the persistent version store inside the user database. A rough starting point for tempdb is:
version store size ≈ version generation rate (KB/s) × longest versioned transaction or statement (s) × 2
Measure the rate in a test run with the performance counters:
SELECT counter_name, cntr_value
FROM sys.dm_os_performance_counters
WHERE object_name LIKE '%:Transactions%'
AND (counter_name LIKE 'Version%' OR counter_name LIKE 'Longest Transaction%'
OR counter_name LIKE 'Free Space in tempdb%');
The per-second counters are cumulative in this DMV; sample twice and divide the difference by the interval.
- tempdb has headroom on pre-grown, equally sized files.
- Abandoned transactions are alerted on. One open transaction can hold cleanup back for the whole instance when versions are in tempdb.
- If the database has a readable secondary, its primary already adds the 14 bytes. Readable secondaries also have their own version store load to plan for.
Make the switch
The option change needs no other active connections in the database until it completes. Single-user mode isn't required.
Caution
ROLLBACK IMMEDIATEends other sessions and rolls back their open transactions. A long rollback delays the change. Without a termination clause, the statement waits while new work can queue up behind it. Use a maintenance window and stop the application first.
-- Run from master with the application stopped
ALTER DATABASE Sales SET READ_COMMITTED_SNAPSHOT ON WITH ROLLBACK IMMEDIATE;
To fail at once rather than disconnect anyone:
ALTER DATABASE Sales SET READ_COMMITTED_SNAPSHOT ON WITH NO_WAIT;
On an availability group, run it on the primary, test it on a non-production AG first and pause monitoring tools that reconnect every second. Confirm with the sys.databases query above.
- Application and Agent jobs stopped.
- No large open transactions (
DBCC OPENTRAN ('Sales')). - Rollback agreed: the same statement with
OFF, which needs the same quiet window.
Watch the first two weeks
-- Space by database (tempdb version store)
SELECT DB_NAME(database_id) AS db, reserved_space_kb / 1024 AS mb
FROM sys.dm_tran_version_store_space_usage
ORDER BY reserved_space_kb DESC;
-- Who is keeping old versions alive
SELECT session_id, elapsed_time_seconds, is_snapshot,
max_version_chain_traversed, average_version_chain_traversed
FROM sys.dm_tran_active_snapshot_database_transactions
ORDER BY elapsed_time_seconds DESC;
Avoid scanning sys.dm_tran_version_store on a busy server; it returns a row for each version record.
| Symptom | Cause | Fix |
|---|---|---|
| tempdb grows steadily | Long transaction holding versions | End it; fix the caller; consider ADR |
| Error 3967, then 3966 | tempdb full; version store was shrunk and readers chosen as victims | Add space, find the oldest transaction |
| Error 3958 | Needed version was never generated | Retry after fixing tempdb space |
| Reader CPU up on hot rows | Long version chains | Shorten transactions; reduce repeated updates |
| Duplicate or oversold rows | Check-then-act code missed in the audit | Atomic statement or UPDLOCK, HOLDLOCK |
Error 3960 is an update conflict under SNAPSHOT isolation, not RCSI. If you see it, something requested snapshot explicitly.
Prevent it next time
- Enable RCSI on new databases before any code is written. Put it in the build script or
model. - Fail code review on new
NOLOCKhints. - On SQL Server 2025, plan RCSI with ADR and optimized locking. ADR is a prerequisite for optimized locking, and its lock-after-qualification part works only with RCSI on.
- Alert on version store size and the oldest versioned transaction, not only on tempdb free space.
- Keep a two-session concurrency test for each business rule that spans rows or tables.
Get the weekly HubDatAI email
One email a week with everything new: posts, learning sessions and videos. Free, no spam, unsubscribe in one click. What you get