chapter 6. concurrency control databases and applications with relaxed acid properties

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

Upload: jessica-morrison

Post on 31-Dec-2015

218 views

Category:

Documents


1 download

TRANSCRIPT

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

Chapter 6. Concurrency control

Databases and Applications with Relaxed ACID Properties

Page 2: 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

Page 3: 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.

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

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.

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

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

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

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

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

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

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

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.

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

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

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

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.

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

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

Page 12: 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

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

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

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

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

ERP system:

Customers Orders Products Orderlines

Product-stocks Locations

Exercise

What concurrency control method would you recommend in e-commerce systems?

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

End of session

Thank you !!!Thank you !!!

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

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.

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

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.