SlideShare a Scribd company logo
Concurrency Control
Concurrency Control
• Concurrency control mechanism is responsible
for maintaining the database consistency in
case of concurrent execution.
• Following are the most common concurrency
control protocols:
– Lock based protocol
– Graph Based protocol
– Time stamp based protocol
– Validation based protocol
Lock-Based Protocols
• Inconsistency occurs when two transactions
attempt to modify the same data item at the same
time.
• A general solution to this problem is that, if one
transaction is accessing a data item then, no other
transaction should be allowed to modify that data
item.
• Locks are used to implement this general solution.
• Lock- is a variable associated with each data item
that describes the status of the item with respect
to possible operations that can be applied to it.
Locks
• There are two types of locks:
– Binary locks
– Shared/Exclusive locks
• A binary lock can have two states-locked and
unlocked.
• The function lock(X) tells that whether data item
X is locked or not at a given time.
• If lock(X)=1 then, X is locked and if lock(X)=0 then,
X is not locked.
• A transaction can request and release a lock on
data item X by using following two instructions:
– Lock_item(X)
– unlock_item(X)
Locks
• Main drawback of binary lock is that at a given
point of time, at most one transaction can
hold a lock on data item X. But, in database
system it should be allowed that multiple
transactions may access a data item only for
reading.
• To overcome this problem, we use
shared/exclusive lock.
Locks
Locks
Compatibility Function
• Compatibility function can be defined as:
– Let M and N be two lock modes. Now suppose that a
transaction Ti requests a lock of mode M on data item
A on which transaction Tj currently holds a lock of
mode N. If transaction Ti can be granted a lock on A
immediately inspite of presence of lock of mode N,
then mode M is said to be compatible with mode N.
Pitfalls of Lock-Based Protocols
Pitfalls of Lock-Based Protocols
• Starvation is also possible if concurrency control
manager is badly designed. For example: A
transaction may be waiting for an X-lock on an item,
while a sequence of other transactions request and
are granted an S-lock on the same item.
• The same transaction is repeatedly rolled back due
to deadlocks.
• Concurrency control manager can be designed to
prevent starvation.
Lock-Based Protocols
• A locking protocol is a set of rules followed by all
transactions while requesting and releasing locks.
Locking protocols restrict the set of possible
schedules.
• Two types of lock based protocol is:
– Two-phase locking protocol
• Protocol which is not two phase:
– Graph based protocol
The Two-Phase Locking Protocol
The Two-Phase Locking Protocol
• Cascading rollback may occur in Two phase locking so
in order to avoid it three variations on two phase
locking is used:
– Strict two-phase locking : Here a transaction must hold all
its exclusive locks till it commits/aborts.
– Rigorous two-phase locking : is even stricter: here all locks
are held till commit/abort. In this protocol transactions can
be serialized in the order in which they commit.
– Two phase locking with Lock Conversion: This protocol
adds the ability of lock conversion to the basic two phase
locking. i.e we can convert a shared lock to an exclusive
lock and vice versa. The Upgrade(A) instruction is used to
convert a shared lock to an exclusive lock. The
Downgrade(A) instruction is used to convert an exclusive
lock shared lock.
Graph Based Protocol
• Graph-based protocols are an alternative to two-
phase locking
• This protocol requires prior knowledge about the
order in which database items will be accessed
• To acquire such prior knowledge, we impose a partial
ordering→ on the set D = {d1, d2 ,..., dh} of all data
items.
– If di → dj then any transaction accessing both di
and dj must access di before accessing dj.
Graph Based Protocol
• A tree or a graph protocol only exclusive locks are
allowed. Each transaction Ti can lock data item
only once, and must observe the following rules:
1. The first lock by Ti may be on any data item.
2. Subsequently, a data Q can be locked by Ti only
if the parent of Q is currently locked by Ti.
3. Data items may be unlocked at any time.
4. A data item that has been locked and unlocked
by Ti cannot subsequently be relocked by Ti
Graph Based Protocol: Example
Graph Based Protocol
• Advantages:
– The tree protocol ensures conflict serializability as
well as freedom from deadlock.
– Unlocking may occur earlier in the tree-locking
protocol than in the two-phase locking protocol.
• shorter waiting times, and increase in concurrency
• protocol is deadlock-free, no rollbacks are required
• Disadvantages:
– Transactions may have to lock data items that it
does not access.
• increased locking overhead, and additional waiting time
• potential decrease in concurrency
Time Stamp Based Protocol
• 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 protocol manages concurrent execution such that
the time-stamps determine the serializability order.
• In order to assure such behavior, the protocol
maintains for each data Q two timestamp values:
– W-timestamp(Q) is the largest time-stamp of any
transaction that executed write(Q) successfully.
– R-timestamp(Q) is the largest time-stamp of any
transaction that executed read(Q) successfully.
Time Stamp Based Protocol
– Use the value of the system clock as the
timestamp; that is, a transaction’s timestamp is
equal to the value of the clock when the
transaction enters the system.
– Use a logical counter that is incremented after a
new timestamp has been assigned; that is, a
transaction’s timestamp is equal to the value of
the counter when the transaction enters the
system.
Time Stamp Based Protocol
• The timestamp ordering protocol ensures that
any conflicting read and write operations are
executed in timestamp order.
• Suppose a transaction Ti issues a read(Q)
– If TS(Ti) ≤ W-timestamp(Q), then Ti needs to read a
value of Q that was already overwritten. Hence, the
read operation is rejected, and Ti is rolled back.
– If TS(Ti)≥ W-timestamp(Q), then the read operation is
executed, and R-timestamp(Q) is set to max(R-
timestamp(Q), TS(Ti)).
Time Stamp Based Protocol
• Suppose that transaction Ti issues write(Q).
– If TS(Ti) < R-timestamp(Q), then the value of Q that Ti is
producing was needed previously, and the system
assumed that that value would never be produced. Hence,
the write operation is rejected, and Ti is rolled back.
– If TS(Ti) < W-timestamp(Q), then Ti is attempting to write
an obsolete value of Q. Hence, this write operation is
rejected, and Ti is rolled back.
• Otherwise, the write operation is executed, and W-
timestamp(Q) is set to TS(Ti).
Time Stamp Based Protocol: Example
• To illustrate this protocol, we consider
transactions T1 and T2. Transaction T1 displays the
contents of accounts A and B:
– T1:
read(B);
read(A);
display(A + B);
– T2:
read(B);
B := B − 50;
write(B);
read(A);
A := A + 50;
write(A);
display(A + B);
Time Stamp Based Protocol
• In presenting schedules under the timestamp protocol, we
shall assume that a transaction is assigned a timestamp
immediately before its first instruction. Thus, in schedule 3,
TS(T1) < TS(T2), and the schedule is possible under the
timestamp protocol.
• Schedule 3
Thomas Write Rule
• Modified version of the timestamp-ordering protocol in
which obsolete write operations may be ignored under
certain circumstances.
• When Ti attempts to write data item Q, if TS(Ti) < W-
timestamp(Q), then Ti is attempting to write an
obsolete value of {Q}.
– Rather than rolling back Ti as the timestamp ordering
protocol would have done, this {write} operation can be
ignored.
• Otherwise this protocol is the same as the timestamp
ordering protocol.
• Thomas' Write Rule allows greater potential
concurrency.
– Allows some view-serializable schedules that are not
conflict-serializable.
Validation Based Protocol
• We assume that each transaction Ti executes
in two or three different phases in its lifetime,
depending on whether it is a read-only or an
update transaction. The phases are, in order,
– Read phase. During this phase, the system
executes transaction Ti. It reads the values of the
various data items and stores them in variables
local to Ti. It performs all write operations on
temporary local variables, without updates of the
actual database.
Validation Based Protocol
– Validation phase. Transaction Ti performs a
validation test to determine whether it can copy
to the database the temporary local variables that
hold the results of write operations without
causing a violation of serializability.
– Write phase. If transaction Ti succeeds in
validation (step 2), then the system applies the
actual updates to the database. Otherwise, the
system rolls back Ti.
Validation Based Protocol
• Each transaction Ti has 3 timestamps
– Start(Ti) : the time when Ti started its execution
– Validation(Ti): the time when Ti entered its
validation phase
– Finish(Ti) : the time when Ti finished its write
phase

