SlideShare a Scribd company logo
By
NeetiArora
Assistant Professor
Advanced Educational Institute
DBMS- Concurrency Control
www.advanced.edu.in
Definition
Concurrency control is a database management system (DBMS)
concept that is used to address conflicts with the simultaneous
accessing or altering of data that can occur with a multi-user
system. It ensures that database transactions are
performed concurrently without violating the data integrity of the
respective databases. Thus concurrency control is an essential
element for correctness in any system where two or more
database transactions, executed with time overlap, can access
the same data.
www.advanced.edu.in
Descriptive Example
To illustrate the concept of concurrency control, consider two travelers who go to
electronic kiosks at the same time to purchase a train ticket to the same destination
on the same train. There's only one seat left in the coach, but without concurrency
control, it's possible that both travelers will end up purchasing a ticket for that one
seat. However, with concurrency control, the database wouldn't allow this to
happen. Both travelers would still be able to access the train seating database, but
concurrency control would preserve data accuracy and allow only one traveler to
purchase the seat.
www.advanced.edu.in
Concurrency Control Protocols can be broadly divided into two
categories −
Lock based protocols
Time stamp based protocols
www.advanced.edu.in
Lock Based Protocol
A lock is nothing but a mechanism that tells the DBMS whether a particular data item is being
used by any transaction for read/write purpose. Since there are two types of operations, i.e.
read and write, whose basic nature are different, the locks for read and write operation may
behave differently.
Read operation performed by different transactions on the same data item. The value of the
data item, if constant, can be read by any number of transactions at any given time. If a
transaction is reading the content of a sharable data item, then any number of other processes
can be allowed to read the content of the same data item.
Write operation is something different. When a transaction writes some value into a data item,
the content of that data item remains in an inconsistent state, starting from the moment when
the writing operation begins up to the moment the writing operation is over.
But if any transaction is writing into a sharable data item, then no other transaction will be
allowed to read or write that same data item.
www.advanced.edu.in
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. Locks are of two kinds −
Binary Locks − A lock on a data item can be in two states; it is either locked or unlocked.
Shared/Exclusive Lock−
Shared Lock: A transaction may acquire shared lock on a data item in order to read its content. The
lock is shared in the sense that any other transaction can acquire the shared lock on that same data
item for reading purpose.
Exclusive Lock: A transaction may acquire exclusive lock on a data item in order to both read/write
into it. The lock is excusive in the sense that no other transaction can acquire any kind of lock (either
shared or exclusive) on that same data item.
www.advanced.edu.in
There are four types of lock protocols available −
Simplistic Lock Protocol
Simplistic lock-based protocols allow transactions to obtain a lock on every object before a 'write'
operation is performed. Transactions may unlock the data item after completing the ‘write’
operation.
Pre-claiming Lock Protocol
Pre-claiming protocols evaluate their operations and create a list of data items on which they need
locks. Before initiating an execution, the transaction requests the system for all the locks it needs
beforehand. If all the locks are granted, the transaction executes and releases all the locks when all
its operations are over. If all the locks are not granted, the transaction rolls back and waits until all
the locks are granted.
www.advanced.edu.in
Two Phase Locking Protocol
The Two Phase Locking Protocol assumes that a transaction can only be in one of two phases.
 Growing Phase: In this phase the transaction can only acquire locks, but cannot release any lock.
The transaction enters the growing phase as soon as it acquires the first lock it wants. From now on it has
no option but to keep acquiring all the locks it would need. It cannot release any lock at this phase even if it
has finished working with a locked data item. Ultimately the transaction reaches a point where all the lock it
may need has been acquired. This point is called Lock Point.
 Shrinking Phase: After Lock Point has been reached, the transaction enters the shrinking phase.
