Bird
0
0

In PostgreSQL, what happens if a transaction running under REPEATABLE READ tries to update a row that was modified by another concurrent transaction?

easy📝 Conceptual Q2 of 15
PostgreSQL - Transactions and Concurrency

In PostgreSQL, what happens if a transaction running under REPEATABLE READ tries to update a row that was modified by another concurrent transaction?

AThe transaction immediately overwrites the other transaction's changes.
BThe transaction waits until the other transaction commits or rolls back.
CThe transaction raises a serialization failure error.
DThe transaction ignores the conflict and proceeds.
Step-by-Step Solution
Solution:
  1. Step 1: Understand locking in REPEATABLE READ

    PostgreSQL uses row-level locks; conflicting updates cause waiting.
  2. Step 2: Behavior on concurrent updates

    The transaction waits for the other to finish to avoid conflicts.
  3. Final Answer:

    The transaction waits until the other transaction commits or rolls back. -> Option B
  4. Quick Check:

    Concurrent update = Wait for lock release [OK]
Quick Trick: Conflicting updates wait, no immediate overwrite [OK]
Common Mistakes:
  • Assuming immediate overwrite
  • Expecting error instead of wait
  • Ignoring locking behavior

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes