CS FundamentalsVery hardProduct company interview · GATE level
A SERIALIZABLE transaction in PostgreSQL (which uses Serializable Snapshot Isolation, SSI) can occasionally abort with a serialization failure even though it did nothing 'wrong' on its own. Why might this legitimately happen?
- A. It only happens if the transaction explicitly requests an abort
- B. PostgreSQL's SERIALIZABLE is identical to READ COMMITTED, so this cannot happen
- C. It is always a bug in PostgreSQL that should be reported
- D. SSI monitors for patterns of concurrent reads/writes among transactions that COULD produce a non-serializable outcome (like write skew) and proactively aborts one of them, even if, in this particular run, the actual values involved wouldn't have caused a real anomaly — this is a conservative, sound-but-not-complete mechanism
Correct answer: D. SSI monitors for patterns of concurrent reads/writes among transactions that COULD produce a non-serializable outcome (like write skew) and proactively aborts one of them, even if, in this particular run, the actual values involved wouldn't have caused a real anomaly — this is a conservative, sound-but-not-complete mechanism
True serializability enforcement (as opposed to just forbidding the three named anomalies) is undecidable to check perfectly and cheaply at runtime, so SSI uses a conservative approximation: it tracks certain read/write dependency patterns (rw-antidependencies) that COULD lead to a serialization anomaly and aborts a transaction when such a pattern is detected, even in some cases where the actual run would have been fine — a known, accepted cost of guaranteeing true serializability efficiently.
More DBMS and SQL questions
- A table has a UNIQUE constraint on (email) and a separate UNIQUE constraint on (phone). An application inserts a row where email already…
- A column is declared NOT NULL DEFAULT 0. An application performs INSERT INTO T (othercol) VALUES (5); without mentioning this column at…
- A transaction executes UPDATE Accounts SET balance = balance - 100 WHERE id = 1; followed immediately (same transaction) by SELECT balance…
- A B+ tree index supports efficient range queries because leaf nodes are linked in sorted order. For a query WHERE age BETWEEN 25 AND 35…
- A table is partitioned by RANGE on a date column (e.g. one partition per year). A query filters WHERE saledate BETWEEN '2023-01-01' AND…
- A relation R(A, B, C, D, E) has FDs AB → CDE and E → B. What are the candidate key(s) of R?