Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic...
-
Upload
brian-clark -
Category
Documents
-
view
224 -
download
0
Transcript of Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic...
![Page 1: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/1.jpg)
Transactionsand
Concurrency Control
![Page 2: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/2.jpg)
Concurrent Accesses to an Object
• Multiple threads
• Atomic operations
• Thread communication
• Fairness
![Page 3: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/3.jpg)
Operations of the Account Interface
Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.
![Page 4: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/4.jpg)
Operations of the Branch Interface
Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.
![Page 5: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/5.jpg)
Transactions (on Objects)
• The basic concept: a sequence of client requests performed as an indivisible unit.
• Properties: Atomicity, Consistency, Isolation, and Durability.
• Means to maximize concurrency: serializable interleavings
![Page 6: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/6.jpg)
A Client’s Bank Transaction
Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.
![Page 7: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/7.jpg)
A Failure Model
• Writes to permanent storage may fail
• Processors may crash
• Messages may be delayed or even lost
The faults are assumed to be detectable.
![Page 8: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/8.jpg)
Operations in the Coordinator Interface
Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.
![Page 9: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/9.jpg)
Transaction Life Histories
Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.
![Page 10: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/10.jpg)
The Lost Update Problem
Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.
![Page 11: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/11.jpg)
The Inconsistent Retrievals Problem
Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.
![Page 12: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/12.jpg)
Serializable Interleavings
Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.
![Page 13: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/13.jpg)
Serializable Interleavings (cont’d)
Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.
![Page 14: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/14.jpg)
Ensuring Serializability
All pairs of conflicting operations of two transactions should be executed in the same order to ensure serializability.
(Two operations conflict if their combined effect depends on the order in which they are executed.)
![Page 15: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/15.jpg)
Conflict Rules for Read and Write
Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.
![Page 16: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/16.jpg)
A Non-Serializable Interleaving
Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.
![Page 17: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/17.jpg)
Recoverability from Aborts
• Dirty reads
• Cascading aborts
• Premature writes
• Strict executions of transactions
• Use of tentative versions
![Page 18: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/18.jpg)
A Dirty Read
Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.
![Page 19: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/19.jpg)
Overwriting Uncommitted Values
Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.
![Page 20: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/20.jpg)
Nested Transactions
Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.
![Page 21: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/21.jpg)
Advantages of Nested Transactions
• Subtransactions at the same level may run concurrently
• Subtransactions can commit or abort independently
![Page 22: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/22.jpg)
Methods of Concurrency Control
• Locking: locks are used to order transactions according to the order of arrival of their operations at the same data item
• Optimistic concurrency control: transactions are allowed to proceed until they are ready to commit, whereupon a check is made to see whether they have performed conflicting operations
• Timestamp ordering: timestamps are used to order transactions according to their starting times
![Page 23: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/23.jpg)
Exclusive Locks
Exclusive locks are a simple serializing mechanism:
• Two-phase locking: all locks are acquired in the first phase and released in the second
• Strict two-phase locking: locks are held until the transaction commits or aborts.
Granularity is an important issue.
![Page 24: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/24.jpg)
Using Exclusive Locks
Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.
![Page 25: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/25.jpg)
Locking
• A pair of read operations on the same data item do not conflict.
• Exclusive locks reduce concurrency more than is necessary.
• The “many reader/single write” scheme distinguishes two types of lock: read (shared) locks and write locks.
• Two-phase locking or strict two-phase locking still applies for ensuring serializability.
![Page 26: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/26.jpg)
Lock Compatibility
Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.
![Page 27: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/27.jpg)
Lock Management
Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.
![Page 28: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/28.jpg)
A Lock Implementation
Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.
![Page 29: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/29.jpg)
A Lock Implementation (cont’d)
Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.
![Page 30: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/30.jpg)
A Lock Manager Implementation
Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.
![Page 31: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/31.jpg)
Deadlocks
• The use of locks may lead to deadlock.
• Deadlock is a state in which each member of a group of transactions is waiting for some other member to release a lock.
• A wait-for graph can be used to represent the waiting relationships between concurrent transactions at a server.
![Page 32: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/32.jpg)
A Deadlock
Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.
![Page 33: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/33.jpg)
A Wait-For Graph
Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.
![Page 34: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/34.jpg)
A Cycle in a Wait-For Graph
Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.
![Page 35: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/35.jpg)
Another Wait-For Graph
Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.
![Page 36: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/36.jpg)
Deadlock Prevention Techniques
• Lock (in one atomic step) all data items used by a transaction when it starts.
• Every transaction requests locks on data items in a predefined order.
• Each lock is given a limited period, after which it becomes vulnerable.
![Page 37: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/37.jpg)
Deadlock Detection
• Deadlocks may be detected by finding cycles in the wait-for graph.
• Two design issues:
* Frequency of checking the existence of a cycle
* Choice of transactions to be aborted
![Page 38: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/38.jpg)
Resolving a Deadlock
Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.
![Page 39: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/39.jpg)
Increasing Concurrency
• Two-version locking: allows one transaction to write tentative versions of data items while other transactions read from the committed version of the same data item; read operations wait only if another transaction is currently committing the same data item
• Hierarchic locks: at each level, the setting of a parent lock has the same effect as setting all the equivalent child locks
![Page 40: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/40.jpg)
Lock Compatibility
Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.
![Page 41: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/41.jpg)
A Lock Hierarchy
Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.
![Page 42: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/42.jpg)
Compatibility of Hierarchical Locks
Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.
![Page 43: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/43.jpg)
Drawbacks of Locking
• Overhead of lock maintenance: some locks may be unnecessary
• Reduced concurrency due to
* deadlock prevention
* holding locks until the end of a transaction (to avoid cascade aborts)
In some applications, the likelihood of conflict is low.
![Page 44: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/44.jpg)
Optimistic Concurrency Control
• Transactions are allowed to proceed as though there were no possibility of conflict with other transactions until the client issues a CloseTransaction request.
• When a conflict is detected, some transaction is aborted.
![Page 45: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/45.jpg)
Optimistic Concurrency Control (cont’d)
Each transaction has three phases:
• Read phase: use a tentative version for each updated data item
• Validation phase: checking if there is a conflict
• Write phase: if validated, all tentative versions are made permanent
![Page 46: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/46.jpg)
Naive Read/Write Rules
Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.
![Page 47: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/47.jpg)
Validation
Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.
![Page 48: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/48.jpg)
Validation of Transactions
• For validation purposes, each transaction is assigned (in an ascending order) a transaction number when it enters the validation phase.
• A transaction always finishes its read phase after all transactions with lower numbers.
![Page 49: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/49.jpg)
Validation of Transactions (cont’d)
• Validation phases may overlap (but transaction numbers should be assigned sequentially).
• All write phases are executed sequentially according to their transaction numbers so that there is no need to check write-write conflicts.
* Reuse of transaction numbers (as suggested in the book) is not a very good idea.
![Page 50: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/50.jpg)
Validation
Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.
![Page 51: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/51.jpg)
Comparing Backward and Forward Validation
• Backward: abort the transaction being validated
Forward: three options:* defer the validation until the conflicting (and active) transactions have finished
* abort all the conflicting active transactions and commit the one being validated
* abort the transaction being validated
![Page 52: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/52.jpg)
Comparing Backward and Forward Validation (cont’d)
• Backward: must retain the write sets of committed transactions that may conflict with active transactions
Forward: must allow for new transactions to start during validation
• Backward: compare a possibly large read set against old write sets
Forward: compare a small write set against the read sets of active transactions
![Page 53: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/53.jpg)
Timestamp Ordering
• Each transaction is assigned a unique timestamp value when it starts.
• Every operation bears the timestamp of its issuing transaction and is validated when it is carried out.
• If the operation cannot be validated, then the transaction is aborted immediately.
![Page 54: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/54.jpg)
Read/Write Rules
Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.
![Page 55: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/55.jpg)
Writes and Timestamp Ordering
Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.
![Page 56: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/56.jpg)
Write Rules in Timestamp Ordering
Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.
![Page 57: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/57.jpg)
Reads and Timestamp Ordering
Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.
![Page 58: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/58.jpg)
Read Rules in Timestamp Ordering
Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.
![Page 59: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/59.jpg)
Timestamp Ordering
Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.
![Page 60: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/60.jpg)
Relaxing the Write Rule
• If a write is too late it can be ignored instead of aborting the transaction, because if it had arrived in time its effects would have been overwritten anyway.
• However, if another transaction has read the data item, the transaction with the late write fails due to the read timestamp on the item.
![Page 61: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/61.jpg)
Multiversion Timestamp Ordering
• The server keeps old committed versions as well as tentative versions in its list of versions of data items.
• With the list, Read operations that arrive too late need not be rejected.
• A Read operation of a transaction is directed to the version with the largest write timestamp less than the transaction timestamp.
![Page 62: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/62.jpg)
A Late Write Invalidating a Read
Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.
![Page 63: Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.](https://reader036.fdocuments.net/reader036/viewer/2022081603/5697bf751a28abf838c806b9/html5/thumbnails/63.jpg)
Comparison
Locks Timestamps
"Attitude" pessimistic optimistic
OrderDecision
dynamic static
BenefitingTrans.
more writesthan reads
read-only
ConflictResolution
wait; mayabort later
abortimmediately