27
A Survey on Optimistic Concurrency Control CAI Yibo 1010087850 ZHENG Xin 1010121850

A Survey on Optimistic Concurrency Control CAI Yibo 1010087850 ZHENG Xin 1010121850

Embed Size (px)

Citation preview

Page 1: A Survey on Optimistic Concurrency Control CAI Yibo 1010087850 ZHENG Xin 1010121850

A Survey on Optimistic Concurrency Control

CAI Yibo 1010087850ZHENG Xin 1010121850

Page 2: A Survey on Optimistic Concurrency Control CAI Yibo 1010087850 ZHENG Xin 1010121850

Outline

• Introduction• OCC algorithm• Three phases– Backward vs. Forward Validation

• OCC VS. 2PL• Conclusion

Page 3: A Survey on Optimistic Concurrency Control CAI Yibo 1010087850 ZHENG Xin 1010121850

Classification of concurrency control

Page 4: A Survey on Optimistic Concurrency Control CAI Yibo 1010087850 ZHENG Xin 1010121850

Optimistic Concurrency Control

• Principle– transaction proceeds without checking conflict – validates its change prior to commit

• checking if data items have changed by committed transactions• Three phases

– Read Phase• committed version of data items for read - read set• tentative version of data items for write - write set

– Validation Phase• start with End Transaction request• validate if data items have changed by other transactions• if no conflicts, commit; otherwise, abort

– Write phase• make changes permanent

Page 5: A Survey on Optimistic Concurrency Control CAI Yibo 1010087850 ZHENG Xin 1010121850

Validation Phase

• Validation rules– For a transaction Tv to be serializable with respect to an

overlapping transaction Ti

• Validation mechanisms– Backward validation– Forward validation

Tv Ti Rulewrite read 1. Ti must not read objects written by Tv

read write 1. Tv must not read objects written by Ti

write Write 1. Ti must not write objects written by Tv and Tv must not write objects written by Ti

Page 6: A Survey on Optimistic Concurrency Control CAI Yibo 1010087850 ZHENG Xin 1010121850

Backward Validation

• Algorithm– checks transaction in validation phase with other

preceding overlapping transactions that have entered validation phase.

– no check is needed for transaction with only Write operations • since Read operations of earlier transactions are done

already

Page 7: A Survey on Optimistic Concurrency Control CAI Yibo 1010087850 ZHENG Xin 1010121850

Backward Validation

Page 8: A Survey on Optimistic Concurrency Control CAI Yibo 1010087850 ZHENG Xin 1010121850

Forward Validation

• Algorithm– checks transaction in validation phase with other

overlapping active transactions– no check is needed for transaction with only Read

operations• since later transactions do not write until it is done

– other options than aborting the current transaction• defer validation until conflicting transaction finished• abort conflicting transaction instead

Page 9: A Survey on Optimistic Concurrency Control CAI Yibo 1010087850 ZHENG Xin 1010121850

Forward Validation

Page 10: A Survey on Optimistic Concurrency Control CAI Yibo 1010087850 ZHENG Xin 1010121850

Comparison of two validation• Resolution of conflict– backward validation allows only one choice

• Abort the transaction being validated– forward validation allows flexible solutions

• Overhead(In general, number of read sets > number of write sets)– backward validation

• compares a possibly large read set against the old write sets• overhead of storing old write sets

– forward validation• checks a small write set against the read sets of active transactions• need to allow for new transactions starting during validation

Page 11: A Survey on Optimistic Concurrency Control CAI Yibo 1010087850 ZHENG Xin 1010121850

Optimistic VS. Two-Phase Locking

• Distributed High-Performance Systems• Hard Real-Time Systems– Maintain temporal consistency

• Real-Time Database Systems

Page 12: A Survey on Optimistic Concurrency Control CAI Yibo 1010087850 ZHENG Xin 1010121850

In Distributed High-Performance Systems

• Improvement of OCC– Limit the number of repeated transaction restarts

• Primary Metric– Overall Transaction Throughput

• System Capacity– 100 MIPS– 200 MIPS– 400 MIPS

