Important Reading to help understand:
Notes
A - Atomicity (All or nothing of a transaction) C - Consistency (Consistent with the constraints on database tables) I - Isolation D - Durability (Handling reboots/failures)
Isolation
3 types of dependencies that can help determine serializability -
- Write - Write Dependency
- Write - Read Dependency
- Read - Write Dependency (Anti dependency)
Anti Dependency: An anti-dependency, also known as write-after-read (WAR), occurs when an instruction requires a value that is later updated. In the following example, instruction 2 anti-depends on instruction 3 — the ordering of these instructions cannot be changed, nor can they be executed in parallel (possibly changing the instruction ordering), as this would affect the final value of A.
- B = 3
- A = B + 1
- B = 7
A single operation transaction isn’t linearizable because single operation transaction still doesn’t guarantee real time ordering which is something that’s required for linearizability.
Concurrency
How to detect deadlock?
- Lock everything (Doesn’t work because unnecessary locks acquired)
- Timeouts (Timeout if a transaction is blocked beyond a certain amount of time, it is assumed that a deadlock has occurred)
- Graph detection (Create a graph of transactions, if it is cyclic then deadlock. Problem is performance)
- Give priorities to transactions (Could be based on TID or some kind of timestamp)
- Wound wait
- Wait die