Transaction Management

Transaction

Failures

Transaction manager

DB constraints may not be satisfied during the transaction.

ACID:

Recovery

SQL

Concurrency

Three problems resulting from interleaving of transactions that are 'correct in itself' i.e. do not violate the Golden Rule:

Locking

Locking granularity: individual tuples vs whole table (concurrency vs overhead)

Transactions A and B holding exclusive (X) locks or shared (S) locks on tuple t

Wait state:

Data access protocol (locking protocol):

Concurrency problems with locks:

Two options to detect deadlock:

Then:

Serializing

Schedule: execution of transactions

Criterion for correctness:

Note that schedules S1 and S2 may be correct and produce different results!

Eswaran's two-phase locking theorem:

Two-phase locking protocol:

Note: the two-phase locking protocol can still lead to deadlocks.

Isolation Levels

Problems with lower isolation levels (violations of serializability):

Isolation levels and associated violations:

dirty nonrep phantom
READ UNCOMMITTED Y Y Y
READ COMMITTED N Y Y
REPEATABLE READ N N Y
SERIALIZABLE N N N

References:

PostgreSQL 9.1.14 Documentation - 13.2. Transaction Isolation