ACID & Basic Transactions — Series 3

Preview — 3 of 10 questions

After COMMIT; runs successfully, what happens to the changes made in that transaction?

AThey remain visible only to the session that made them, forever
BThey're held in a pending state until the next VACUUM runs
CCOMMIT only saves changes to disk; other sessions still can't see them until they reconnect
DThey become permanent and immediately visible to any other session that queries the affected rows afterward — COMMIT is the point at which a transaction's changes stop being private to that session and become part of the database's actual, durable state

A transaction transfers money: UPDATE accounts SET balance = balance - 100 WHERE id = 1; then UPDATE accounts SET balance = balance + 100 WHERE id = 2;. If the second statement fails and the transaction is rolled back, what happens to the first statement's effect?

AThe first statement's -100 change stays applied, since it already succeeded before the failure
BBoth statements are undone together — the whole transaction is treated as one atomic unit, so a failure anywhere inside it means none of its statements' effects survive, not just the one that literally failed
COnly the second statement is undone; the first one needs a separate manual ROLLBACK
DThe database automatically retries the second statement instead of rolling back

A session runs BEGIN; followed by an UPDATE, but the client's connection drops before COMMIT is ever sent. What happens to the UPDATE?

AIt's automatically committed, since the server assumes the client intended to finish
BPostgreSQL pauses the transaction indefinitely, waiting for the client to reconnect and finish it
CThe transaction is automatically rolled back — an uncommitted transaction whose connection is lost never gets a chance to COMMIT, so its changes are simply discarded, exactly as if ROLLBACK had been explicitly issued
DThe UPDATE is retried on a different connection automatically

Sign up free to play

Answer all 10 questions (7 more), see explanations for every answer, and track your score.