SlideShare a Scribd company logo
1 of 17
BIT 4514:
Database Technology for Business
Fall 2019
Database concurrency control
1
Concurrency control
• Concurrency control is the process of managing
simultaneous operations on the database without
having them interfere with one another
• Prevents interference when two or more users are
accessing database simultaneously and at least one is
updating data
• Although two transactions may be correct in
themselves, interleaving of operations may produce
an incorrect result
2
Need for concurrency control
3
• Three examples of potential problems
caused by concurrency:
– Lost updates
– Uncommitted data
– Inconsistent retrievals
Lost update problem
• Occurs when a successfully completed update is
overwritten by another transaction
• Example:
– T1 withdraws $10 from an account with initial balx = $100
– T2 deposits $100 into same account
The final balance should be $190, but incorrectly
overlapping transactions may lead to a final balance of
only $90
4
Lost update problem (illustr.)
5
• Result: T2's update is lost
Uncommitted data problem
• Occurs when one transaction accesses the
intermediate results of another transaction before
they are committed – and the second transaction is
then rolled back.
• Example:
– T4 updates balx to $200, but there is an error in a later
UPDATE, so balx is rolled back to original value of $100
– After the balx update, but before the rollback, T3 reads the
new value of balx ($200) and uses this as the basis of a $10
reduction, giving a final new balance of $190, not $90
6
Uncommitted data problem (illustr.)
7
Inconsistent retrievals problem
• Occurs when a transaction reads several values, but a
different transaction updates some of them in the
midst of this process
– Some data are read before they are changed and others
after they are changed – yielding inconsistent results
• Example:
– T6 is totaling balances of account x ($100), account y
($50), and account z ($25)
– Meanwhile, T5 transfers $10 from balx to balz after x is
totaled but before z is, so T6 has a result that's $10 too high
8
Inconsistent retrievals problem (illustr.)
9
Scheduler
10
• A serializable schedule is a schedule of a transaction's
operations in which the interleaved execution of all active
transactions yields the same results as if those transactions
were executed in serial order
– Waiting for one transaction to finish before starting any
others may be inefficient
– The built-in scheduler ensures efficient use of the DBMS
and CPU by interleaving operations when possible
• If transactions access unrelated data, then there is no
conflict among individual operations between
transactions
Scheduling
• Methods for scheduling conflicting operations
in concurrent transactions:
– Locking methods
– Timestamping
11
Lock terminology
• Lock granularity refers to the size of the locked
resource:
database-level…table-level…page-level…row-level
slow data access significant overhead
• An exclusive lock prohibits other users from reading
the locked resource
• A shared lock allows other users to read the locked
resource, but they cannot update it
12
Optimistic vs. Pessimistic locking
• Optimistic locking assumes that no transaction conflict(s)
will occur:
– DBMS processes a transaction to a temporary file; checks whether
conflict occurred:
• If not, the transaction is finished
• If so, the transaction is repeated until there is no conflict
• Pessimistic locking assumes that conflict(s) will occur:
– Locks are issued before a transaction is processed, and then the
locks are released
• Optimistic locking is acceptable for applications with few
update operations
13
Two-phase locking
• Two-phase locking (2PL) guarantees serializability
– one of the most common techniques used to
achieve this
– Transactions are allowed to obtain as many locks
as necessary (growing phase)
– Once the first lock is released (shrinking phase),
no additional locks can be obtained
– Two-phase locking doesn't prevent deadlocks
14
Deadlock
• An impasse that may result when two (or more)
transactions are waiting for locks held by the other to be
released
15
Controlling deadlocks
• Three basic techniques:
– Deadlock prevention
• Abort a transaction if possibility of deadlock
• Reschedule transaction for later execution
– Deadlock detection
• DBMS periodically tests database for deadlocks
• If found, one transaction ("victim") is rolled back
– Deadlock avoidance
• Transactions obtain all needed locks before execution
16
Timestamping
• Timestamp: A unique identifier created by DBMS that
indicates the relative starting time of a transaction
• Transactions ordered globally so that older
transactions (transactions with smaller timestamps) get
priority in the event of conflict
• Conflict is resolved by rolling back and restarting the
associated transaction - no locks, so no deadlocks
• Demands a lot of system resources (both memory and
processing overhead)
17

More Related Content

Similar to Concurrency.education presentation schoolpptx

Transaction Processing Concept
Transaction Processing ConceptTransaction Processing Concept
Transaction Processing ConceptNishant Munjal
 
