Distributed Transactions Flashcards
What is a transaction?
Sequence of server operations guarenteed to be completed.
How do transactions comply to ACID?
Atomicity: Transactions are either completed or aborted.
Consistency: 1 consistent state to another.
Isolation: Transactions happen without interference from other transactions.
Durability: Results of transactions stored in permanent storage.
Why must objects be recoverable?
If a process crashes during a transactions, a new process can recover the objects from storage and continue the transaction.
Why must operations be synchronised?
To ensure isolation
When can transactions happen concurrently?
When concurrent execution has the same effect as serial execution.
What is the lost update problem?
Transaction T reads the value of x. (suspends) Transaction U reads the value of x. Transaction U adds 4 to value of x. Transaction U commits. Transaction T adds 5 to old value of x. Transaction T commits. Changes made by U are overridden.
What is the inconsistent retrieval problem?
Wrong retrieval of data because a transactipon accesses data before another has finished modifying it. (T) a.withdraw(100):100 (U) total = a.get(): 100 (U) total += b.get(): 400 (T) b.deposit(100):400 (T) commit (U) commit
What is a conflicting operation?
A pair of operations that, when executed in different orders, produce different values.
(Read->Write != Write-> Read)
What does serial equivalence require?
All conflicting operations to be executed in the same order for all processes.
What is locking?
Using locks to ensure that only one transaction can access data at any one time.
What can locking lead to?
Deadlock
What is optimistic concurrency?
Executing both transactions and checking for conflicts before commiting. If conflicts are found, both transactions are aborted.
What is timestamp ordering?
Using total ordering of transactions based on start.
If object O was last read/written by EARLIER transactions, O can be written to.
If O was last written to by EARLIER transactions, O can be read.
How are dirty reads prevented?
Delay commit of U until all transactions from which U has observed a value have also committed.
How can cascading aborts be prevented?
Only allow reads from commited transactions.
How are premature writes prevented?
Delay writes until other transactions that have affecting values have commited.
What is a distributed transaction?
Transactions that access objects managed by multiple servers.
What is the two-phase commit protocol?
Protocol that allows for atomicty of distributed transactions by ensuring all processes have been completed successfully before committing changes.
What is phase 1 of the 2PC protocol?
Each server votes for the transaction to be commited or aborted.
When a server votes commit, state = PREPARED
What is phase 2 of the 2PC protocol?
If any server votes to abort, all must abort transaction.
If all servers vote commit, transaction can be committed.
What are the timeout situations and solutions for distributed transactions? (3)
- Server doesn’t receive joint decision: Request decision again (Coordinator may have crashed.)
- Server not received abort/commit request: Abort
- Coordinator not received votes from all servers: Can decide to abort, inform all servers.