J.N GRAY R.A LORIE IBM RESEARCH LAB, SAN JOSE, CALIFORNIA

Slides:



Advertisements
Similar presentations
Database System Principles 18.7 Tree Locking Protocol CS257 Section 1 Spring 2012 Dhruv Jalota ID: 115.
Advertisements

1 ICS 214B: Transaction Processing and Distributed Data Management Lecture 4: More on Locks Professor Chen Li.
1 CS216 Advanced Database Systems Shivnath Babu Notes 12: Concurrency Control (II)
Concurrency Control Amol Deshpande CMSC424. Approach, Assumptions etc.. Approach  Guarantee conflict-serializability by allowing certain types of concurrency.
Managing Hierarchies of Database Elements (18.6) 1 Presented by Sarat Dasika (114) February 16, 2012.
Concurrency Control II. General Overview Relational model - SQL  Formal & commercial query languages Functional Dependencies Normalization Physical Design.
Concurrency Control Part 2 R&G - Chapter 17 The sequel was far better than the original! -- Nobody.
Sekolah Tinggi Ilmu Statistik (STIS) 1 Dr. Said Mirza Pahlevi, M.Eng.
CMU SCS Carnegie Mellon Univ. Dept. of Computer Science /615 - DB Applications C. Faloutsos – A. Pavlo Lecture#22: Concurrency Control – Part 2 (R&G.
Managing Hierarchies of Database Elements (18.6) -Neha Saxena Class Id: 214.
Chapter 4 Transaction Management Title: Granularity of Locks and Degrees of Consistency in a Shared Database Authors: J.N. Gray, R.A. Lorie, G. R. Putzolu.
Granularity of Locks and Degrees of Consistency in a Shared Data Base John LaFontaine Haixuan Sun.
Concurrency Control Managing Hierarchies of Database Elements (18.6) 1 Presented by Ronak Shah (214) March 9, 2009.
Chapter 4 Transaction Management Title: Granularity of Locks and Degrees of Consistency in a Shared Database Authors: J.N. Gray, R.A. Lorie, G. R. Putzolu.
GRANULARITY OF LOCKS IN SHARED DATA BASE J.N. Gray, R.A. Lorie and G.R. Putzolu.
Presentation Topic 18.7 of Book Tree Protocol Submitted to: Prof. Dr. T.Y.LIN Submitted By :Saurabh Vishal.
18.7 The Tree Protocol Andy Yang. Outline Introduction Motivation Rules for Access to Tree-Structured Data Why the Tree Protocol Works.
15.1Database System Concepts - 6 th Edition Chapter 15: Concurrency Control Lock-Based Protocols The Two-Phase Locking Protocol Graph-Based Protocols #Deadlock.
Concurrency Control.
Granularity of Locks and Degrees of Consistency in a Shared Database J.N. Gray, R.A. Lorie, G.R. Putzolu, I.L. Traiger 1977 (Presentation by Randy Ellis)
Lecture 12 Recoverability and failure. 2 Optimistic Techniques Based on assumption that conflict is rare and more efficient to let transactions proceed.
V. Megalooikonomou Concurrency control (based on slides by C. Faloutsos at CMU and on notes by Silberchatz,Korth, and Sudarshan) Temple University – CIS.
Carnegie Mellon Carnegie Mellon Univ. Dept. of Computer Science Database Applications C. Faloutsos Concurrency control.
Chapter 11 Concurrency Control. Lock-Based Protocols  A lock is a mechanism to control concurrent access to a data item  Data items can be locked in.
Transaction Management for XML Taro L. Saito Department of Information Science University of Tokyo
1 Concurrency Control Chapter Conflict Serializable Schedules  Two schedules are conflict equivalent if:  Involve the same actions of the same.
1 Concurrency Control Lecture 22 Ramakrishnan - Chapter 19.
Concurrency control in XML databases Ali Abbasi. Concurrency in XML Bases XML : standard format of data exchange on the internet XML docs is stored in.
Module 11: Managing Transactions and Locks
Lecture 9- Concurrency Control (continued) Advanced Databases Masood Niazi Torshiz Islamic Azad University- Mashhad Branch
CS 440 Database Management Systems Concurrency Control 1.
Managing Hierarchies of Database Elements Section 18.6 CS257 Jack Price.
Assignment 6 - Solution Problem 1 Suppose a transaction sets an intention-write lock on a file and later sets a write lock on a record of the file. Is.
Prepared by: Mudra Patel (113) Pradhyuman Raol(114) Locking Scheduler & Managing Hierarchies of Database Elements.
CS 540 Database Management Systems Concurrency Control 1.
CS 440 Database Management Systems
Section 18.6: Managing Hierarchies of Database Elements
Concurrency Control Managing Hierarchies of Database Elements (18.6)
Indexing Structures for Files and Physical Database Design
Azita Keshmiri CS 157B Ch 12 indexing and hashing
Lecture 3 Concurrency control techniques
Concurrency Control Techniques
Extra slide #3.
B+-Trees.
Concurrency Control More !
Multiple Granularity Granularity is the size of data item  allowed to lock. Multiple Granularity is the hierarchically breaking up the database into portions.
Concurrency Control Chapter 17 Modified by Donghui Zhang
B+-Trees.
B+-Trees.
B+ Tree.
B-Trees Disk Storage What is a multiway tree? What is a B-tree?
External Methods Chapter 15 (continued)
Chapter Trees and B-Trees
Chapter Trees and B-Trees
Anthony D. Joseph and Ion Stoica
Transactions, Locking and Query Optimisation
B- Trees D. Frey with apologies to Tom Anastasio
Chapter 16: Concurrency Control
Ch 22: Databases Concurrency Control
B-Trees Disk Storage What is a multiway tree? What is a B-tree?
B-Trees Disk Storage What is a multiway tree? What is a B-tree?
B- Trees D. Frey with apologies to Tom Anastasio
Transactions and Concurrency
Concurrency Control E0 261 Prasad Deshpande, Jayant Haritsa
Temple University – CIS Dept. CIS661 – Principles of Data Management
Database Management System
Transactional Information Systems:
B-Trees.
CONCURRENCY Concurrency is the tendency for different tasks to happen at the same time in a system ( mostly interacting with each other ) .   Parallel.
Prepared by: Mudra Patel (113) Pradhyuman Raol(114)
Presentation transcript:

J.N GRAY R.A LORIE IBM RESEARCH LAB, SAN JOSE, CALIFORNIA GRANULARITY OF LOCKS IN A SHARED DATABASE J.N GRAY R.A LORIE IBM RESEARCH LAB, SAN JOSE, CALIFORNIA

Why Locking ? When multiple users access the same data, they need to avoid clobbering each others work. Database must restrict the access to one user at a time for a table or a row.

Granularity ? Data is divided into levels. Granularity is the size of data item allowed to lock. Idea is to improve efficiency. Problem? What is the appropriate granularity of lockable objects in data base?

BACKGROUND Fine lockable unit = Increases concurrency for simple transactions. However, increases overhead for complex transactions. Coarse lockable unit= Lower overhead for complex transactions. However, reduces concurrency too for simple transactions.

The choice of lockable unit is Tradeoff ! Overhead: The amount of file structure, memory and processing time needed to keep those different transactions from affecting each other undesirably WE DON’T WANT Concurrency: The ability to have one transaction work with one set of resources while another transaction “Simultaneously” works with others WHAT WE WANT

Granularity of Locks Locking only the exact record being examined allows for maximum concurrency However, if there are a lot of lockable objects, then the overhead increases: Takes time to set/reset locks. Storage overhead of representing lock in memory. Solution : Allow for multiple granularity locking in the same system.

Granularity Hierarchy Database Areas Files Records Locking level is NOT FIXED. It is decided based on the requirements !

Types of Locks Exclusive lock (x) : Requester has exclusive access to that node and its descendants (for writes) Shared lock (s): Requester has shared access to that node and its descendants (for reads) Requesting a lock on a node in the hierarchy implicitly locks the descendants of the node as well.

Analogy Reference: https://www.slideshare.net/billkarwin/innodb-locking-explained-with-stick-figures