DBMS Presentation.pptx
DBMS Presentation.pptxDBMS Presentation.pptx
DBMS Presentation.pptxPravinBhargav1
 
Transaction concurrency control
Transaction concurrency controlTransaction concurrency control
Transaction concurrency controlAnand Grewal
 
Dartabase Transaction.pptx
Dartabase Transaction.pptxDartabase Transaction.pptx
Dartabase Transaction.pptxBibus Poudel
 
Distributed Database Design and Relational Query Language
Distributed Database Design and Relational Query LanguageDistributed Database Design and Relational Query Language
Distributed Database Design and Relational Query LanguageAAKANKSHA JAIN
 
concurrencycontrol from power pint pdf a
concurrencycontrol  from power pint pdf aconcurrencycontrol  from power pint pdf a
concurrencycontrol from power pint pdf aMdAyanParwez
 
Chapter-10 Transaction Processing and Error Recovery
Chapter-10 Transaction Processing and Error RecoveryChapter-10 Transaction Processing and Error Recovery
Chapter-10 Transaction Processing and Error RecoveryKunal Anand
 
Svetlin Nakov - Database Transactions
Svetlin Nakov - Database TransactionsSvetlin Nakov - Database Transactions
Svetlin Nakov - Database TransactionsSvetlin Nakov
 
Chapter Three _Concurrency Control Techniques_ETU.ppt
Chapter Three _Concurrency Control Techniques_ETU.pptChapter Three _Concurrency Control Techniques_ETU.ppt
Chapter Three _Concurrency Control Techniques_ETU.ppthaymanot taddesse
 
7 concurrency controltwo
7 concurrency controltwo7 concurrency controltwo
7 concurrency controltwoashish61_scs
 
7 concurrency controltwo
7 concurrency controltwo7 concurrency controltwo
7 concurrency controltwoashish61_scs
 
Transaction management and concurrency control
Transaction management and concurrency controlTransaction management and concurrency control
Transaction management and concurrency controlDhani Ahmad
 
7. transaction mang
7. transaction mang7. transaction mang
7. transaction mangkhoahuy82
 

Similar to Concurrency.education presentation schoolpptx (20)

Concurrency Control
Concurrency ControlConcurrency Control
Concurrency Control
 
Transaction Processing Concept
Transaction Processing ConceptTransaction Processing Concept
Transaction Processing Concept
 
DBMS Presentation.pptx
DBMS Presentation.pptxDBMS Presentation.pptx
DBMS Presentation.pptx
 
Transaction concurrency control
Transaction concurrency controlTransaction concurrency control
Transaction concurrency control
 
Concurrency control
Concurrency control Concurrency control
Concurrency control
 
Dartabase Transaction.pptx
Dartabase Transaction.pptxDartabase Transaction.pptx
Dartabase Transaction.pptx
 
Distributed Database Design and Relational Query Language
Distributed Database Design and Relational Query LanguageDistributed Database Design and Relational Query Language
Distributed Database Design and Relational Query Language
 
concurrencycontrol from power pint pdf a
concurrencycontrol  from power pint pdf aconcurrencycontrol  from power pint pdf a
concurrencycontrol from power pint pdf a
 
Chapter-10 Transaction Processing and Error Recovery
Chapter-10 Transaction Processing and Error RecoveryChapter-10 Transaction Processing and Error Recovery
Chapter-10 Transaction Processing and Error Recovery
 
Concurrency control
Concurrency controlConcurrency control
Concurrency control
 
Concurrency control
Concurrency controlConcurrency control
Concurrency control
 
Svetlin Nakov - Database Transactions
Svetlin Nakov - Database TransactionsSvetlin Nakov - Database Transactions
Svetlin Nakov - Database Transactions
 
Rdbms
RdbmsRdbms
Rdbms
 
Rdbms
RdbmsRdbms
Rdbms
 
transaction_processing.ppt
transaction_processing.ppttransaction_processing.ppt
transaction_processing.ppt
 
Chapter Three _Concurrency Control Techniques_ETU.ppt
Chapter Three _Concurrency Control Techniques_ETU.pptChapter Three _Concurrency Control Techniques_ETU.ppt
Chapter Three _Concurrency Control Techniques_ETU.ppt
 
7 concurrency controltwo
7 concurrency controltwo7 concurrency controltwo
7 concurrency controltwo
 
7 concurrency controltwo
7 concurrency controltwo7 concurrency controltwo
7 concurrency controltwo
 
