Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 6. Concurrency control Databases and Applications with Relaxed ACID Properties.

Similar presentations


Presentation on theme: "Chapter 6. Concurrency control Databases and Applications with Relaxed ACID Properties."— Presentation transcript:

1 Chapter 6. Concurrency control Databases and Applications with Relaxed ACID Properties

2 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 Can eliminate read-write conflicts in hotspots Can reduce both read-write and write-write conflicts in hotspots The atomicity property No problems Extended transaction models should be used The consistency property 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 Countermeasures may be used to manage isolation anomalies Countermeasures should always be used to manage isolation anomalies The durability property No problems No problems if the atomicity property is implemented Distribution options 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 Extra costs for countermeasures against isolation anomalies Extra development costs for relaxed ACID properties

3 Often Deadlock prevention is impossible: Example: In e-commerce products may be put in the basket in any order.

4 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.

5 What is read-write conflicts? What is write-write conflicts?

6 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).

7 The anomalies of SQL’s isolation levels SQL isolation levels Isolation anomalies Dirty readNonrepeatable read Phantoms READ UNCOMMITTED Yes READ COMMITTEDNoYes REPEATABLE READNo Yes SERIALIZABLENo

8 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.

9 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

10 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.

11 Methods to increase concurrency Evaluation criteria Pessimistic concurrency control Optimistic concurrency control Low isolation levels Short duration locks Concur-rencyAllows 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 DeadlockWhen 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 HotspotsPessimistic 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 conflicts in hotspots

12 Evaluation criteria Pessimistic concurrency control Optimistic concurrency control Low isolation levels Short duration locks The atomicity property No problems Extended transaction models should be used The consis- tency property 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 Countermeasur es may be used to manage isolation anomalies Countermeasu- res should always be used to manage isolation anomalies

13 Evalua- tion criteria Pessimistic concurrency control Optimistic concurrency control Low isolation levels Short duration locks The du- rability pro- perty No problems No problems if the atomicity property is implemented Distri- bution options 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 Extra costs for countermeasures against isolation anomalies Extra development costs for relaxed ACID properties

14 ERP system: Exercise What concurrency control method would you recommend in e- commerce systems?

15 End of session Thank you !!!

16 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.

17 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.


Download ppt "Chapter 6. Concurrency control Databases and Applications with Relaxed ACID Properties."

Similar presentations


Ads by Google