Does running a transaction at the READ UNCOMMITTED isolation level change how its own INSERT, UPDATE and DELETE statements acquire locks, or let it overwrite a row another uncommitted transaction has already modified?
answer
- Isolation = read policy; atomicity = write policy
- Exclusive write locks held to commit, always
- Dirty write forbidden at every level
- Still blocks, still deadlocks
- Not a fix for writer-vs-writer contention
basics
~20 sNo to both. Isolation levels govern reads; write locks are unaffected. Your writes still take exclusive row locks held until commit, and you still block on rows an uncommitted transaction has modified. Dirty writes are forbidden at every level, including this one.
solid answer
~60 sNo. READ UNCOMMITTED relaxes the **read** side only — in a lock-based engine, it means taking no shared read locks. Write locking is untouched: - Your `INSERT`/`UPDATE`/`DELETE` still take **exclusive row locks**, and those are held until the transaction commits or rolls back, at every level. Releasing them earlier would make rollback impossible to honour. - You still **block** on a row an uncommitted transaction has modified. The **dirty write** — replacing a version another in-flight transaction wrote — is prohibited universally, because after such an overwrite the first transaction's rollback could neither restore its pre-image nor leave the second transaction's work intact. - You still deadlock, and can still be chosen as the deadlock victim. The asymmetry is the point: **isolation levels are a read policy, atomicity is a write policy.** A transaction at READ UNCOMMITTED is fully atomic and durable; it just has no guarantees about what it sees. So this level cannot be used to reduce write contention — if writers are blocking each other, lowering isolation changes nothing.
go deeper
Answer no to both parts and state that isolation levels affect reads, not writes.
Explain that exclusive write locks are held to commit at every level and that dirty writes are universally forbidden.
Derive the rule from rollback semantics, note deadlocks and constraint checks are unchanged, and reject the level as a remedy for write contention.
Separate the read-guarantee dial from the atomicity invariant, and steer a contention discussion toward transaction length, lock ordering, access-path narrowing and hot-row design instead.
## The asymmetry to internalise Isolation levels are defined by which **read** anomalies they permit. Every named level — READ UNCOMMITTED included — leaves the write protocol alone. A useful way to hold it: - **Isolation level = what your transaction is allowed to see.** - **Atomicity and durability = what your transaction is allowed to do, and what survives.** Lowering the isolation level trades away read guarantees. It never trades away atomicity, never shortens how long your write locks are held, and never lets you interfere with another transaction's uncommitted writes. ## Why write locks must be held to commit A transaction that modifies a row takes that row's exclusive lock and keeps it until it ends. That duration is not a tuning choice; it is forced by rollback. Suppose the lock were released at the end of the statement: 1. T1 updates row R from 100 to 50 and releases the lock. 2. T2 updates R from 50 to 30 and commits. 3. T1 rolls back. What should R now be? Restoring T1's pre-image gives 100, destroying T2's committed change and violating T2's durability. Leaving 30 means T1's rollback did not undo its effect, violating T1's atomicity. There is no correct answer, so the situation must be prevented — by holding the write lock, which makes step 2 wait until step 3 resolves. This reasoning is independent of isolation level, which is exactly why the rule is universal. ## The dirty write, and why no level permits it The scenario above is the **dirty write**: overwriting a row version created by a still-uncommitted transaction. Every isolation level in the standard forbids it, and every engine enforces it. Note the elegant contrast with the dirty *read*. A dirty read is a hazard the application might, in principle, choose to accept — you see a value that might vanish, and if your use is approximate you may not care. A dirty write is not accept-able by anyone, because it corrupts the engine's own ability to implement rollback. One is an application-level risk that can be delegated; the other is an engine-level invariant that cannot. ## What still happens at READ UNCOMMITTED - **Blocking on write-write conflicts.** Two transactions updating the same row serialise, exactly as at any other level. This is the most common source of contention in an OLTP system, and this level does nothing about it. - **Deadlocks.** Two transactions taking row locks in opposite orders still deadlock and one is still aborted as the victim. Lowering isolation does not reduce deadlock frequency for write-write cycles. - **Constraint enforcement.** Unique indexes, foreign keys, and check constraints are enforced at write or commit time regardless of level. Note the interaction: a unique-index check may have to wait on a conflicting uncommitted insert to learn whether the duplicate becomes real. - **Lock escalation and range locking on writes**, where an engine implements them, follow their normal rules. ## What actually changes Only the read path, and only in engines that implement the level literally. In a lock-based engine, your `SELECT` statements — and the read phase of your own statements, in engines where that phase takes shared locks — stop taking shared locks. The observable effects are: - your reads never wait behind another transaction's exclusive lock; - your reads may return provisional versions that later disappear; - your reads no longer block writers, which historically was the *other* half of the appeal: a long scan at a stronger level could stall writers for its whole duration. In multi-version engines, where reads are already served from committed versions without locking, this changes little or nothing, which is why several such engines map the level onto READ COMMITTED. ## The operational conclusion If your incident is **writers blocking writers** — long lock waits on hot rows, rising deadlock counts, queues behind a slow transaction — the isolation level is the wrong lever entirely. The effective levers are: shorten transactions so locks are held briefly; never hold a write lock across a network call or user think time; touch rows in a consistent order to break deadlock cycles; reduce the number of rows a statement locks by improving its access path; and split hot single rows into shardable counters where the design allows. If your incident is **readers waiting on writers** on a lock-based engine, the isolation level is a lever, but a crude one — and the better answer is usually a multi-version read path or a read replica rather than accepting rolled-back data into a report.
- Why must exclusive write locks be held until commit rather than released at the end of the statement?Because rollback would otherwise be undefinable. If a second transaction overwrote the row and committed, undoing the first transaction would either restore a pre-image and destroy the second transaction's committed work, or leave the second value and fail to undo the first transaction's effect. Holding the lock to commit makes the conflict a wait instead of a contradiction.
- Why can a dirty read be offered as an application choice while a dirty write cannot?A dirty read is a risk borne entirely by the reading application — it may see a value that later vanishes, and an approximate consumer may accept that. A dirty write breaks the engine's own rollback semantics and would corrupt other transactions' atomicity or durability, so it is not a risk any single application is entitled to take on everyone else's behalf.
- A production system shows long write-lock waits and rising deadlocks. Would lowering the isolation level help?No. Write-write contention is governed by exclusive locks that every level holds to commit, so the level has no effect on it. The effective actions are shortening transactions, never holding locks across network calls or user think time, ordering row access consistently to break deadlock cycles, and narrowing statements so they lock fewer rows.
saying these in an interview costs you the question
- Claiming READ UNCOMMITTED lets you write without taking locks
- Thinking write locks are released at statement end at weaker levels
- Believing dirty writes are permitted at the weakest level
- Lowering the isolation level to relieve writer-versus-writer contention
- Assuming a transaction at this level is somehow less atomic or less durable