Bird
0
0

What will Transaction A see if it reads the same row again before committing?

medium📝 query result Q13 of 15
PostgreSQL - Transactions and Concurrency
Consider two concurrent transactions in PostgreSQL using the REPEATABLE READ isolation level. Transaction A reads a row, then Transaction B updates and commits that row. What will Transaction A see if it reads the same row again before committing?
AThe updated row from Transaction B
BThe original row before Transaction B's update
CAn error due to concurrent update
DNo row, because it is locked
Step-by-Step Solution
Solution:
  1. Step 1: Understand REPEATABLE READ snapshot

    REPEATABLE READ provides a consistent snapshot for the whole transaction, so it sees data as it was at the start.
  2. Step 2: Apply to scenario

    Transaction A will see the original row even after Transaction B commits an update, because its snapshot does not change.
  3. Final Answer:

    The original row before Transaction B's update -> Option B
  4. Quick Check:

    REPEATABLE READ = consistent snapshot [OK]
Quick Trick: REPEATABLE READ shows data as of transaction start [OK]
Common Mistakes:
  • Assuming it sees latest committed data mid-transaction
  • Expecting an error or lock blocking read
  • Confusing with READ COMMITTED behavior

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes