180 likes | 355 Views
Chapter 6. Concurrency control. Databases and Applications with 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:.
E N D
Chapter 6. Concurrency control Databases and Applications with 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). •
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.
ERP system: Exercise What concurrency control method would you recommend in e-commerce systems?
End of session 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.