SlideShare a Scribd company logo
2
Most read
3
Most read
13
Most read
Concurrency  control
 In a multiprogramming environment where multiple
transactions can be executed simultaneously, it is highly
important to control the concurrency of transactions.
Concurrency control protocols can be broadly divided into two
categories :
A. Lock-based protocols
B. Time-stamp based protocols
Lock-based Protocols :
Database systems equipped with lock-based protocols use a mechanism
by which any transaction cannot read or write data until it acquires an
appropriate lock on it
Data items can be locked in two modes :
a) exclusive (X) mode. Data item can be both read as well as
written. X-lock is requested using lock-X instruction.
b) shared (S) mode. Data item can only be read. S-lock is
requested using lock-S instruction.
 Lock-compatibility matrix
 If a lock cannot be granted, the requesting transaction is made
to wait till all incompatible locks held by other transactions
have been released. The lock is then granted.
 Example of a transaction performing locking:
T2: lock-S(A);
read (A);
unlock(A);
lock-S(B);
read (B);
unlock(B);
display(A+B)
Each transaction is issued a timestamp when it enters the system. If
an old transaction Ti has time-stamp TS(Ti), a new transaction Tj is
assigned time-stamp TS(Tj) such that TS(Ti) <TS(Tj).
 The timestamp of transaction Ti is denoted as TS(Ti).
 Read time-stamp of data-item X is denoted by R-timestamp(X).
 Write time-stamp of data-item X is denoted by W-timestamp(X).
Timestamp ordering protocol works as follows −
 If a transaction Ti issues a read(X) operation −
◦ If TS(Ti) < W-timestamp(X)
 Operation rejected.
◦ If TS(Ti) >= W-timestamp(X)
 Operation executed.
◦ All data-item timestamps updated.
 If a transaction Ti issues a write(X) operation −
◦ If TS(Ti) < R-timestamp(X)
 Operation rejected.
◦ If TS(Ti) < W-timestamp(X)
 Operation rejected and Ti rolled back.
◦ Otherwise, operation executed.
 Optimistic concurrency control (OCC) is a concurrency
control method applied to transactional systems such as
relational database management systems and software
transactional memory.
 OCC assumes that multiple transactions can frequently
complete without interfering with each other.
In this approach, a transaction’s life cycle is divided into the following
three phases −
1. Execution Phase − A transaction fetches data items to memory
and performs operations upon them.
2. Validation Phase − A transaction performs checks to ensure that
committing its changes to the database passes serializability test.
3. Commit Phase − A transaction writes back modified data item in
memory to the disk.
This algorithm uses three rules to enforce serializability in
validation phase −
 Rule 1 − Given two transactions Ti and Tj, if Ti is reading the
data item which Tj is writing, then Ti’s execution phase cannot
overlap with Tj’s commit phase. Tj can commit only after Ti
has finished execution.
 Rule 2 − Given two transactions Ti and Tj, if Ti is writing the
data item that Tj is reading, then Ti’s commit phase cannot
overlap with Tj’s execution phase. Tj can start executing only
after Ti has already committed.
 Rule 3 − Given two transactions Ti and Tj, if Ti is writing the
data item which Tj is also writing, then Ti’s commit phase
cannot overlap with Tj’s commit phase. Tj can start to commit
only after Ti has already committed
 Backward Validation (BV) – check against committed
transactions
 Forward Validation (FV) – check against concurrent
executing transactions
Concurrency  control

More Related Content

PPT
Transactions in dbms
PPT
16. Concurrency Control in DBMS
PPTX
Concurrency Control in Distributed Database.
PPTX
Timestamp based protocol
PDF
Chapter 5 Database Transaction Management
PPTX
VALIDATION BASED PROTOCOL AND MULTIPLE GRANULARITY.pptx
PPTX
Validation based protocol
PPTX
Concurrency control
Transactions in dbms
16. Concurrency Control in DBMS
Concurrency Control in Distributed Database.
Timestamp based protocol
Chapter 5 Database Transaction Management
VALIDATION BASED PROTOCOL AND MULTIPLE GRANULARITY.pptx
Validation based protocol
Concurrency control

What's hot (20)

