Transaction: An atomic group of statements that must all succeed or all fail. (e.g. bank money transfer)

Transaction Problems & Isolation Levels

Use Isolation Level: begin; set transaction isolation level <level-name>;

Dirty Read: Reading partial (uncommitted) result from another transaction

  1. Read Committed: Only committed results are seen in a trans~ (Default in Postgres)

Non-repeatable Reads: Reads can change between start and end of a transaction (because of other committed transactions).

  1. Repeatable Read: One trans~ can’t see changes by other trans~ from start to end.

Serialization Anomaly: When two uncommitted transactions produce inconsistent results (When T1+T2 ≠ T1→T2 or T2→T1)

  1. Serializable: Can commit only if result is consistent with committed trans~