More Related Content

What's hot

Concurrency control
Concurrency controlConcurrency control
Concurrency control
Subhasish Pati
 
Transaction
TransactionTransaction
Transaction
Amin Omi
 
2 phase locking protocol DBMS
2 phase locking protocol DBMS2 phase locking protocol DBMS
2 phase locking protocol DBMS
Dhananjaysinh Jhala
 
Concurrency Control in Distributed Database.
Concurrency Control in Distributed Database.Concurrency Control in Distributed Database.
Concurrency Control in Distributed Database.
Meghaj Mallick
 
Concurrency Control Techniques
Concurrency Control TechniquesConcurrency Control Techniques
Concurrency Control Techniques
Raj vardhan
 
Deadlock management
Deadlock managementDeadlock management
Deadlock management
Ahmed kasim
 
Distributed database management system
Distributed database management  systemDistributed database management  system
Distributed database management system
Pooja Dixit
 
protocols of concurrency control
protocols of concurrency controlprotocols of concurrency control
protocols of concurrency control
MOHIT DADU
 
Overview of Concurrency Control & Recovery in Distributed Databases
Overview of Concurrency Control & Recovery in Distributed DatabasesOverview of Concurrency Control & Recovery in Distributed Databases
Overview of Concurrency Control & Recovery in Distributed Databases
Meghaj Mallick
 
