Bird
0
0

In PostgreSQL, what happens if two concurrent transactions under SERIALIZABLE isolation try to update the same row simultaneously?

medium📝 query result Q5 of 15
PostgreSQL - Transactions and Concurrency
In PostgreSQL, what happens if two concurrent transactions under SERIALIZABLE isolation try to update the same row simultaneously?
APostgreSQL automatically merges the changes
BBoth transactions succeed and overwrite each other
CBoth transactions are blocked indefinitely
DOne transaction will succeed; the other will get a serialization failure error
Step-by-Step Solution
Solution:
  1. Step 1: Understand SERIALIZABLE isolation

    SERIALIZABLE prevents concurrent conflicting updates by enforcing strict ordering.
  2. Step 2: Analyze concurrent update conflict

    One transaction commits; the other fails with serialization error to avoid conflicts.
  3. Final Answer:

    One transaction will succeed; the other will get a serialization failure error -> Option D
  4. Quick Check:

    SERIALIZABLE = strict conflict detection [OK]
Quick Trick: Serializable aborts conflicting concurrent transactions [OK]
Common Mistakes:
  • Thinking both succeed
  • Assuming automatic merge

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes