6. Concurrency Flashcards
Lock-Based Protocols
1- ___ (X) mode
2- ___(S) mode
Exclusive
Shared
Exclusive (X) mode
Data item can be both ___. X-lock is requested using lock-X instruction.
Read and written
Shared (S) mode
Data item can only be ___. S-lock is requested using lock-S instruction.
Read
Deadlock
Happens when at least two ___ want the lock of ___
Transactions
Each other
Starvation
Transaction needs to rollback beacause other transactions are constantly getting the desired ___
Lock
Two-Phase Locking Protocol
1- ___ phase - ___obtain / ___ release Locks
2- ___ phase - ___ Obtain / ___release Locks
Growing / Can, Can’t
Shrinking Can’t, Can
Graph-Based Protocols
A lock can only be obtained if the ___ lock is already obtained by the ___ transaction. We can’t ___unlocked items
Parent
Same
Re-lock
Deadlock prevention protocols
Ensure that the system does not enter into a ___ state. Some prevention strategies:
1- Require that the transaction locks ___ before executing
2- ___ all data items and only allow locking in that ___
Deadlock
Everything
Order
Wait-die scheme
Order transactions ___ while younger transactions ___
Wound-wait
Older transactions force younger ones to ___
Younger transactions ___
Timeout-based
Wait for only a specified amount of time then is ___
Wait Rollback Rollback Wait Rollback
Deadlock Detection (Wait-for graph) The system is in a deadlock state if and only if the wait-for graph has a \_\_\_.
Cycle
Intention Lock Modes
1- ___ (IS) - ___ locks at lower levels of tree
2- ___ (IX) - ___ or ___ locks at lowers level of the tree
3- ___ (SIX) - a ___ lock, with the possibility of
having exclusive or shared locks at lower levels of the tree.
1- Intention-shared / Shared
2- Intention-exclusive / Exclusive or shared
3- Shared and intention-exclusive / Shared
Multiple Granularity Locking Scheme
Before requesting IS or S lock, all ancestors nodes must be locked in ___
Before requesting IX, SIX or X lock, all ancestors nodes must be locked in ___
Leaf nodes are always locked in __, since they have no descendants
Locks are acquired in ___ oder
Locks are released during transaction in ___ order or at the end in ___ order
Cannot ___ locks
IS or IX IX or SIX S or X Root-to-leaf Leaf-to-root / any Reacquire
Timestamp Ordering
Read needs to take ___ time than largest ___ time saved, otherwise save new read time
Write needs to take ___ time than largest ___ and ___ time saved, otherwise save new ___ time
More Write More Read and Write Write
Multiversion Timestamp Ordering
Equal to Timestamp ordering but we access version Qk that has the ___ W-Timestamp
Largest
Snapshot Isolation
- Each transaction is given its own ___ of the database
- Updates are kept in the snapshot until the transaction ___
- Reqad Request never __ or ___
Snapshot
Commits
Wait or fail