Concurrency Conrol
Concurrency ConrolConcurrency Conrol
Concurrency Conrol
lubna19
 
Concurrency control!
Concurrency control!Concurrency control!
Concurrency control!
Ashish K
 
Chapter18
Chapter18Chapter18
Chapter18
gourab87
 
12. Indexing and Hashing in DBMS
12. Indexing and Hashing in DBMS12. Indexing and Hashing in DBMS
12. Indexing and Hashing in DBMSkoolkampus
 
Concurrency control
Concurrency controlConcurrency control
Concurrency control
varsha singh
 
database recovery techniques
database recovery techniques database recovery techniques
database recovery techniques Kalhan Liyanage
 
Two phase commit protocol in dbms
Two phase commit protocol in dbmsTwo phase commit protocol in dbms
Two phase commit protocol in dbms
Dilouar Hossain
 
Deadlock dbms
Deadlock dbmsDeadlock dbms
Deadlock dbms
Vardhil Patel
 
deadlock handling
deadlock handlingdeadlock handling
deadlock handling
Suraj Kumar
 
management of distributed transactions
management of distributed transactionsmanagement of distributed transactions
management of distributed transactionsNilu Desai
 
concurrency-control
concurrency-controlconcurrency-control
concurrency-control
Saranya Natarajan
 

What's hot (20)

Concurrency control
Concurrency controlConcurrency control
Concurrency control
 
Transaction
TransactionTransaction
Transaction
 
2 phase locking protocol DBMS
2 phase locking protocol DBMS2 phase locking protocol DBMS
2 phase locking protocol DBMS
 
Concurrency Control in Distributed Database.
Concurrency Control in Distributed Database.Concurrency Control in Distributed Database.
Concurrency Control in Distributed Database.
 
Concurrency Control Techniques
Concurrency Control TechniquesConcurrency Control Techniques
Concurrency Control Techniques
 
Deadlock management
Deadlock managementDeadlock management
Deadlock management
 
Distributed database management system
Distributed database management  systemDistributed database management  system
Distributed database management system
 
protocols of concurrency control
protocols of concurrency controlprotocols of concurrency control
protocols of concurrency control
 
Overview of Concurrency Control & Recovery in Distributed Databases
Overview of Concurrency Control & Recovery in Distributed DatabasesOverview of Concurrency Control & Recovery in Distributed Databases
Overview of Concurrency Control & Recovery in Distributed Databases
 
Concurrency Conrol
Concurrency ConrolConcurrency Conrol
Concurrency Conrol
 
Concurrency control!
Concurrency control!Concurrency control!
Concurrency control!
 
Chapter18
Chapter18Chapter18
Chapter18
 
12. Indexing and Hashing in DBMS
12. Indexing and Hashing in DBMS12. Indexing and Hashing in DBMS
12. Indexing and Hashing in DBMS
 
Concurrency control
Concurrency controlConcurrency control
Concurrency control
 
database recovery techniques
database recovery techniques database recovery techniques
database recovery techniques
 
Two phase commit protocol in dbms
Two phase commit protocol in dbmsTwo phase commit protocol in dbms
Two phase commit protocol in dbms
 
Deadlock dbms
Deadlock dbmsDeadlock dbms
Deadlock dbms
 
deadlock handling
deadlock handlingdeadlock handling
deadlock handling
 
management of distributed transactions
management of distributed transactionsmanagement of distributed transactions
management of distributed transactions
 
concurrency-control
concurrency-controlconcurrency-control
concurrency-control
 

Similar to Concurrency control

concurrencycontrol from power pint pdf a
concurrencycontrol  from power pint pdf aconcurrencycontrol  from power pint pdf a
concurrencycontrol from power pint pdf a
MdAyanParwez
 
Concurrency control
Concurrency control Concurrency control
Concurrency control
Abdelrahman Almassry
 
Unit 4 Concurrency control.pptx dbms lovely
Unit 4 Concurrency control.pptx dbms lovelyUnit 4 Concurrency control.pptx dbms lovely
Unit 4 Concurrency control.pptx dbms lovely
PritishMajumdar3
 
Unit 4 Concurrency control.pptx dbms lovely
Unit 4 Concurrency control.pptx dbms lovelyUnit 4 Concurrency control.pptx dbms lovely
Unit 4 Concurrency control.pptx dbms lovely
PritishMajumdar3
 
Concurrency control
Concurrency controlConcurrency control
Concurrency control
Jaya Jeswani
 
Concurrency Control.pptx
Concurrency Control.pptxConcurrency Control.pptx
Concurrency Control.pptx
VijaySourtha
 
DBMS Presentation.pptx
DBMS Presentation.pptxDBMS Presentation.pptx
DBMS Presentation.pptx
PravinBhargav1
 
Unit 5 dbms
Unit 5 dbmsUnit 5 dbms
Unit 5 dbms
Sweta Singh
 
Concurrency Control
Concurrency ControlConcurrency Control
Concurrency Control
Nishant Munjal
 
Concurrency control PPT
Concurrency control PPTConcurrency control PPT
Concurrency control PPT
ShushrutGupta
 
Concurrency note.pdf
Concurrency note.pdfConcurrency note.pdf
Concurrency note.pdf
BijayNag1
 
Unit 5 rdbms study_material
Unit 5  rdbms study_materialUnit 5  rdbms study_material
Unit 5 rdbms study_material
gayaramesh
 
UNIT II.pptx
UNIT II.pptxUNIT II.pptx
UNIT II.pptx
ssuserec53e73
 
F017213747
F017213747F017213747
F017213747
IOSR Journals
 
F017213747
F017213747F017213747
F017213747
IOSR Journals
 
Design & Development of an Advanced Database Management System Using Multiver...
Design & Development of an Advanced Database Management System Using Multiver...Design & Development of an Advanced Database Management System Using Multiver...
Design & Development of an Advanced Database Management System Using Multiver...
IOSR Journals
 
db unit 4 dbms protocols in transaction
db unit 4 dbms  protocols in transactiondb unit 4 dbms  protocols in transaction
db unit 4 dbms protocols in transaction
Kumari Naveen
 
Concurrency Control & Deadlock Handling
Concurrency Control & Deadlock HandlingConcurrency Control & Deadlock Handling
Concurrency Control & Deadlock Handling
Meghaj Mallick
 
Database concurrency control &amp; recovery (1)
Database concurrency control &amp; recovery (1)Database concurrency control &amp; recovery (1)
Database concurrency control &amp; recovery (1)
Rashid Khan
 
VALIDATION BASED PROTOCOL AND MULTIPLE GRANULARITY.pptx
VALIDATION BASED PROTOCOL AND MULTIPLE GRANULARITY.pptxVALIDATION BASED PROTOCOL AND MULTIPLE GRANULARITY.pptx
VALIDATION BASED PROTOCOL AND MULTIPLE GRANULARITY.pptx
SamyakJain710491
 

Similar to Concurrency control (20)