In this phase the transaction can only release locks, but cannot acquire any new lock. The transaction enters
the shrinking phase as soon as it releases the first lock after crossing the Lock Point.
Strict Two-Phase Locking
The first phase of Strict-2PL is same as 2PL. After acquiring all the locks in the first phase, the transaction
continues to execute normally. But in contrast to 2PL, Strict-2PL does not release a lock after using it. Strict-
2PL holds all the locks until the commit point and releases all the locks at a time.
www.advanced.edu.in
Timestamp-based Protocols
A timestamp is a tag that can be attached to any transaction or any data item, which denotes a specific time on
which the transaction or data item had been activated in any way. This protocol uses either system time or logical
counter as a timestamp. Every transaction has a timestamp associated with it, and the ordering is determined by
the age of the transaction.
The timestamp of a data item can be of the following two types:
W-timestamp (Q): This means the latest time when the data item Q has been written into.
R-timestamp (Q): This means the latest time when the data item Q has been read from.
www.advanced.edu.in
How should timestamps be used?
For Read operations: 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.
For Write operations: 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.
www.advanced.edu.in
Thomas’s Write Rule Timestamp Ordering Protocol (TWRTSO Protocol)
When Transaction Ti issues READ Operation :
a) If TS(Ti) < WTS(Q), then
ROLLBACK Ti.
b) Otherwise,allowed to execute READ operation by transaction Ti and
Set RTS(Q) = max(RTS(Q), TS(Ti))
When Transaction Ti issues WRITE Operation :
a) If TS(Ti) < RTS(Q), then
ROLLBACK Ti.
a) If TS(Ti) < WTS(Q), then Ignore WRITE operation by Ti and
Continue the execution of Ti.
c) Otherwise, Allowed to execute the WRITE operation by transaction Ti and
Set WTS(Q) = TS(Ti)
www.advanced.edu.in
Neeti Arora
Assistant Professor
neetiarorapkl@gmail.com
Advanced Educational Institutions,
70 km Milestone,
Delhi-Mathura Road, Distt. Palwal, Haryana-121105
+91–1275–398400, 302222
www.advanced.edu.in
www.advanced.edu.in

More Related Content

What's hot (20)

PPT
Dbms ii mca-ch9-transaction-processing-2013
Prosanta Ghosh
 
PPTX
Advanced DBMS presentation
Hindustan Petroleum
 
PPTX
Transaction and concurrency control
Anil Shrestha
 
PPT
Chapter18
gourab87
 
PPT
Unit06 dbms
arnold 7490
 
PPT
Transaction management
renuka_a
 
PDF
Introduction to database-Transaction Concurrency and Recovery
Ajit Nayak
 
PPT
Concurrent transactions
Sajan Sahu
 
PPT
15. Transactions in DBMS
koolkampus
 
DOCX
Multiversion Concurrency Control Techniques
Raj vardhan
 
PPTX
Transaction states and properties
Chetan Mahawar
 
PPTX
CS 542 -- Concurrency Control, Distributed Commit
J Singh
 
PPT
Transactions (Distributed computing)
Sri Prasanna
 
PPT
Transaction slide
shawon roy
 
PPTX
Transactions
Ketaki_Pattani
 
PPTX
Transaction Management
Visakh V
 
PPTX
Deadlock in database
Tayyab Hussain
 
PPTX
Vani dbms
SangeethaSasi1
 
PPT
Distributed Transaction
Pratik Tambekar
 
PPT
Chapter17
gourab87
 
Dbms ii mca-ch9-transaction-processing-2013
Prosanta Ghosh
 
Advanced DBMS presentation
Hindustan Petroleum
 
Transaction and concurrency control
Anil Shrestha
 
Chapter18
gourab87
 
Unit06 dbms
arnold 7490
 
Transaction management
renuka_a
 
Introduction to database-Transaction Concurrency and Recovery
Ajit Nayak
 
Concurrent transactions
Sajan Sahu
 
15. Transactions in DBMS
koolkampus
 
Multiversion Concurrency Control Techniques
Raj vardhan
 
Transaction states and properties
Chetan Mahawar
 