Analogy

Analogy

Analogy

Exclusive locks revisited A lock that does not share It must be the only lock on the resource Request for an exclusive locks waits for any other locks on the resource.

Shared lock Analogy

Analogy

Analogy

Shared locks revisited A lock that shares with others It blocks exclusive locks

Problem? T1 has an s lock on a record of a file. T2 has an x lock on whole file. How can T2 discover that T1 has locked the record?

Intention Locks Tags all the ancestors of a node to be locked in s or x mode. Signals the intention of locking at finer levels. Prevent locking of the entire subtree by locking ancestors with x or s mode . Allow us to work with higher node, and still avoid changes that might conflict with the lock further down -- increases concurrency T1 gets an s-lock on record but first gets an intention (IS) lock on file Now T2 can get x-lock on file

Intention Locks Intention Share (IS) : Gives intention share access to the requested node and allows the requestor to lock descendant nodes in S or IS mode. (No implicit locking)

Intention Locks Intention exclusive (IX):Gives intention exclusive access to the requested node and allows the requestor to explicitly lock descendants in X, S, SIX, IX, or IS mode. (No implicit locking) Suppose we need to access the entire subtree and update particular nodes of the subtree, which mode will be used?

Intention Locks A. Exclusive lock to root and no further locking OR B. IX lock on root of subtree and explicitly locking child nodes in intention, share or exclusive mode A results in low concurrency B results in high overhead Solution: Shared access to subtree, giving read access to all. Allowing X locks to only those which needs to be updated and IX or SIX locks to intervening nodes.

Intention Locks Shared Intention Exclusive(SIX): Implicitly locks all the children of the node in shared mode and explicitly allows to lock child in X,SIX,or IX mode. (No implicit locking)

Access mode compatibility Null mode (NL) represents absence of requests of a resource by a transaction

Rules for requesting nodes Must observe the lock compatibility Root of the tree must be locked first in any mode Before requesting S/IS lock on a node, all ancestor nodes must have IX/IS lock. Before requesting X/SIX/IX lock on a node, all ancestor nodes must have SIX/IX lock. Locks should be released in leaf to root order. A transaction can unlock a node only if none of its children are currently locked.

Examples Lock record R for Write-exclusive access: IX IX IX X

Examples Lock a record R for read: IS IS IS S Note: If the records of this and previous example are distinct , each request can be granted simultaneously to different transactions even though they refer to same file.

Examples To lock a file F for complete scan and occasional updates: DataBase Table File IX IX SIX Note: This transaction is compatible with the previous example

Directed Acyclic Graph of locks The tree locking hierarchy can be generalized to all directed acyclic graphs(DAG) To lock a node in DAG , all parents must be locked in appropriate mode. A node is locked in S mode if ANY of the parents are explicitly or implicitly locked in S,SIX or X. A node is implicitly locked in X mode if ALL of its parents are locked in X mode. Note: Rules for requesting a lock is similar to hierarchy based locking.

Requesting Locks in DAG Before requesting an S or IS lock on a node, one should request at least one parent in IS mode Before requesting IX, SIX, or X mode access to a node, one should request all parents in IX (or greater) mode When releasing locks, one should never hold a lower lock having released its ancestors (or it should release all locks when the transaction is complete)

Dynamic Lock graphs So far the lock graphs were static. Areas, files indices are dynamically created and destroyed as records are inserted and deleted . Index is partitioned into lockable key value intervals Example: Lock all the records in account file where location field(key) = napa (value). Advantage: Instead of locking the index or record, we can lock all records with a certain index value.

Dynamic locks Key value interval is the parent of records and indexed field. An index value interval has a record id and field value so we can read the filed directly without touching the record. Update: When an indexed field is updated, it and its parent record move from one interval to another interval. Insert: When record is inserted, it joins the interval containing the field value. Delete: Removes the records form the interval and the file.

Example Move Napa account to St.Helena branch: Lock database: IX mode Lock area : IX mode Lock accounts file: IX mode Lock location index: IX mode Lock Napa interval: IX mode Lock Helena interval: IX mode Lock record: IX mode Lock field: X mode

Questions???