concurrencycontrol from power pint pdf a
concurrencycontrol  from power pint pdf aconcurrencycontrol  from power pint pdf a
concurrencycontrol from power pint pdf a
 
Concurrency control
Concurrency control Concurrency control
Concurrency control
 
Unit 4 Concurrency control.pptx dbms lovely
Unit 4 Concurrency control.pptx dbms lovelyUnit 4 Concurrency control.pptx dbms lovely
Unit 4 Concurrency control.pptx dbms lovely
 
Unit 4 Concurrency control.pptx dbms lovely
Unit 4 Concurrency control.pptx dbms lovelyUnit 4 Concurrency control.pptx dbms lovely
Unit 4 Concurrency control.pptx dbms lovely
 
Concurrency control
Concurrency controlConcurrency control
Concurrency control
 
Concurrency Control.pptx
Concurrency Control.pptxConcurrency Control.pptx
Concurrency Control.pptx
 
DBMS Presentation.pptx
DBMS Presentation.pptxDBMS Presentation.pptx
DBMS Presentation.pptx
 
Unit 5 dbms
Unit 5 dbmsUnit 5 dbms
Unit 5 dbms
 
Concurrency Control
Concurrency ControlConcurrency Control
Concurrency Control
 
Concurrency control PPT
Concurrency control PPTConcurrency control PPT
Concurrency control PPT
 
Concurrency note.pdf
Concurrency note.pdfConcurrency note.pdf
Concurrency note.pdf
 
Unit 5 rdbms study_material
Unit 5  rdbms study_materialUnit 5  rdbms study_material
Unit 5 rdbms study_material
 
UNIT II.pptx
UNIT II.pptxUNIT II.pptx
UNIT II.pptx
 
F017213747
F017213747F017213747
F017213747
 
F017213747
F017213747F017213747
F017213747
 
Design & Development of an Advanced Database Management System Using Multiver...
Design & Development of an Advanced Database Management System Using Multiver...Design & Development of an Advanced Database Management System Using Multiver...
Design & Development of an Advanced Database Management System Using Multiver...
 
db unit 4 dbms protocols in transaction
db unit 4 dbms  protocols in transactiondb unit 4 dbms  protocols in transaction
db unit 4 dbms protocols in transaction
 
Concurrency Control & Deadlock Handling
Concurrency Control & Deadlock HandlingConcurrency Control & Deadlock Handling
Concurrency Control & Deadlock Handling
 
Database concurrency control &amp; recovery (1)
Database concurrency control &amp; recovery (1)Database concurrency control &amp; recovery (1)
Database concurrency control &amp; recovery (1)
 
VALIDATION BASED PROTOCOL AND MULTIPLE GRANULARITY.pptx
VALIDATION BASED PROTOCOL AND MULTIPLE GRANULARITY.pptxVALIDATION BASED PROTOCOL AND MULTIPLE GRANULARITY.pptx
VALIDATION BASED PROTOCOL AND MULTIPLE GRANULARITY.pptx
 

More from Soumyajit Dutta

Normalisation
NormalisationNormalisation
Normalisation
Soumyajit Dutta
 
Er model
Er modelEr model
Er model
Soumyajit Dutta
 
Aggregate functions
Aggregate functionsAggregate functions
Aggregate functions
Soumyajit Dutta
 
Transaction processing
Transaction processingTransaction processing
Transaction processing
Soumyajit Dutta
 
Single row functions
Single row functionsSingle row functions
Single row functions
Soumyajit Dutta
 
Chapter 4
Chapter 4Chapter 4
Chapter 4
Soumyajit Dutta
 
Chapter 2
Chapter 2Chapter 2
Chapter 2
Soumyajit Dutta
 
Computer Organisation Design
Computer Organisation DesignComputer Organisation Design
Computer Organisation Design
Soumyajit Dutta
 

More from Soumyajit Dutta (8)

Normalisation
NormalisationNormalisation
Normalisation
 
Er model
Er modelEr model
Er model
 
Aggregate functions
Aggregate functionsAggregate functions
Aggregate functions
 
Transaction processing
Transaction processingTransaction processing
Transaction processing
 
Single row functions
Single row functionsSingle row functions
Single row functions
 
Chapter 4
Chapter 4Chapter 4
Chapter 4
 