CS 542 -- Concurrency Control, Distributed Commit
J Singh
 
Transactions (Distributed computing)
Sri Prasanna
 
Transaction slide
shawon roy
 
Transactions
Ketaki_Pattani
 
Transaction Management
Visakh V
 
Deadlock in database
Tayyab Hussain
 
Vani dbms
SangeethaSasi1
 
Distributed Transaction
Pratik Tambekar
 
Chapter17
gourab87
 

Viewers also liked (20)

PPTX
DBMS (Deadlock, deadlock prevention, 2phase locking)
Gaurav Solanki
 
PPT
multi-threading
Ezzat Gul
 
PPTX
System Data Modelling Tools
Liam Dunphy
 
PPT
Two phase commit protocol in dbms
Dilouar Hossain
 
PPTX
Validation based protocol
BBDITM LUCKNOW
 
PPTX
Paging-R.D.Sivakumar
Sivakumar R D .
 
PPTX
Normalization in Database
Afrasiyab Haider
 
PPTX
Normalization in DBMS
Prateek Parimal
 
PPTX
Exception handling in Java
Prasad Sawant
 
PPT
DbMs
amanrock2012
 
PPTX
OSI Model | Computer Science
Transweb Global Inc
 
ODP
Exception Handling In Java
parag
 
PPTX
Normalization
Salman Memon
 
PPT
Database Management Systems (DBMS)
Dimara Hakim
 
PPT
Transaction concurrency control
Anand Grewal
 
PPT
Concurrency control
Virender Kumar
 
PPT
Test Life Cycle
Nilesh Patange
 
PDF
Transaction & Concurrency Control
Ravimuthurajan
 
PPTX
Dbms slides
rahulrathore725
 
PDF
Database design & Normalization (1NF, 2NF, 3NF)
Jargalsaikhan Alyeksandr
 
DBMS (Deadlock, deadlock prevention, 2phase locking)
Gaurav Solanki
 
multi-threading
Ezzat Gul
 
System Data Modelling Tools
Liam Dunphy
 
Two phase commit protocol in dbms
Dilouar Hossain
 
Validation based protocol
BBDITM LUCKNOW
 
Paging-R.D.Sivakumar
Sivakumar R D .
 
Normalization in Database
Afrasiyab Haider
 
Normalization in DBMS
Prateek Parimal
 
Exception handling in Java
Prasad Sawant
 
OSI Model | Computer Science
Transweb Global Inc
 
Exception Handling In Java
parag
 
Normalization
Salman Memon
 
Database Management Systems (DBMS)
Dimara Hakim
 
Transaction concurrency control
Anand Grewal
 
Concurrency control
Virender Kumar
 
Test Life Cycle
Nilesh Patange
 
Transaction & Concurrency Control
Ravimuthurajan
 
Dbms slides
rahulrathore725
 
Database design & Normalization (1NF, 2NF, 3NF)
Jargalsaikhan Alyeksandr
 
Ad

Similar to Concurrency control ms neeti (20)

PPTX
DBMS Pravin concurrency control technique.pptx
PravinBhargav1
 
DOCX
Concurrency Control Techniques
Raj vardhan
 
PPT
concurrency-control
Saranya Natarajan
 
PPTX
Unit 5 dbms
Sweta Singh
 
PDF
Module 5 part-2 concurrency control in dbms
barekaresahana
 
PPTX
Concurrency Control in Databases.Database management systems
ambikavenkatesh2
 
PPTX
DBMS Presentation.pptx
PravinBhargav1
 
PPTX
Transaction management
janani thirupathi
 
PPTX
Overview of Concurrency Control & Recovery in Distributed Databases
Meghaj Mallick
 
PPTX
Chapter 4-Concrruncy controling techniques.pptx
KelemAlebachew
 
PPTX
Concujsjsjejejejejejejerreny control.pptx
sajal16877
 
PPTX
CHapter four database managementm04.pptx
meharikiros2
 
