❖ Transaction Isolation |
Simplest form of isolation: serial execution (T1 ; T2 ; T3 ; ...)
Problem: serial execution yields poor throughput.
Concurrency control schemes (CCSs) aim for "safe" concurrency
Abstract view of DBMS concurrency mechanisms:
❖ Serializability |
Consider two schedules S1 and S2 produced by
❖ Serializability (cont) |
Two formulations of serializability:
❖ Checking Serializability |
Conflict serializablility checking:
make a graph with just nodes, one for each Ti for each pair of operations across transactions { if (Ti and Tj have conflicting ops on variable X) { put a directed edge between Ti and Tj where the direction goes from first tx to access X to second tx to access X if this new edge forms a cycle in the graph return "Not conflict serializable" } } return "Conflict serializable"
❖ Checking Serializability (cont) |
View serializability checking:
// TC,i denotes transaction i in concurrent schedule for each serial schedule S { // TS,i denotes transaction i in serial schedule for each shared variable X { if TC,i reads same version of X as TS,i (either initial value or value written by Tj) continue else give up on this serial schedule if TC,i and TS,i write the final version of X continue else give up on this serial schedule } return "View serializable" } return "Not view serializable"
❖ Transaction Isolation Levels |
SQL programmers' concurrency control mechanism ...
set transaction read only -- so weaker isolation may be ok read write -- suggests stronger isolation needed isolation level -- weakest isolation, maximum concurrency read uncommitted read committed repeatable read serializable -- strongest isolation, minimum concurrency
Applies to current tx only; affects how scheduler treats this tx.
❖ Transaction Isolation Levels (cont) |
Implication of transaction isolation levels:
Isolation Level |
Dirty Read |
Nonrepeatable Read |
Phantom Read |
Read Uncommitted |
Possible | Possible | Possible |
Read Committed |
Not Possible | Possible | Possible |
Repeatable Read |
Not Possible | Not Possible | Possible |
Serializable | Not Possible | Not Possible | Not Possible |
❖ Transaction Isolation Levels (cont) |
For transaction isolation, PostgreSQL
For more details, see PostgreSQL Documentation section 13.2
UPDATE
INSERT
DELETE
❖ Transaction Isolation Levels (cont) |
A PostgreSQL tx consists of a sequence of SQL statements:
BEGIN S1; S2; ... Sn; COMMIT;
Isolation levels affect view of DB provided to each Si:
❖ Transaction Isolation Levels (cont) |
Example of repeatable read vs serializable
❖ Concurrency Control |
Isolation requires some method to control concurrency
Possible approaches to implementing concurrency control:
Produced: 14 Apr 2021