Tuesday, November 10, 2026

Transaction Isolation Level

SQL Server Concurrency Problems

Problem Explanation
Dirty ReadReading uncommitted changes from another transaction.
Non-Repeatable ReadReading the same row twice and getting different values.
Phantom ReadRepeating a query returns additional or missing rows due to concurrent inserts or deletes.
Lost UpdateOne transaction overwrites another transaction's update.
Write SkewTransactions read the same state and update different rows, jointly violating a business constraint.
Read SkewReading related data at different times, resulting in an inconsistent combination.
Dirty WriteOverwriting data modified by another uncommitted transaction.
DeadlockTransactions wait for each other in a circular dependency. SQL Server aborts one victim.
LivelockA transaction repeatedly loses opportunities to proceed due to competing transactions.
StarvationA transaction is continually denied resources or access.
Lock EscalationSQL Server replaces many fine-grained locks with a table-level or partition-level lock.
Hot SpotMany transactions compete for the same frequently accessed row or resource.

SQL Server Isolation Levels

Problem Read Uncommitted Read Committed Repeatable Read Snapshot Serializable
Dirty ReadPossibleNoNoNoNo
Non-Repeatable ReadPossiblePossibleNoNoNo
Phantom ReadPossiblePossiblePossibleNoNo
Lost UpdatePossiblePossible*Possible*No**No
Write SkewPossiblePossiblePossiblePossibleNo
Read SkewPossiblePossiblePossibleNoNo

Notes:

  • READ COMMITTED is the default SQL Server isolation level.
  • READ_COMMITTED_SNAPSHOT uses row versioning for Read Committed.
  • SNAPSHOT provides transaction-level consistent reads.
  • SNAPSHOT detects conflicting updates to the same row.
  • SERIALIZABLE uses range locks to prevent phantom inserts and serialization anomalies.
  • * Lost updates depend on the read-modify-write pattern and locking strategy.
  • ** SNAPSHOT aborts one transaction when both transactions attempt conflicting updates to the same row.

No comments:

Post a Comment

Transaction Isolation Level - Snapshot

PostgreSQL REPEATABLE READ = SQL Server SNAPSHOT (similar transaction-level snapshot behavior).