Transaction management and concurrency control
Transaction management and concurrency controlTransaction management and concurrency control
Transaction management and concurrency control
 
7. transaction mang
7. transaction mang7. transaction mang
7. transaction mang
 

Recently uploaded

PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptxPoojaSen20
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 

Recently uploaded (20)

PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptx
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 

Concurrency.education presentation schoolpptx

  • 1. BIT 4514: Database Technology for Business Fall 2019 Database concurrency control 1
  • 2. Concurrency control • Concurrency control is the process of managing simultaneous operations on the database without having them interfere with one another • Prevents interference when two or more users are accessing database simultaneously and at least one is updating data • Although two transactions may be correct in themselves, interleaving of operations may produce an incorrect result 2
  • 3. Need for concurrency control 3 • Three examples of potential problems caused by concurrency: – Lost updates – Uncommitted data – Inconsistent retrievals
  • 4. Lost update problem • Occurs when a successfully completed update is overwritten by another transaction • Example: – T1 withdraws $10 from an account with initial balx = $100 – T2 deposits $100 into same account The final balance should be $190, but incorrectly overlapping transactions may lead to a final balance of only $90 4
  • 5. Lost update problem (illustr.) 5 • Result: T2's update is lost
  • 6. Uncommitted data problem • Occurs when one transaction accesses the intermediate results of another transaction before they are committed – and the second transaction is then rolled back. • Example: – T4 updates balx to $200, but there is an error in a later UPDATE, so balx is rolled back to original value of $100 – After the balx update, but before the rollback, T3 reads the new value of balx ($200) and uses this as the basis of a $10 reduction, giving a final new balance of $190, not $90 6
  • 8. Inconsistent retrievals problem • Occurs when a transaction reads several values, but a different transaction updates some of them in the midst of this process – Some data are read before they are changed and others after they are changed – yielding inconsistent results • Example: – T6 is totaling balances of account x ($100), account y ($50), and account z ($25) – Meanwhile, T5 transfers $10 from balx to balz after x is totaled but before z is, so T6 has a result that's $10 too high 8
  • 10. Scheduler 10 • A serializable schedule is a schedule of a transaction's operations in which the interleaved execution of all active transactions yields the same results as if those transactions were executed in serial order – Waiting for one transaction to finish before starting any others may be inefficient – The built-in scheduler ensures efficient use of the DBMS and CPU by interleaving operations when possible • If transactions access unrelated data, then there is no conflict among individual operations between transactions
  • 11. Scheduling • Methods for scheduling conflicting operations in concurrent transactions: – Locking methods – Timestamping 11
  • 12. Lock terminology • Lock granularity refers to the size of the locked resource: database-level…table-level…page-level…row-level slow data access significant overhead • An exclusive lock prohibits other users from reading the locked resource • A shared lock allows other users to read the locked resource, but they cannot update it 12
  • 13. Optimistic vs. Pessimistic locking • Optimistic locking assumes that no transaction conflict(s) will occur: – DBMS processes a transaction to a temporary file; checks whether conflict occurred: • If not, the transaction is finished • If so, the transaction is repeated until there is no conflict • Pessimistic locking assumes that conflict(s) will occur: – Locks are issued before a transaction is processed, and then the locks are released • Optimistic locking is acceptable for applications with few update operations 13
  • 14. Two-phase locking • Two-phase locking (2PL) guarantees serializability – one of the most common techniques used to achieve this – Transactions are allowed to obtain as many locks as necessary (growing phase) – Once the first lock is released (shrinking phase), no additional locks can be obtained – Two-phase locking doesn't prevent deadlocks 14
  • 15. Deadlock • An impasse that may result when two (or more) transactions are waiting for locks held by the other to be released 15
  • 16. Controlling deadlocks • Three basic techniques: – Deadlock prevention • Abort a transaction if possibility of deadlock • Reschedule transaction for later execution – Deadlock detection • DBMS periodically tests database for deadlocks • If found, one transaction ("victim") is rolled back – Deadlock avoidance • Transactions obtain all needed locks before execution 16
  • 17. Timestamping • Timestamp: A unique identifier created by DBMS that indicates the relative starting time of a transaction • Transactions ordered globally so that older transactions (transactions with smaller timestamps) get priority in the event of conflict • Conflict is resolved by rolling back and restarting the associated transaction - no locks, so no deadlocks • Demands a lot of system resources (both memory and processing overhead) 17