Data and Database Administration Chapter 12. Outline What is Concurrency Control? Background Serializability  Locking mechanisms.

Slides:



Advertisements
Similar presentations
Indra Budi Transaction Indra Budi
Advertisements

Concurrency Control WXES 2103 Database. Content Concurrency Problems Concurrency Control Concurrency Control Approaches.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Transaction Management Overview Chapter 16.
Chapter 16 Concurrency. Topics in this Chapter Three Concurrency Problems Locking Deadlock Serializability Isolation Levels Intent Locking Dropping ACID.
CSC271 Database Systems Lecture # 32.
Lecture 11 Recoverability. 2 Serializability identifies schedules that maintain database consistency, assuming no transaction fails. Could also examine.
Transaction Management and Concurrency Control
10 1 Chapter 10 Transaction Management and Concurrency Control Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
Transaction Management and Concurrency Control
Transaction Management and Concurrency Control
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Transaction Management and Concurrency Control.
What is a Transaction? Logical unit of work
Transaction Management
DBMS Functions Data, Storage, Retrieval, and Update
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 8-1 COS 346 Day 18.
Chapter 9 Transaction Management and Concurrency Control
9 Chapter 9 Transaction Management and Concurrency Control Hachim Haddouti.
Database Administration Part 1 Chapter Six CSCI260 Database Applications.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Transaction Management and Concurrency Control.
BACS 485—Database Management Concurrency Control Overview of Database Concurrency Control.
Transaction Management and Concurrency Control
10/5/1999Database Management -- R. Larson Data Administration and Database Administration University of California, Berkeley School of Information Management.
Academic Year 2014 Spring Academic Year 2014 Spring.
1 IT420: Database Management and Organization Transactions 31 March 2006 Adina Crăiniceanu
© 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 CHAPTER 11: DATA AND DATABASE ADMINISTRATION Modern Database Management 11 th Edition Jeffrey.
DBSQL 7-1 Copyright © Genetic Computer School 2009 Chapter 7 Transaction Management, Database Security and Recovery.
Multi-user Database Processing Architectures Architectures Transactions Transactions Security Security Administration Administration.
Recovery & Concurrency Control. What is a Transaction?  A transaction is a logical unit of work that must be either entirely completed or aborted. 
BIS Database Systems School of Management, Business Information Systems, Assumption University A.Thanop Somprasong Chapter # 10 Transaction Management.
ITEC 3220M Using and Designing Database Systems Instructor: Prof. Z. Yang Course Website: 3220m.htm
Database Systems/COMP4910/Spring05/Melikyan1 Transaction Management Overview Unit 2 Chapter 16.
Module Coordinator Tan Szu Tak School of Information and Communication Technology, Politeknik Brunei Semester
1 IT420: Database Management and Organization Session Control Managing Multi-user Databases 24 March 2006 Adina Crăiniceanu
11/7/2012ISC329 Isabelle Bichindaritz1 Transaction Management & Concurrency Control.
Concurrency Control. Objectives Management of Databases Concurrency Control Database Recovery Database Security Database Administration.
II.I Selected Database Issues: 2 - Transaction ManagementSlide 1/20 1 II. Selected Database Issues Part 2: Transaction Management Lecture 4 Lecturer: Chris.
Data & Database Administration
MBA 664 Database Management Dave Salisbury ( )
TM 13-1 Copyright © 1999 Addison Wesley Longman, Inc. Data and Database Administration.
Transaction Management Overview. Transactions Concurrent execution of user programs is essential for good DBMS performance. – Because disk accesses are.
Transaction Management Transparencies. ©Pearson Education 2009 Chapter 14 - Objectives Function and importance of transactions. Properties of transactions.
Transaction Processing Concepts
ITEC 3220A Using and Designing Database Systems Instructor: Gordon Turpin Course Website: Office: CSEB3020.
1 Advanced Database Concepts Transaction Management and Concurrency Control.
Transaction Management and Concurrent Control
9 1 Chapter 9_B Concurrency Control Database Systems: Design, Implementation, and Management, Rob and Coronel.
Lecture 8 Transactions & Concurrency UFCE8K-15-M: Data Management.
1 Database Systems ( 資料庫系統 ) December 27/28, 2006 Lecture 13 Merry Christmas & New Year.
Switch off your Mobiles Phones or Change Profile to Silent Mode.
10 1 Chapter 10_B Concurrency Control Database Systems: Design, Implementation, and Management, Rob and Coronel.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Transaction Management and Concurrency Control.
10 Transaction Management and Concurrency Control MIS 304 Winter 2005.
©Bob Godfrey, 2002, 2005 Lecture 17: Transaction Integrity and Concurrency BSA206 Database Management Systems.
3 Database Systems: Design, Implementation, and Management CHAPTER 9 Transaction Management and Concurrency Control.
18 September 2008CIS 340 # 1 Last Covered (almost)(almost) Variety of middleware mechanisms Gain? Enable n-tier architectures while not necessarily using.
Chapter 13 Managing Transactions and Concurrency Database Principles: Fundamentals of Design, Implementation, and Management Tenth Edition.
CSC314 Day 16 Transaction processing Concurrency Control 1.
Copyright © 2016 Pearson Education, Inc. CHAPTER 12: DATA AND DATABASE ADMINISTRATION Modern Database Management 12 th Edition Jeff Hoffer, Ramesh Venkataraman,
TM 13-1 Copyright © 1999 Addison Wesley Longman, Inc. Data and Database Administration.
Transaction Management and Concurrency Control
Multi-User Databases Chapter 9.
Transaction Properties
Database Processing: David M. Kroenke’s Chapter Nine: Part One
Concurrency.
Chapter 10 Transaction Management and Concurrency Control
Concurrency Control WXES 2103 Database.
Introduction of Week 13 Return assignment 11-1 and 3-1-5
Transactions and Concurrency
Transaction Management Overview
Presentation transcript:

