chapter 6. concurrency control databases and applications with relaxed acid properties
TRANSCRIPT
Chapter 6. Concurrency control
Databases and Applications with Relaxed ACID Properties
•
Evaluation criteria
Pessimistic concurrency control
Optimistic concurrency control
Low isolation levels
Short duration locks
Concurrency Allows concurrency except when conflicting locks occur
Allows concur-rency except for conflicting transactions
Concurrency is improved at the costs of “non-lost-update” anomalies
Concurrency is improved at the costs of all types of isolation anomalies
Deadlock When deadlock occurs one of the transactions must be aborted
Eliminates deadlock, but one of the transactions must be aborted in case of a conflict
Can eliminate deadlocks caused by read-write conflicts
Can reduce/eliminate dead-locks caused by both read-write and write-write conflicts
Hotspots Pessimistic con-currency is generally better than optimistic concurrency control in hotspots
Pessimistic con-currency is generally better than optimistic concurrency control in hotspots
Can eliminate read-write conflicts in hotspots
Can reduce both read-write and write-write conflicts in hotspots
The atomicity property
No problems No problems No problems Extended transaction models should be used
The consistency property
No problems No problems Countermeasures may be used to manage isolation anomalies
Asymptotic consistency should normally be used
The Isolation property
No problems except for long-duration transactions
No problems except for long-duration transactions
Countermeasures may be used to manage isolation anomalies
Countermeasures should always be used to manage isolation anomalies
The durability property
No problems No problems No problems No problems if the atomicity property is implemented
Distributionoptions
Distributed con-currency control will decrease performance and availability
Distributed con-currency control will decrease performance and availability
May be implemented in a distributed DBMS without further problems
Retriable subtrans-actions may be necessary to implement the atomicity property
Development costs
A DBMS facility A DBMS facility Extra costs for countermeasures against isolation anomalies
Extra development costs for relaxed ACID properties
Often Deadlock prevention is impossible:
Example:In e-commerce products may be put in the basket in any order.
•
Pessimistic concurrency control:
• Locking is a pessimistic concurrency control, because access for a new transaction to data is blocked if there is a chance for conflict with old accesses. Therefore, there are no conflicts when a transaction is committed.
(What is a conflict between transactions?)
On the other hand, transactions may have waited for non existing conflicts or expierensed deadlock.
•
What is read-write conflicts? What is write-write conflicts?
Optimistic concurrency control
• Concurrency control is optimistic if access to committed data always is allowed. Therefore, there are no access to updated data before it is committed.
• A transaction can only commit if it has no conflicts at the time of commit.(Backward validation).
•
The anomalies of SQL’s isolation levels
SQL isolation levels
Isolation anomalies
Dirty read Nonrepeatable read
Phantoms
READ UNCOMMITTED
Yes Yes Yes
READ COMMITTED No Yes Yes
REPEATABLE READ
No No Yes
SERIALIZABLE No No No
Different lock durations:
• Long duration locks = All locks are obtain before global commit and released after global commit
• Short duration locks = All locks are obtained and released in local transactions executed both before and after global commit.
Short duration locks does not lock data accross a dialog with the user or when there is a risk for deadlock.
Long-lived transactions
Long-lived transactions are transactions where only short duration locking are acceptable.
– workflows are normally long-lived– in cooperative work there is a need for user notification
which is a countermeasure to prevent anomalies.– applications such as cooperative CAD need user
involvement in conflict resolution
•
Hotspots:
A hotspot is a record normally updated by many concurrent transactions. In hotspots, pessimistic concurrency control is generally better than optimistic concurrency control (O’Neil, 1986).
However, a hotspot is best managed by using short duration locking around the hotspot.
Examples:
– In e-commerce best-seller products may be hot spots– The generator of transaction sequense numbers.
Methods to increase concurrency
Evaluation criteria
Pessimistic concurrency control
Optimistic concurrency control
Low isolation levels
Short duration locks
Concur-rency
Allows concurrency except when conflicting locks occurs
Allows concurrency except for conflicting transactions
Concurrency is improved at the costs of “non-lost-update” anomalies
Concurrency is improved at the costs of all types of isolation anomalies
Deadlock When deadlock occurs one of the transactions must be aborted
Eliminates deadlock, but one of the transactions must be aborted in case of a conflict
Can eliminate deadlocks caused by read-write conflicts
Can reduce/eliminate dead-locks caused by both read-write and write-write conflicts
Hotspots Pessimistic concurrency is generally better than optimistic concurrency control in hotspots
Pessimistic concurrency is generally better than optimistic concurrency control in hotspots
Can eliminate read-write conflicts in hotspots
Can reduce/eliminate both read-write and write-write conflictsin hotspots
Evaluation criteria
Pessimistic concurrency control
Optimistic concurrency control
Low isolation levels
Short duration locks
The atomicity property
No problems No problems No problems Extended transaction models should be used
The consis-tency property
No problems No problems Countermea-sures may be used to manage isolation anomalies
Asymptotic consistency should normally be used
The Isolation property
No problems except for long-duration transactions
No problems except for long-duration transactions
Countermeasures may be used to manage isolation anomalies
Countermeasu-res should always be used to manage isolation anomalies
Evalua-tion criteria
Pessimistic concurrency control
Optimistic concurrency control
Low isolation levels
Short duration locks
The du-rability pro-perty
No problems No problems No problems No problems if the atomicity property is implemented
Distri-butionoptions
Distributed con-currency control will decrease performance and availability
Distributed con-currency control will decrease performance and availability
May be implemented in a distributed DBMS without further problems
Retriable subtrans-actions may be necessary to implement the atomicity property
Deve-lopment costs
A DBMS facility A DBMS facility Extra costs for countermeasures against isolation anomalies
Extra development costs for relaxed ACID properties
ERP system:
Customers Orders Products Orderlines
Product-stocks Locations
Exercise
What concurrency control method would you recommend in e-commerce systems?
End of session
Thank you !!!Thank you !!!
Evaluering af concurrency control metoderne:
Design af DBMS/transaktioner så en rette information haves
til rette tid
til rette person/system
på rette sted
i rette kvalitet (consistency)
til de mindste omkostninger.
Short duration locking:
Ved kort låsning låses der ikke på tværs af en brugerdialog/subtransaktioner samt ved risiko for deadlock og andre problemer, som gør låsetiden uforudsigelig.
I denne situation må man bruge modforholdsregler mod de mulige anomalies samt kompensering på tværs af opdaterende subtransaktioner i stedet for roll back retablering.
Eksempler: E-handel samt lagerstyring generelt.