PDF
Concurrency note.pdf
BijayNag1
 
DOCX
Locking base concurrency control
Prakash Poudel
 
PDF
PPT-concurrency Control database management system DBMS concurrent control (U...
PratikshaSatpute8
 
PPTX
Concurrency Control in RDBMS for Students.pptx
emilinshyni2020
 
PDF
Design & Development of an Advanced Database Management System Using Multiver...
IOSR Journals
 
PDF
F017213747
IOSR Journals
 
PDF
F017213747
IOSR Journals
 
PPTX
transaction management-database management system
SheebaS25
 
DBMS Pravin concurrency control technique.pptx
PravinBhargav1
 
Concurrency Control Techniques
Raj vardhan
 
concurrency-control
Saranya Natarajan
 
Unit 5 dbms
Sweta Singh
 
Module 5 part-2 concurrency control in dbms
barekaresahana
 
Concurrency Control in Databases.Database management systems
ambikavenkatesh2
 
DBMS Presentation.pptx
PravinBhargav1
 
Transaction management
janani thirupathi
 
Overview of Concurrency Control & Recovery in Distributed Databases
Meghaj Mallick
 
Chapter 4-Concrruncy controling techniques.pptx
KelemAlebachew
 
Concujsjsjejejejejejejerreny control.pptx
sajal16877
 
CHapter four database managementm04.pptx
meharikiros2
 
Concurrency note.pdf
BijayNag1
 
Locking base concurrency control
Prakash Poudel
 
PPT-concurrency Control database management system DBMS concurrent control (U...
PratikshaSatpute8
 
Concurrency Control in RDBMS for Students.pptx
emilinshyni2020
 
Design & Development of an Advanced Database Management System Using Multiver...
IOSR Journals
 
F017213747
IOSR Journals
 
F017213747
IOSR Journals
 
transaction management-database management system
SheebaS25
 
Ad

Recently uploaded (20)

PDF
REINFORCEMENT LEARNING IN DECISION MAKING SEMINAR REPORT
anushaashraf20
 
PPTX
Water Resources Engineering (CVE 728)--Slide 4.pptx
mohammedado3
 
PDF
A Brief Introduction About Robert Paul Hardee
Robert Paul Hardee
 
PDF
William Stallings - Foundations of Modern Networking_ SDN, NFV, QoE, IoT, and...
lavanya896395
 
PPT
New_school_Engineering_presentation_011707.ppt
VinayKumar304579
 
PDF
Electrical Machines and Their Protection.pdf
Nabajyoti Banik
 
PPTX
Unit_I Functional Units, Instruction Sets.pptx
logaprakash9
 
PDF
methodology-driven-mbse-murphy-july-hsv-huntsville6680038572db67488e78ff00003...
henriqueltorres1
 
PPTX
Final Major project a b c d e f g h i j k l m
bharathpsnab
 
PPTX
MODULE 03 - CLOUD COMPUTING AND SECURITY.pptx
Alvas Institute of Engineering and technology, Moodabidri
 
PPTX
OCS353 DATA SCIENCE FUNDAMENTALS- Unit 1 Introduction to Data Science
A R SIVANESH M.E., (Ph.D)
 
PDF
Data structures notes for unit 2 in computer science.pdf
sshubhamsingh265
 
PPTX
Distribution reservoir and service storage pptx
dhanashree78
 
PDF
Module - 4 Machine Learning -22ISE62.pdf
Dr. Shivashankar
 
PPTX
Introduction to Internal Combustion Engines - Types, Working and Camparison.pptx
UtkarshPatil98
 
PPTX
How Industrial Project Management Differs From Construction.pptx
jamespit799
 
PPTX
darshai cross section and river section analysis
muk7971
 
PPTX
template.pptxr4t5y67yrttttttttttttttttttttttttttttttttttt
SithamparanaathanPir
 
PPTX
fatigue in aircraft structures-221113192308-0ad6dc8c.pptx
aviatecofficial
 
PDF
Water Industry Process Automation & Control Monthly July 2025
Water Industry Process Automation & Control
 
REINFORCEMENT LEARNING IN DECISION MAKING SEMINAR REPORT
anushaashraf20
 
Water Resources Engineering (CVE 728)--Slide 4.pptx
mohammedado3
 
A Brief Introduction About Robert Paul Hardee
Robert Paul Hardee
 
William Stallings - Foundations of Modern Networking_ SDN, NFV, QoE, IoT, and...
lavanya896395
 
New_school_Engineering_presentation_011707.ppt
VinayKumar304579
 
Electrical Machines and Their Protection.pdf
Nabajyoti Banik
 
Unit_I Functional Units, Instruction Sets.pptx
logaprakash9
 
methodology-driven-mbse-murphy-july-hsv-huntsville6680038572db67488e78ff00003...
henriqueltorres1
 
Final Major project a b c d e f g h i j k l m
bharathpsnab
 
MODULE 03 - CLOUD COMPUTING AND SECURITY.pptx
Alvas Institute of Engineering and technology, Moodabidri
 
OCS353 DATA SCIENCE FUNDAMENTALS- Unit 1 Introduction to Data Science
A R SIVANESH M.E., (Ph.D)
 
Data structures notes for unit 2 in computer science.pdf
sshubhamsingh265
 
Distribution reservoir and service storage pptx
dhanashree78
 
Module - 4 Machine Learning -22ISE62.pdf
Dr. Shivashankar
 
Introduction to Internal Combustion Engines - Types, Working and Camparison.pptx
UtkarshPatil98
 
How Industrial Project Management Differs From Construction.pptx
jamespit799
 
darshai cross section and river section analysis
muk7971
 
template.pptxr4t5y67yrttttttttttttttttttttttttttttttttttt
SithamparanaathanPir
 
fatigue in aircraft structures-221113192308-0ad6dc8c.pptx
aviatecofficial
 
Water Industry Process Automation & Control Monthly July 2025
Water Industry Process Automation & Control
 

Concurrency control ms neeti

  • 1. By NeetiArora Assistant Professor Advanced Educational Institute DBMS- Concurrency Control www.advanced.edu.in
  • 2. Definition Concurrency control is a database management system (DBMS) concept that is used to address conflicts with the simultaneous accessing or altering of data that can occur with a multi-user system. It ensures that database transactions are performed concurrently without violating the data integrity of the respective databases. Thus concurrency control is an essential element for correctness in any system where two or more database transactions, executed with time overlap, can access the same data. www.advanced.edu.in
  • 3. Descriptive Example To illustrate the concept of concurrency control, consider two travelers who go to electronic kiosks at the same time to purchase a train ticket to the same destination on the same train. There's only one seat left in the coach, but without concurrency control, it's possible that both travelers will end up purchasing a ticket for that one seat. However, with concurrency control, the database wouldn't allow this to happen. Both travelers would still be able to access the train seating database, but concurrency control would preserve data accuracy and allow only one traveler to purchase the seat. www.advanced.edu.in
  • 4. Concurrency Control Protocols can be broadly divided into two categories − Lock based protocols Time stamp based protocols www.advanced.edu.in
  • 5. Lock Based Protocol A lock is nothing but a mechanism that tells the DBMS whether a particular data item is being used by any transaction for read/write purpose. Since there are two types of operations, i.e. read and write, whose basic nature are different, the locks for read and write operation may behave differently. Read operation performed by different transactions on the same data item. The value of the data item, if constant, can be read by any number of transactions at any given time. If a transaction is reading the content of a sharable data item, then any number of other processes can be allowed to read the content of the same data item. Write operation is something different. When a transaction writes some value into a data item, the content of that data item remains in an inconsistent state, starting from the moment when the writing operation begins up to the moment the writing operation is over. But if any transaction is writing into a sharable data item, then no other transaction will be allowed to read or write that same data item. www.advanced.edu.in
  • 6. 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. Locks are of two kinds − Binary Locks − A lock on a data item can be in two states; it is either locked or unlocked. Shared/Exclusive Lock− Shared Lock: A transaction may acquire shared lock on a data item in order to read its content. The lock is shared in the sense that any other transaction can acquire the shared lock on that same data item for reading purpose. Exclusive Lock: A transaction may acquire exclusive lock on a data item in order to both read/write into it. The lock is excusive in the sense that no other transaction can acquire any kind of lock (either shared or exclusive) on that same data item. www.advanced.edu.in
  • 7. There are four types of lock protocols available − Simplistic Lock Protocol Simplistic lock-based protocols allow transactions to obtain a lock on every object before a 'write' operation is performed. Transactions may unlock the data item after completing the ‘write’ operation. Pre-claiming Lock Protocol Pre-claiming protocols evaluate their operations and create a list of data items on which they need locks. Before initiating an execution, the transaction requests the system for all the locks it needs beforehand. If all the locks are granted, the transaction executes and releases all the locks when all its operations are over. If all the locks are not granted, the transaction rolls back and waits until all the locks are granted. www.advanced.edu.in
  • 8. Two Phase Locking Protocol The Two Phase Locking Protocol assumes that a transaction can only be in one of two phases.  Growing Phase: In this phase the transaction can only acquire locks, but cannot release any lock. The transaction enters the growing phase as soon as it acquires the first lock it wants. From now on it has no option but to keep acquiring all the locks it would need. It cannot release any lock at this phase even if it has finished working with a locked data item. Ultimately the transaction reaches a point where all the lock it may need has been acquired. This point is called Lock Point.  Shrinking Phase: After Lock Point has been reached, the transaction enters the shrinking phase. In this phase the transaction can only release locks, but cannot acquire any new lock. The transaction enters the shrinking phase as soon as it releases the first lock after crossing the Lock Point. Strict Two-Phase Locking The first phase of Strict-2PL is same as 2PL. After acquiring all the locks in the first phase, the transaction continues to execute normally. But in contrast to 2PL, Strict-2PL does not release a lock after using it. Strict- 2PL holds all the locks until the commit point and releases all the locks at a time. www.advanced.edu.in
  • 9. Timestamp-based Protocols A timestamp is a tag that can be attached to any transaction or any data item, which denotes a specific time on which the transaction or data item had been activated in any way. This protocol uses either system time or logical counter as a timestamp. Every transaction has a timestamp associated with it, and the ordering is determined by the age of the transaction. The timestamp of a data item can be of the following two types: W-timestamp (Q): This means the latest time when the data item Q has been written into. R-timestamp (Q): This means the latest time when the data item Q has been read from. www.advanced.edu.in
  • 10. How should timestamps be used? For Read operations: 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. For Write operations: 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. www.advanced.edu.in
  • 11. Thomas’s Write Rule Timestamp Ordering Protocol (TWRTSO Protocol) When Transaction Ti issues READ Operation : a) If TS(Ti) < WTS(Q), then ROLLBACK Ti. b) Otherwise,allowed to execute READ operation by transaction Ti and Set RTS(Q) = max(RTS(Q), TS(Ti)) When Transaction Ti issues WRITE Operation : a) If TS(Ti) < RTS(Q), then ROLLBACK Ti. a) If TS(Ti) < WTS(Q), then Ignore WRITE operation by Ti and Continue the execution of Ti. c) Otherwise, Allowed to execute the WRITE operation by transaction Ti and Set WTS(Q) = TS(Ti) www.advanced.edu.in
  • 12. Neeti Arora Assistant Professor [email protected] Advanced Educational Institutions, 70 km Milestone, Delhi-Mathura Road, Distt. Palwal, Haryana-121105 +91–1275–398400, 302222 www.advanced.edu.in www.advanced.edu.in