Page 13: A Survey on Optimistic Concurrency Control CAI Yibo 1010087850 ZHENG Xin 1010121850

In Distributed High-Performance Systems

Page 14: A Survey on Optimistic Concurrency Control CAI Yibo 1010087850 ZHENG Xin 1010121850

In Distributed High-Performance Systems

Page 15: A Survey on Optimistic Concurrency Control CAI Yibo 1010087850 ZHENG Xin 1010121850

In Distributed High-Performance Systems

Page 16: A Survey on Optimistic Concurrency Control CAI Yibo 1010087850 ZHENG Xin 1010121850

Distributed High-Performance Systems

• Generally, improved OCC outperforms 2PL, especially in systems with fast processors.

Page 17: A Survey on Optimistic Concurrency Control CAI Yibo 1010087850 ZHENG Xin 1010121850

In Hard Real-Time Systems

• Hard-Real Time System – functional correctness– perform exactly no later than a deadline

• Temporal Consistency – Data objects are temporally consistent if their

ages and dispersions are sufficiently small to meet the requirements of the application

Page 18: A Survey on Optimistic Concurrency Control CAI Yibo 1010087850 ZHENG Xin 1010121850

In Hard Real-Time Systems

Page 19: A Survey on Optimistic Concurrency Control CAI Yibo 1010087850 ZHENG Xin 1010121850

In Hard Real-Time Systems

B represents for period ratio. B = longest period / shortest period. Each period will be in the interval [1, B].

Page 20: A Survey on Optimistic Concurrency Control CAI Yibo 1010087850 ZHENG Xin 1010121850

In Hard Real-Time Systems

• five different conflict patterns– All transactions may conflict with each other.– 0.5 conflicts probability among transactions.– Locality of conflict, which means that the

probability of conflicts among transactions with similar periods is 0.5 while the probability of conflicts among transactions with different periods is 0.2

– 0.2 conflicts probability among transactions.– No conflict at all.

Page 21: A Survey on Optimistic Concurrency Control CAI Yibo 1010087850 ZHENG Xin 1010121850

In Hard Real-Time Systems

Performance of 2PL for Different Conflict Patterns

Performance of OCC for Different Conflict Patterns

Page 22: A Survey on Optimistic Concurrency Control CAI Yibo 1010087850 ZHENG Xin 1010121850

In Hard Real-Time Systems

Comparison Between OCC and 2PL When B = 10

Comparison Between OCC and 2PL When B = 50

Page 23: A Survey on Optimistic Concurrency Control CAI Yibo 1010087850 ZHENG Xin 1010121850

In Hard Real-Time Systems

• 2PL outperforms OCC– under OCC transactions restarted due to access

conflicts often do not have enough time to complete on time, leading temporally inconsistent data read by other transactions

Page 24: A Survey on Optimistic Concurrency Control CAI Yibo 1010087850 ZHENG Xin 1010121850

In Real-Time Database Systems

• OCC generates higher deadline guarantee ratio than 2PL

• The performance is relative to the tightness of deadline.– While 2PL outperforms OCC when the transaction

deadline is very tight, OCC performs better when the transaction deadline becomes looser.

• OCC outperforms 2PL regarding to total weighted value because of limited blocking value. – OCC is not sensitive to the length of transactions. It

can perform well even for long transactions.

Page 25: A Survey on Optimistic Concurrency Control CAI Yibo 1010087850 ZHENG Xin 1010121850

In Real-Time Database Systems

• OCC outperforms 2PL– deadlock freedom – predictable blocking time

Page 26: A Survey on Optimistic Concurrency Control CAI Yibo 1010087850 ZHENG Xin 1010121850

Conclusion

• OCC– Algorithm– Three phase

• Backward vs. Forward validation

• OCC VS. 2PL– Disadvantage

• large number of transaction restart times– Advantage

• deadlock freedom• predictable blocking time

Page 27: A Survey on Optimistic Concurrency Control CAI Yibo 1010087850 ZHENG Xin 1010121850

Thank You!