Data and Database Administration Chapter 12

Outline What is Concurrency Control? Background Serializability  Locking mechanisms

What is Concurrency Control? The process of managing simultaneous operations against a database so that data integrity is maintained and the operations do not interfere with each other in a multi-user environment.

Background Most DBMS run in a multi-user environment, where several users are able to share data contained in a database. No data integrity problems occur when data is being read. But problems can arise when several users are updating data. When more than one transaction is being processed against a DB at the same time, the transactions are considered to be concurrent. The actions that must be made to ensure data integrity are called concurrency control actions.

Background (Contd.) Remember that CPU can process only one instruction at a time. As new transactions are submitted while other processing is occurring against the database, the transactions are usually interleaved. The CPU switches among the transactions so that some portion of each transaction is performed as the CPU addresses each transaction in turn.

Problems without Concurrency Control Lost Updates problem can occur when multiple users attempt to update database. Example Two users with joint account trying to withdraw cash at the same time using ATM at different locations. User AUser B 1.Read account balance($1000) 2.Withdraw $200 2.Withdraw $300 3.Write account balance($800) 3.Write account balance($700) ERROR time

Problems without Concurrency Control Inconsistent read problems can occur when one user reads data that has been partially updated by another user. This read will be incorrect, also called dirty read or unrepeatable read.

Serializabilty Concurrent transactions need to be processed in isolation so that they do not interfere with each other. If one transaction were entirely processes at a time before another one, no interference would occur. Procedures which emulate this are called serializable. Serializable schedules process transactions that will give results as if they had been processed one after the other. Schedules are designed such that transactions that will not interfere with each other can be run in parallel, e.g., transactions that access data from different tables in a database will not conflict with each other. Serializability is achieved by different ways, but locking mechanisms are the most common.

Locking Locking implies that any data retrieved by a user for updating must be locked, or denied to other users, until the update is completed or aborted. Locking mechanism enforces a sequential updating process that prevents erroneous updates. (See next slide to understand this) It is the pessimistic approach of concurrency control

Concurrency Control through Locking User AUser B 1.Read account balance 2.Lock account balance 1.Read account balance (denied) 2.Read account balance($1000) 2.Withdraw $200 3.Write account balance($800) 4. Unlock account balance 2.Lock account balance 3.Read account balance($800) 4.Withdraw $300 5.Write account balance($500) 6. Unlock account balance time

Locking Levels There are different locking levels (granularity)  Database Entire DB is locked & becomes unavailable. This level can be used during backups  Table Entire table containing a requested record is locked. This level can be used for bulk updates that will update entire table (e.g., salary raise)  Block or page The physical storage block (or page) containing the requested record is locked. This level is commonly implemented.  Record level Only the requested record (row) is locked. All other records within table are available.  Field level Only the particular field (column) in the requested record is locked.

Types of locks Shared (S locks or read locks)  Allows other transactions to read but not update a record or resource.  Placing a shared lock prevents another user from placing an exclusive lock, but not a shared lock, on that record. Exclusive (X locks or write locks)  Prevent other transaction from reading and therefore updating a record until unlocked.  Should be placed when updating records.  Placing an exclusive lock on a record prevents another user from placing any type of lock on that record

Deadlocks Locking may prevent erroneous updates but can lead to deadlocks problem. Deadlock: When two or more transactions lock a common resource, each one of them waits for the other one to unlock that resource. Deadlock prevention: users must lock all required records at the beginning of the transaction. Two-phase locking protocol is used (read yourself from book). Deadlock resolution: the DBMS detects and breaks the deadlock by backing out of the the deadlocked transactions.  Any changes made by that transaction up to the time of deadlock are removed,  The transaction is restarted when the resources become available.

Versioning Optimistic approach of concurrency control Already covered in previous lectures.