Critique of ANSI SQL Isolation Levels

Notes Types of locks - Write lock Read lock Predicate lock - Lock where multiple rows are locked for reads(WHERE clause) All of these locks are long locks(Meaning all are acquired first and then all are released)(2 Phase locking) If we wanna improve performance(and decrease isolation levels), we can reduce long locks to short locks. Types of anomalies - Phantom Reads is we do a search condition (using WHERE clause) and then Read1, Write1 and Read2. Read1 =/= Read2. Fuzzy Reads is Read1, Write1 and Read2. Read1 =/= Read2. Dirty Reads is where we can read an uncommitted value of a transaction. Read Skew is where Tx 1 has a write(x) and then read(y) and Tx 2 has a write(y) and then read(x) causing the system to be non-serializable. Write Skew is where Tx 1 has a read(x) and then write(y) and Tx 2 has a read(y) and then write(x) causing the system to be non-serializable. ...

Percolator

Notes Bigtable doesn’t support multi-row/multi-table transactions. Why does Google need multi-table transactions? Removing duplicates(Multiple URLs may lead to the same website), calculation of pagerank will get affected. Built on top of big table, because didn’t have that many people working on it and also didn’t have source code access to big table. Locks Locks in percolator could have been implemented in two ways - In place(in database) Problem with this is that you can’t maintain complex locks with queues and techniques like wound wait, wait die, etc. Database overhead Standalone lock service Why is Snapshot Isolation used instead of Optimistic Concurrency Control? Because OCC requires complex locking mechanisms like queues to hold pending locks. ...

Spanner

Notes Two strategies for implementing deadlock prevention used in 2-phase locking Wound wait - Force the lock to release from another transaction Wait die - Wait for lock to be released or die https://stackoverflow.com/questions/32794142/what-is-the-difference-between-wait-die-and-wound-wait-deadlock-prevention-a Distributed Transactions Two problems with distributed transactions Write ahead logging needs to happen on each shard There needs to be a flag on each shard indicating that its in the commit phase (because otherwise locks would be wounded) This is solved using 2-phase commit ...