PPTX
Concurrency control
PPT
Deadlock
PPTX
Distributed concurrency control
PPT
Chapter 12 transactions and concurrency control
PPTX
Concurrency Control in Database Management System
PDF
Serializability
PPTX
File Organization
PPTX
Process synchronization
PPTX
Lock based protocols
PPT
Chapter 11 - File System Implementation
PPTX
deadlock handling
PPTX
DeadLock in Operating-Systems
PPTX
Query processing and optimization (updated)
PPSX
Parallel Database
PPTX
Transaction management DBMS
PPTX
Transaction processing ppt
PPTX
Transaction Management
PPTX
Deadlock ppt
PPTX
Deadlock dbms
PPTX
Database System Architectures
Concurrency control
Deadlock
Distributed concurrency control
Chapter 12 transactions and concurrency control
Concurrency Control in Database Management System
Serializability
File Organization
Process synchronization
Lock based protocols
Chapter 11 - File System Implementation
deadlock handling
DeadLock in Operating-Systems
Query processing and optimization (updated)
Parallel Database
Transaction management DBMS
Transaction processing ppt
Transaction Management
Deadlock ppt
Deadlock dbms
Database System Architectures
Ad

Similar to Concurrency control (20)

PPTX
protocols of concurrency control
PPTX
Chapter_NINE_Concurrency_Control_DBMS.pptx
PPTX
Transaction management transparencies
PPTX
Concurrent control
PPTX
Transaction management
PPTX
Chapter 4-Concrruncy controling techniques.pptx
PPTX
Concurrency Control.pptx
PPTX
Unit 5 dbms
PPTX
Concurrency control!
PPT
Concurrency control ms neeti
PPT
Concurrency control ms neeti
PDF
CONCURRENCY CONTOL notes.pdf
PPTX
Concurrency Control in Distributed Systems.pptx
PPTX
DBMS Pravin concurrency control technique.pptx
PDF
PPT-concurrency Control database management system DBMS concurrent control (U...
PPTX
Overview of Concurrency Control & Recovery in Distributed Databases
PDF
Management of Distributed Transactions
PPTX
Vani dbms
PPTX
DBMS Presentation.pptx
PPTX
UNIT IV DIS.pptx
protocols of concurrency control
Chapter_NINE_Concurrency_Control_DBMS.pptx
Transaction management transparencies
Concurrent control
Transaction management
Chapter 4-Concrruncy controling techniques.pptx
Concurrency Control.pptx
Unit 5 dbms
Concurrency control!
Concurrency control ms neeti
Concurrency control ms neeti
CONCURRENCY CONTOL notes.pdf
Concurrency Control in Distributed Systems.pptx
DBMS Pravin concurrency control technique.pptx
PPT-concurrency Control database management system DBMS concurrent control (U...
Overview of Concurrency Control & Recovery in Distributed Databases
Management of Distributed Transactions
Vani dbms
DBMS Presentation.pptx
UNIT IV DIS.pptx
Ad

Recently uploaded (20)

PDF
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION
PDF
Influence of Green Infrastructure on Residents’ Endorsement of the New Ecolog...
PDF
III.4.1.2_The_Space_Environment.p pdffdf
PDF
Level 2 – IBM Data and AI Fundamentals (1)_v1.1.PDF
PDF
Human-AI Collaboration: Balancing Agentic AI and Autonomy in Hybrid Systems
PDF
R24 SURVEYING LAB MANUAL for civil enggi
PPTX
AUTOMOTIVE ENGINE MANAGEMENT (MECHATRONICS).pptx
PDF
Artificial Superintelligence (ASI) Alliance Vision Paper.pdf
PDF
22EC502-MICROCONTROLLER AND INTERFACING-8051 MICROCONTROLLER.pdf
PPTX
Current and future trends in Computer Vision.pptx
PDF
Soil Improvement Techniques Note - Rabbi
PDF
737-MAX_SRG.pdf student reference guides
PDF
Visual Aids for Exploratory Data Analysis.pdf
PPTX
Artificial Intelligence
PPTX
Information Storage and Retrieval Techniques Unit III
PPTX
Management Information system : MIS-e-Business Systems.pptx
PDF
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
PDF
COURSE DESCRIPTOR OF SURVEYING R24 SYLLABUS
PPTX
Fundamentals of Mechanical Engineering.pptx
PDF
Categorization of Factors Affecting Classification Algorithms Selection
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION
Influence of Green Infrastructure on Residents’ Endorsement of the New Ecolog...
III.4.1.2_The_Space_Environment.p pdffdf
Level 2 – IBM Data and AI Fundamentals (1)_v1.1.PDF
Human-AI Collaboration: Balancing Agentic AI and Autonomy in Hybrid Systems
R24 SURVEYING LAB MANUAL for civil enggi
AUTOMOTIVE ENGINE MANAGEMENT (MECHATRONICS).pptx
Artificial Superintelligence (ASI) Alliance Vision Paper.pdf
22EC502-MICROCONTROLLER AND INTERFACING-8051 MICROCONTROLLER.pdf
Current and future trends in Computer Vision.pptx
Soil Improvement Techniques Note - Rabbi
737-MAX_SRG.pdf student reference guides
Visual Aids for Exploratory Data Analysis.pdf
Artificial Intelligence
Information Storage and Retrieval Techniques Unit III
Management Information system : MIS-e-Business Systems.pptx
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
COURSE DESCRIPTOR OF SURVEYING R24 SYLLABUS
Fundamentals of Mechanical Engineering.pptx
Categorization of Factors Affecting Classification Algorithms Selection

Concurrency control

  • 2.  In a multiprogramming environment where multiple transactions can be executed simultaneously, it is highly important to control the concurrency of transactions.
  • 3. Concurrency control protocols can be broadly divided into two categories : A. Lock-based protocols B. Time-stamp based protocols Lock-based Protocols : Database systems equipped with lock-based protocols use a mechanism by which any transaction cannot read or write data until it acquires an appropriate lock on it
  • 4. Data items can be locked in two modes : a) exclusive (X) mode. Data item can be both read as well as written. X-lock is requested using lock-X instruction. b) shared (S) mode. Data item can only be read. S-lock is requested using lock-S instruction.
  • 5.  Lock-compatibility matrix  If a lock cannot be granted, the requesting transaction is made to wait till all incompatible locks held by other transactions have been released. The lock is then granted.
  • 6.  Example of a transaction performing locking: T2: lock-S(A); read (A); unlock(A); lock-S(B); read (B); unlock(B); display(A+B)
  • 7. Each transaction is issued a timestamp when it enters the system. If an old transaction Ti has time-stamp TS(Ti), a new transaction Tj is assigned time-stamp TS(Tj) such that TS(Ti) <TS(Tj).  The timestamp of transaction Ti is denoted as TS(Ti).  Read time-stamp of data-item X is denoted by R-timestamp(X).  Write time-stamp of data-item X is denoted by W-timestamp(X).
  • 8. Timestamp ordering protocol works as follows −  If a transaction Ti issues a read(X) operation − ◦ If TS(Ti) < W-timestamp(X)  Operation rejected. ◦ If TS(Ti) >= W-timestamp(X)  Operation executed. ◦ All data-item timestamps updated.  If a transaction Ti issues a write(X) operation − ◦ If TS(Ti) < R-timestamp(X)  Operation rejected. ◦ If TS(Ti) < W-timestamp(X)  Operation rejected and Ti rolled back. ◦ Otherwise, operation executed.
  • 9.  Optimistic concurrency control (OCC) is a concurrency control method applied to transactional systems such as relational database management systems and software transactional memory.  OCC assumes that multiple transactions can frequently complete without interfering with each other.
  • 10. In this approach, a transaction’s life cycle is divided into the following three phases − 1. Execution Phase − A transaction fetches data items to memory and performs operations upon them. 2. Validation Phase − A transaction performs checks to ensure that committing its changes to the database passes serializability test. 3. Commit Phase − A transaction writes back modified data item in memory to the disk.
  • 11. This algorithm uses three rules to enforce serializability in validation phase −  Rule 1 − Given two transactions Ti and Tj, if Ti is reading the data item which Tj is writing, then Ti’s execution phase cannot overlap with Tj’s commit phase. Tj can commit only after Ti has finished execution.
  • 12.  Rule 2 − Given two transactions Ti and Tj, if Ti is writing the data item that Tj is reading, then Ti’s commit phase cannot overlap with Tj’s execution phase. Tj can start executing only after Ti has already committed.  Rule 3 − Given two transactions Ti and Tj, if Ti is writing the data item which Tj is also writing, then Ti’s commit phase cannot overlap with Tj’s commit phase. Tj can start to commit only after Ti has already committed
  • 13.  Backward Validation (BV) – check against committed transactions  Forward Validation (FV) – check against concurrent executing transactions