Transaction and concurrency controll

22
TRANSACTION AND CONCURRENCY CONTROLL Chapter 13 “Distributed Systems: Concepts and Design” Coulouris, Dollimore, Kindberg Hanna Björling, Stina Fröjd & Liv Sundman

description

Transaction and concurrency controll. Chapter 13. “Distributed Systems: Concepts and Design” Coulouris , Dollimore , Kindberg. Hanna Björling, Stina Fröjd & Liv Sundman. Transaction. A transaction is a point where there is interaction with the database - PowerPoint PPT Presentation

Transcript of Transaction and concurrency controll

Page 1: Transaction and  concurrency controll

TRANSACTION AND CONCURRENCY CONTROLL

Chapter 13

“Distributed Systems: Concepts and Design”

Coulouris, Dollimore, KindbergHanna Björling,

Stina Fröjd & Liv Sundman

Page 2: Transaction and  concurrency controll

TRANSACTION A transaction is a point where there is

interaction with the database

A transaction is generally atomic

The state of the transaction being done is not visible. If it is not done completely, any changes it made will be undone. This is known as rollback

Page 3: Transaction and  concurrency controll

TRANSACTION It’s common to talk about transactions

in banking systems

Ex: A transfer between accounts. The money should be transferred as well as withdrawn

To make sure both things are done concurrency control is used

Page 4: Transaction and  concurrency controll

CONCURRENCY CONTROL Concurrency – multiple users want to

access the same data at the same time Concurrency control (CC) ensures that

correct results for parallel operations are generated

CC provides rules, methods, design methodologies and theories to maintain the consistency of components operating simultaneously while interacting with the same object

Page 5: Transaction and  concurrency controll

WHY CONCURRENCY CONTROL? Concurrency control is needed because

there are a lot of things that can go wrong

Each transaction itself can be okay, but the concurrency generates problems such as: The lost update problem The dirty read problem The incorrect summary problem

Page 6: Transaction and  concurrency controll

READ AND WRITE CONFLICTS

Figur 13.9

Page 7: Transaction and  concurrency controll

THREE METHODS There are many methods for

concurrency control

The main methods are:LocksOptimistic concurrency controlTimestamp ordering

Page 8: Transaction and  concurrency controll

LOCKS Locks are used to order transactions

that access the same objects according to the order of arrival of their operations at the objects

Mechanism for enforcing limits on access to the object

If the access to the object is locked other users have to wait until it’s unlocked

Page 9: Transaction and  concurrency controll

LOCK COMPABILITY

Figur 13.15

Page 10: Transaction and  concurrency controll

A PROBLEM WITH LOCK The use of locks can lead to deadlocks

Ex: Two transactions are waiting and each is dependent on the other to release a lock so it can resume

B

A

Waits for

Held by

Held by

T UU T

Waits for

Figur 13.20

Page 11: Transaction and  concurrency controll

OPTIMISTIC CONCURRENCY CONTROL Optimistic concurrency control (OCC) is

based on the assumption that two transactions won’t occur at the same time

OCC is generally used in environments with low data contention

Page 12: Transaction and  concurrency controll

OCC PHASES Begin Working phase Validation phase Update phase

Page 13: Transaction and  concurrency controll

OCC PHASES Begin: Record a timestamp marking the

transaction's beginning

Working phase: Read and write database values to a copy of the transaction which is not yet bound to the object. Several different transactions of this type may coexist

Page 14: Transaction and  concurrency controll

OCC PHASES Validate phase:

Controls if the transaction conflicts with another transaction on the same object

Update phase: Committed: If there is no conflict, make all

changes part of the official state of the database

Aborted: If there is a conflict, resolve it, typically by aborting the transaction, although other resolution schemes are possible

Page 15: Transaction and  concurrency controll

TIMESTAMP Whenever a transaction starts, it is

given a timestamp The timestamp tells in which order that

the transactions are supposed to be applied in

The transaction with the earliest timestamp is executed first

Every object in the database has a read timestamp and a write timestamp

Page 16: Transaction and  concurrency controll

MAJOR GOALS Serializability Recoverability Distribution

Page 17: Transaction and  concurrency controll

SERIALIZABILITY The goal with serializability is that the

result of the parallel transactions is the same as if though the transactions were preformed serially

Page 18: Transaction and  concurrency controll

RECOVERABILITY Recoverability means that committed

transactions do not read data written by aborted transactions

Page 19: Transaction and  concurrency controll

DISTRIBUTION Distributed serializability The serializability concept Commitment

Ordering allows to effectively achieve global serializability across multiple Database Systems, that may use different concurrency control mechanisms.

Page 20: Transaction and  concurrency controll

QUESTIONS?

Page 21: Transaction and  concurrency controll

THANK YOU,NU ÄR DET SLUT!

Page 22: Transaction and  concurrency controll