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)

PDF
Advanced Database Chapter 4.pdf shnsbxlajmndm woweosmkl m,xcnkl C NOOxcx xcbnxc
alemunuruhak9
 
PDF
Concurrency note.pdf
BijayNag1
 
PPTX
Concurrency control PPT
ShushrutGupta
 
PPTX
Concurrency Control in Distributed Database.
Meghaj Mallick
 
DOCX
Dbms voc 5 unit
gurjotkawatra
 
PDF
Design & Development of an Advanced Database Management System Using Multiver...
IOSR Journals
 
PDF
F017213747
IOSR Journals
 
PDF
F017213747
IOSR Journals
 
PPTX
Transaction management
janani thirupathi
 
PDF
Unit 5 rdbms study_material
gayaramesh
 
PPTX
Concurrent control
Felix Makundi
 
PDF
Mba ebooks ! Edhole
Edhole.com
 
PPTX
DBMS Presentation.pptx
PravinBhargav1
 
PPTX
Overview of Concurrency Control & Recovery in Distributed Databases
Meghaj Mallick
 
PPTX
DBMS Pravin concurrency control technique.pptx
PravinBhargav1
 
PPTX
Transaction management
ArchanaMani2
 
PPTX
Concurrency Control
Nishant Munjal
 
PPT
concurrency control.ppt
BikalAdhikari4
 
PPTX
Concurrency control
Javed Khan
 
Advanced Database Chapter 4.pdf shnsbxlajmndm woweosmkl m,xcnkl C NOOxcx xcbnxc
alemunuruhak9
 
Concurrency note.pdf
BijayNag1
 
Concurrency control PPT
ShushrutGupta
 
Concurrency Control in Distributed Database.
Meghaj Mallick
 
Dbms voc 5 unit
gurjotkawatra
 
Design & Development of an Advanced Database Management System Using Multiver...
IOSR Journals
 
F017213747
IOSR Journals
 
F017213747
IOSR Journals
 
Transaction management
janani thirupathi
 
Unit 5 rdbms study_material
gayaramesh
 
Concurrent control
Felix Makundi
 
Mba ebooks ! Edhole
Edhole.com
 
DBMS Presentation.pptx
PravinBhargav1
 
Overview of Concurrency Control & Recovery in Distributed Databases
Meghaj Mallick
 
DBMS Pravin concurrency control technique.pptx
PravinBhargav1
 
Transaction management
ArchanaMani2
 
Concurrency Control
Nishant Munjal
 
concurrency control.ppt
BikalAdhikari4
 
Concurrency control
Javed Khan
 
Ad

Recently uploaded (20)

PPTX
Break Statement in Programming with 6 Real Examples
manojpoojary2004
 
PPTX
The Role of Information Technology in Environmental Protectio....pptx
nallamillisriram
 
PPTX
Day2 B2 Best.pptx
helenjenefa1
 
PDF
Statistical Data Analysis Using SPSS Software
shrikrishna kesharwani
 
PPTX
Solar Thermal Energy System Seminar.pptx
Gpc Purapuza
 
PDF
UNIT-4-FEEDBACK AMPLIFIERS AND OSCILLATORS (1).pdf
Sridhar191373
 
DOCX
8th International Conference on Electrical Engineering (ELEN 2025)
elelijjournal653
 
PDF
Water Design_Manual_2005. KENYA FOR WASTER SUPPLY AND SEWERAGE
DancanNgutuku
 
PDF
Unified_Cloud_Comm_Presentation anil singh ppt
anilsingh298751
 
PPTX
Heart Bleed Bug - A case study (Course: Cryptography and Network Security)
Adri Jovin
 
PPTX
Green Building & Energy Conservation ppt
Sagar Sarangi
 
PPTX
site survey architecture student B.arch.
sri02032006
 
PDF
ARC--BUILDING-UTILITIES-2-PART-2 (1).pdf
IzzyBaniquedBusto
 
PPTX
Arduino Based Gas Leakage Detector Project
CircuitDigest
 
PPTX
REINFORCEMENT AS CONSTRUCTION MATERIALS.pptx
mohaiminulhaquesami
 
PPTX
ISO/IEC JTC 1/WG 9 (MAR) Convenor Report
Kurata Takeshi
 
PPTX
Server Side Web Development Unit 1 of Nodejs.pptx
sneha852132
 
PDF
IoT - Unit 2 (Internet of Things-Concepts) - PPT.pdf
dipakraut82
 
PDF
POWER PLANT ENGINEERING (R17A0326).pdf..
haneefachosa123
 
PDF
MAD Unit - 1 Introduction of Android IT Department
JappanMavani
 
Break Statement in Programming with 6 Real Examples
manojpoojary2004
 
The Role of Information Technology in Environmental Protectio....pptx
nallamillisriram
 
Day2 B2 Best.pptx
helenjenefa1
 
Statistical Data Analysis Using SPSS Software
shrikrishna kesharwani
 
Solar Thermal Energy System Seminar.pptx
Gpc Purapuza
 
UNIT-4-FEEDBACK AMPLIFIERS AND OSCILLATORS (1).pdf
Sridhar191373
 
8th International Conference on Electrical Engineering (ELEN 2025)
elelijjournal653
 
Water Design_Manual_2005. KENYA FOR WASTER SUPPLY AND SEWERAGE
DancanNgutuku
 
Unified_Cloud_Comm_Presentation anil singh ppt
anilsingh298751
 
Heart Bleed Bug - A case study (Course: Cryptography and Network Security)
Adri Jovin
 
Green Building & Energy Conservation ppt
Sagar Sarangi
 
site survey architecture student B.arch.
sri02032006
 
ARC--BUILDING-UTILITIES-2-PART-2 (1).pdf
IzzyBaniquedBusto
 
Arduino Based Gas Leakage Detector Project
CircuitDigest
 
REINFORCEMENT AS CONSTRUCTION MATERIALS.pptx
mohaiminulhaquesami
 
ISO/IEC JTC 1/WG 9 (MAR) Convenor Report
Kurata Takeshi
 
Server Side Web Development Unit 1 of Nodejs.pptx
sneha852132
 
IoT - Unit 2 (Internet of Things-Concepts) - PPT.pdf
dipakraut82
 
POWER PLANT ENGINEERING (R17A0326).pdf..
haneefachosa123
 
MAD Unit - 1 Introduction of Android IT Department
JappanMavani
 

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