Chapter 2
Chapter 2Chapter 2
Chapter 2
 
Computer Organisation Design
Computer Organisation DesignComputer Organisation Design
Computer Organisation Design
 

Recently uploaded

Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Po-Chuan Chen
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 

Recently uploaded (20)

Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 

Concurrency control

  • 2. Concurrency Control • Concurrency control mechanism is responsible for maintaining the database consistency in case of concurrent execution. • Following are the most common concurrency control protocols: – Lock based protocol – Graph Based protocol – Time stamp based protocol – Validation based protocol
  • 3. Lock-Based Protocols • Inconsistency occurs when two transactions attempt to modify the same data item at the same time. • A general solution to this problem is that, if one transaction is accessing a data item then, no other transaction should be allowed to modify that data item. • Locks are used to implement this general solution. • Lock- is a variable associated with each data item that describes the status of the item with respect to possible operations that can be applied to it.
  • 4. Locks • There are two types of locks: – Binary locks – Shared/Exclusive locks • A binary lock can have two states-locked and unlocked. • The function lock(X) tells that whether data item X is locked or not at a given time. • If lock(X)=1 then, X is locked and if lock(X)=0 then, X is not locked. • A transaction can request and release a lock on data item X by using following two instructions: – Lock_item(X) – unlock_item(X)
  • 5. Locks • Main drawback of binary lock is that at a given point of time, at most one transaction can hold a lock on data item X. But, in database system it should be allowed that multiple transactions may access a data item only for reading. • To overcome this problem, we use shared/exclusive lock.
  • 8. Compatibility Function • Compatibility function can be defined as: – Let M and N be two lock modes. Now suppose that a transaction Ti requests a lock of mode M on data item A on which transaction Tj currently holds a lock of mode N. If transaction Ti can be granted a lock on A immediately inspite of presence of lock of mode N, then mode M is said to be compatible with mode N.
  • 10. Pitfalls of Lock-Based Protocols • Starvation is also possible if concurrency control manager is badly designed. For example: A transaction may be waiting for an X-lock on an item, while a sequence of other transactions request and are granted an S-lock on the same item. • The same transaction is repeatedly rolled back due to deadlocks. • Concurrency control manager can be designed to prevent starvation.
  • 11. Lock-Based Protocols • A locking protocol is a set of rules followed by all transactions while requesting and releasing locks. Locking protocols restrict the set of possible schedules. • Two types of lock based protocol is: – Two-phase locking protocol • Protocol which is not two phase: – Graph based protocol
  • 13. The Two-Phase Locking Protocol • Cascading rollback may occur in Two phase locking so in order to avoid it three variations on two phase locking is used: – Strict two-phase locking : Here a transaction must hold all its exclusive locks till it commits/aborts. – Rigorous two-phase locking : is even stricter: here all locks are held till commit/abort. In this protocol transactions can be serialized in the order in which they commit. – Two phase locking with Lock Conversion: This protocol adds the ability of lock conversion to the basic two phase locking. i.e we can convert a shared lock to an exclusive lock and vice versa. The Upgrade(A) instruction is used to convert a shared lock to an exclusive lock. The Downgrade(A) instruction is used to convert an exclusive lock shared lock.
  • 14. Graph Based Protocol • Graph-based protocols are an alternative to two- phase locking • This protocol requires prior knowledge about the order in which database items will be accessed • To acquire such prior knowledge, we impose a partial ordering→ on the set D = {d1, d2 ,..., dh} of all data items. – If di → dj then any transaction accessing both di and dj must access di before accessing dj.
  • 15. Graph Based Protocol • A tree or a graph protocol only exclusive locks are allowed. Each transaction Ti can lock data item only once, and must observe the following rules: 1. The first lock by Ti may be on any data item. 2. Subsequently, a data Q can be locked by Ti only if the parent of Q is currently locked by Ti. 3. Data items may be unlocked at any time. 4. A data item that has been locked and unlocked by Ti cannot subsequently be relocked by Ti
  • 17. Graph Based Protocol • Advantages: – The tree protocol ensures conflict serializability as well as freedom from deadlock. – Unlocking may occur earlier in the tree-locking protocol than in the two-phase locking protocol. • shorter waiting times, and increase in concurrency • protocol is deadlock-free, no rollbacks are required • Disadvantages: – Transactions may have to lock data items that it does not access. • increased locking overhead, and additional waiting time • potential decrease in concurrency
  • 18. Time Stamp Based Protocol • 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 protocol manages concurrent execution such that the time-stamps determine the serializability order. • In order to assure such behavior, the protocol maintains for each data Q two timestamp values: – W-timestamp(Q) is the largest time-stamp of any transaction that executed write(Q) successfully. – R-timestamp(Q) is the largest time-stamp of any transaction that executed read(Q) successfully.
  • 19. Time Stamp Based Protocol – Use the value of the system clock as the timestamp; that is, a transaction’s timestamp is equal to the value of the clock when the transaction enters the system. – Use a logical counter that is incremented after a new timestamp has been assigned; that is, a transaction’s timestamp is equal to the value of the counter when the transaction enters the system.
  • 20. Time Stamp Based Protocol • The timestamp ordering protocol ensures that any conflicting read and write operations are executed in timestamp order. • Suppose a transaction Ti issues a read(Q) – If TS(Ti) ≤ W-timestamp(Q), then Ti needs to read a value of Q that was already overwritten. Hence, the read operation is rejected, and Ti is rolled back. – If TS(Ti)≥ W-timestamp(Q), then the read operation is executed, and R-timestamp(Q) is set to max(R- timestamp(Q), TS(Ti)).
  • 21. Time Stamp Based Protocol • Suppose that transaction Ti issues write(Q). – If TS(Ti) < R-timestamp(Q), then the value of Q that Ti is producing was needed previously, and the system assumed that that value would never be produced. Hence, the write operation is rejected, and Ti is rolled back. – If TS(Ti) < W-timestamp(Q), then Ti is attempting to write an obsolete value of Q. Hence, this write operation is rejected, and Ti is rolled back. • Otherwise, the write operation is executed, and W- timestamp(Q) is set to TS(Ti).
  • 22. Time Stamp Based Protocol: Example • To illustrate this protocol, we consider transactions T1 and T2. Transaction T1 displays the contents of accounts A and B: – T1: read(B); read(A); display(A + B); – T2: read(B); B := B − 50; write(B); read(A); A := A + 50; write(A); display(A + B);
  • 23. Time Stamp Based Protocol • In presenting schedules under the timestamp protocol, we shall assume that a transaction is assigned a timestamp immediately before its first instruction. Thus, in schedule 3, TS(T1) < TS(T2), and the schedule is possible under the timestamp protocol. • Schedule 3
  • 24. Thomas Write Rule • Modified version of the timestamp-ordering protocol in which obsolete write operations may be ignored under certain circumstances. • When Ti attempts to write data item Q, if TS(Ti) < W- timestamp(Q), then Ti is attempting to write an obsolete value of {Q}. – Rather than rolling back Ti as the timestamp ordering protocol would have done, this {write} operation can be ignored. • Otherwise this protocol is the same as the timestamp ordering protocol. • Thomas' Write Rule allows greater potential concurrency. – Allows some view-serializable schedules that are not conflict-serializable.
  • 25. Validation Based Protocol • We assume that each transaction Ti executes in two or three different phases in its lifetime, depending on whether it is a read-only or an update transaction. The phases are, in order, – Read phase. During this phase, the system executes transaction Ti. It reads the values of the various data items and stores them in variables local to Ti. It performs all write operations on temporary local variables, without updates of the actual database.
  • 26. Validation Based Protocol – Validation phase. Transaction Ti performs a validation test to determine whether it can copy to the database the temporary local variables that hold the results of write operations without causing a violation of serializability. – Write phase. If transaction Ti succeeds in validation (step 2), then the system applies the actual updates to the database. Otherwise, the system rolls back Ti.
  • 27. Validation Based Protocol • Each transaction Ti has 3 timestamps – Start(Ti) : the time when Ti started its execution – Validation(Ti): the time when Ti entered its validation phase – Finish(Ti) : the time when Ti finished its write phase

Editor's Notes

  1. We have arrived a state where neither of the transactions can ever proceed with normal execution. This situation is called deadlock