Is It a Problem?
It matters for the same reason as the other range lock waits: most systems never chose serializable on purpose. Concurrent inserts into the same key range under serializable block each other, and upsert code that checks then inserts under HOLDLOCK is a well-known deadlock recipe. It was zero on our SQL Server 2025 lab. Get Wait Statistics does not filter it out, so if it ranks, you will see it.
What It Means
Microsoft’s definition: waiting to acquire a NULL lock on the current key value, and an Insert Range lock between the current and previous key, where the NULL lock is an instant release lock. The locking guide describes RangeI-N as used to test ranges before inserting a new key. Key-range locks only exist under SERIALIZABLE isolation, or with a HOLDLOCK hint, where the locking guide uses them to stop phantom rows appearing in a range a transaction has read.
When It Does Matter
When it rises with deadlocks. Find out who runs serializable and why:
SELECT
s.session_id,
s.login_name,
s.program_name,
s.transaction_isolation_level
FROM sys.dm_exec_sessions AS s
WHERE s.transaction_isolation_level = 4;
The usual sources:
- Code or connections that set
SERIALIZABLEon purpose. - Framework defaults: .NET
TransactionScopedefaults to serializable. HOLDLOCKhints in older procedures and inMERGEupserts.- An isolation level set by one user of a pooled connection carrying over to the next, which is commonly reported.
Rework upserts as a plain insert backed by a unique constraint with a retry on duplicate key, under READ COMMITTED; if serializable must stay, serialise the writers with sp_getapplock. The baseline to monitor is zero sessions at isolation level 4 that you did not plan for. The query needs VIEW SERVER STATE.
The LCK_M Family
Every lock mode has its own wait type, and the name says which lock the waiting session asked for. The check is the same for all of them: find the waiter, then follow blocking_session_id to the head of the chain.
- LCK_M_X / S / URow and page locks. Exclusive, shared and update, the everyday blocking waits, with the full blocking walkthrough.The main lock waits page
- LCK_M_SCH_SSchema stability. Every query needs it, so a queued SCH-M request stalls them all.Worth investigating
- LCK_M_SCH_MSchema modification. DDL waiting for every user of the table to let go.Worth investigating
- LCK_M_ISIntent shared. A reader cannot mark the table because a writer holds the whole of it.Worth investigating
- LCK_M_IXIntent exclusive. A writer cannot mark the table, so modifications stall at table level.Worth investigating
- LCK_M_SIXShared with intent exclusive. A transaction that reads the whole table and changes some of it; rare, so any amount stands out.Worth investigating
- LCK_M_RS_SRange shared. Serializable reads locking key ranges; check whether that isolation level was chosen.Worth investigating
- LCK_M_RS_URange update. A serializable search for rows it means to update.Worth investigating
- LCK_M_RX_XRange exclusive. Serializable writes locking the gaps between keys, a common deadlock ingredient.Worth investigating
- LCK_M_RIn_NLInsert range. A serializable insert waiting to lock the gap it lands in.Worth investigating. This page.
- _LOW_PRIORITYLow priority variants. Index operations and partition switches waiting under WAIT_AT_LOW_PRIORITY.Usually the feature working
Where To Go Next
LCK_M_RIn_NL means serializable is in use. If you are chasing a real problem, start with the waits that cost you time.
- LCK_M_RX_X, the exclusive range lock, with the serializable checks in full.
- Troubleshoot SQL Server Blocking, Step by Step, from the first symptom to the head blocker.
- The waits that usually matter, ranked, with what each one is telling you.
- Performance & Troubleshooting, the scripts and guides for this part of the stack.
Leave a Reply