Transactional Information Systems:

Slides:



Advertisements
Similar presentations
Database Systems (資料庫系統)
Advertisements

1 CS216 Advanced Database Systems Shivnath Babu Notes 12: Concurrency Control (II)
4/16/20151 PSU’s CS Concurrency Control and Recovery (only for DBs with updates…..!)- Review  Concurrency Control  Transaction  ACID  Isolation.
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.
Transaction Management and Concurrency Control
Granularity of Locks and Degrees of Consistency in a Shared Data Base John LaFontaine Haixuan Sun.
Transaction Management and Concurrency Control
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Transaction Management and Concurrency Control.
6/25/2015Transactional Information Systems7-1 Transactional Information Systems: Theory, Algorithms, and the Practice of Concurrency Control and Recovery.
Chapter 4: Transaction Management
B + -Trees (Part 1). Motivation AVL tree with N nodes is an excellent data structure for searching, indexing, etc. –The Big-Oh analysis shows most operations.
6/27/2015Transactional Information Systems8-1 Transactional Information Systems: Theory, Algorithms, and the Practice of Concurrency Control and Recovery.
GRANULARITY OF LOCKS IN SHARED DATA BASE J.N. Gray, R.A. Lorie and G.R. Putzolu.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Transaction Management and Concurrency Control.
18.7 The Tree Protocol Andy Yang. Outline Introduction Motivation Rules for Access to Tree-Structured Data Why the Tree Protocol Works.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 Tree-Structured Indexes Chapter 9.
 B+ Tree Definition  B+ Tree Properties  B+ Tree Searching  B+ Tree Insertion  B+ Tree Deletion.
BIS Database Systems School of Management, Business Information Systems, Assumption University A.Thanop Somprasong Chapter # 10 Transaction Management.
V. Megalooikonomou Concurrency control (based on slides by C. Faloutsos at CMU and on notes by Silberchatz,Korth, and Sudarshan) Temple University – CIS.
Concurrency Control Concurrency Control By Dr.S.Sridhar, Ph.D.(JNUD), RACI(Paris, NICE), RMR(USA), RZFM(Germany) DIRECTOR ARUNAI ENGINEERING COLLEGE TIRUVANNAMALAI.
1 Concurrency Control II: Locking and Isolation Levels.
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.
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.
3 Database Systems: Design, Implementation, and Management CHAPTER 9 Transaction Management and Concurrency Control.
1 Tree-Structured Indexes Chapter Introduction  As for any index, 3 alternatives for data entries k* :  Data record with key value k   Choice.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Tree-Structured Indexes Content based on Chapter 10 Database Management Systems, (3 rd.
11th International Conference on Web-Age Information Management July 15-17, 2010 Jiuzhaigou, China V Locking Protocol for Materialized Aggregate Join Views.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Tree-Structured Indexes Chapter 10.
Chapter 13 Managing Transactions and Concurrency Database Principles: Fundamentals of Design, Implementation, and Management Tenth Edition.
Database Applications (15-415) DBMS Internals- Part III Lecture 13, March 06, 2016 Mohammad Hammoud.
Tree-Structured Indexes. Introduction As for any index, 3 alternatives for data entries k*: – Data record with key value k –  Choice is orthogonal to.
Transactional Information Systems:
Contents. Goal and Overview. Ingredients. The Page Model.
Chapter 8: Concurrency Control on Relational Databases
Transactional Information Systems:
Chap.7 Concurrency Control Algorithms on object
Concurrency Control Managing Hierarchies of Database Elements (18.6)
Transactional Information Systems - Chapter 2. ML Lab 나 용 찬
Multiway Search Trees Data may not fit into main memory
Tree-Structured Indexes
COP Introduction to Database Structures
Concurrency Control Techniques
Computational Models Database Lab Minji Jo.
Transaction Management and Concurrency Control
Extra slide #3.
Concurrency Control More !
Concurrency Control.
Multiple Granularity Granularity is the size of data item  allowed to lock. Multiple Granularity is the hierarchically breaking up the database into portions.
Transactional Information Systems:
Temporal Indexing MVBT.
B+ Tree.
Chapter 6: Concurrency Control on Objects: Notions of Correctness
Database Applications (15-415) DBMS Internals- Part III Lecture 15, March 11, 2018 Mohammad Hammoud.
J.N GRAY R.A LORIE IBM RESEARCH LAB, SAN JOSE, CALIFORNIA
B+ Trees What are B+ Trees used for What is a B Tree What is a B+ Tree
B+-Trees and Static Hashing
Tree-Structured Indexes
Chapter 10 Transaction Management and Concurrency Control
B+Trees The slides for this text are organized into chapters. This lecture covers Chapter 9. Chapter 1: Introduction to Database Systems Chapter 2: The.
Chapter 15 : Concurrency Control
Transactional Information Systems:
Introduction of Week 13 Return assignment 11-1 and 3-1-5
Temple University – CIS Dept. CIS661 – Principles of Data Management
Chapter 7: Concurrency Control Algorithms on Objects
Tree-Structured Indexes
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:

Transactional Information Systems: Theory, Algorithms, and the Practice of Concurrency Control and Recovery Gerhard Weikum and Gottfried Vossen © 2002 Morgan Kaufmann ISBN 1-55860-508-8 “Teamwork is essential. It allows you to blame someone else.”(Anonymous) 5/17/2019 Transactional Information Systems

Part II: Concurrency Control 3 Concurrency Control: Notions of Correctness for the Page Model 4 Concurrency Control Algorithms 5 Multiversion Concurrency Control 6 Concurrency Control on Objects: Notions of Correctness 7 Concurrency Control Algorithms on Objects 8 Concurrency Control on Relational Databases 9 Concurrency Control on Search Structures 10 Implementation and Pragmatic Issues 5/17/2019 Transactional Information Systems

Chapter 9: Concurrency Control on Search Structures 9.2 Implementation by B+-trees 9.3 Key-Range Locking at the Access Layer 9.4 Techniques for the Page Layer 9.5 Further Optimizations 9.6 Lessons Learned “ As long as one keeps searching, the answers come. ” (Joan Baez) 5/17/2019 Transactional Information Systems

Transactional Information Systems Example  fetches records p, q t1: Update Persons Set City = ‘Phoenix‘ Where Age  50 And City = ‘Dallas‘ t2: Select * From Persons Where City = ‘Phoenix‘ Where City = ‘Dallas‘  modifies record x  fetches records d, e Observations: page locking would prevent this phantom-problem execution locking the accessed records alone is insufficient need appropriate locks on (key, RID) pairs in City index 5/17/2019 Transactional Information Systems

Chapter 9: Concurrency Control on Search Structures 9.2 Implementation by B+-trees 9.3 Key-Range Locking at the Access Layer 9.4 Techniques for the Page Layer 9.5 Further Optimizations 9.6 Lessons Learned 5/17/2019 Transactional Information Systems

Implementation of Index by B+-tree Adam Bill Dick Eve Hank Jane Bob Jill Tom Root Node Leaf Nodes RIDs B+-tree Search tree interface: lookup <index> where <indexed field> = <search key> lookup <index> where <indexed field> between <lower bound> and <higher bound> 5/17/2019 Transactional Information Systems

Simple Insertion into B+-tree Index Carl Eve Adam Bill Carl Dick Eve Hank Jane Jill Tom + Ellen, + Bob Carl Eve Adam Bill Bob Carl Dick Ellen Eve Hank Jane Jill Tom 5/17/2019 Transactional Information Systems

Insertion into B+-tree with Leaf Node Split Adam Bill Dick Ellen Hank Jane Sue Tom Bob Jill Carl Eve Leaf Node Split + Sue 5/17/2019 Transactional Information Systems

Insertion into B+-tree with Root Node Split + Betty Bill Carl Eve Jill Adam Betty Bill Dick Ellen Eve Hank Jane Jill Sue Tom Bob Carl Root Node Split Eve root node inner nodes Bill Carl Jill Adam Betty Bill Dick Ellen Eve Hank Jane Jill Sue Tom leaf nodes Bob Carl 5/17/2019 Transactional Information Systems

Chapter 9: Concurrency Control on Search Structures 9.2 Implementation by B+-trees 9.3 Key-Range Locking at the Access Layer 9.4 Techniques for the Page Layer 9.5 Further Optimizations 9.6 Lessons Learned 5/17/2019 Transactional Information Systems

Simple Key-Range Locking ADT interface for search structure: insert (key, RID) delete (key, RID) search (key) range_search (lowkey, highkey) Protocol: insert, delete, and search lock single key (insert and delete in compatible modes) range_search locks interval [lowkey, highkey] table scan effectively locks interval [ - , +  ] + page locks acquired during subtransactions lock manager needs “key in interval” test range_search “preclaims” lock on entire interval 5/17/2019 Transactional Information Systems

Incremental Key-Range Locking refined ADT interface with range_search(lowkey, highkey) replaced by: search (lowkey)  key  page next (currentkey, currentpage, highkey)  key  page next ... Approach: operations lock intervals [found-key, next-existing-key) identified by “found-key” (i.e., only keys that do exist in the index) + page locks during subtransactions Incremental Key-Range (Previous-Key) Locking Protocol: search(x) requests read lock on x if x is present, or largest key < x if x is not found next(currentkey, ...) requests read lock on currentkey insert (y, RID) requests write locks on y and largest key < y delete (y, RID) requests write locks on y and largest key < y 5/17/2019 Transactional Information Systems

Example: Incremental Key-Range Locking 18 31 38 r ... n 17 22 25 p 33 36 q range_search (23, 34): search (23)  25  p lock page r, page n, page p lock key 22 unlock pages r, n, p next (25, p, 34)  31  p lock key 25 next (31, p, 34)  33  q lock key 31 next (33, q, 34)  nil  nil lock key 33 insert (27, ...): lock page r, page n, page p lock key 25 lock key 27 unlock pages r, n, p 5/17/2019 Transactional Information Systems

Correctness of Incremental Key-Range Locking Theorem 9.1: Previous-key locking generates only conflict-serializable schedules as far as index operations are concerned. Proof sketch: search(x) is in conflict with insert(y, RID) or delete (y, RID) only for x=y for successful search the conflict is detected by locks on x for unsuccessful search the conflict is detected by locks on largest key < x range_search (low, high) is in conflict with insert (y, RID) or delete (y, RID) if y falls into [low, high] this conflict is detected because range_search incrementally acquires locks on all keys from low or the largest key < low up to and including the largest key  high, which must include the largest key < y insert (x, RID) and insert (y, RID) conflict only for x=y (and only for unique index) ... 5/17/2019 Transactional Information Systems

Chapter 9: Concurrency Control on Search Structures 9.2 Implementation by B+-trees 9.3 Key-Range Locking at the Access Layer 9.4 Techniques for the Page Layer 9.5 Further Optimizations 9.6 Lessons Learned 5/17/2019 Transactional Information Systems

Transactional Information Systems Problem Scenario 18 31 38 r ... n 17 22 25 27 p 33 36 q 30 p' stage 0 stage 1 stage 2 Problem: search(31) or insert(31) in between stage 1 and stage 2 5/17/2019 Transactional Information Systems

Solution 1: Lock Coupling (“Crabbing”) Definition: A tree node is split-safe if it has enough free space to accommodate at least one additional routing key and child pointer Protocol: Search operations need a read lock before accessing a node. Insert operations need a write lock before accessing a node. A lock can be granted only if there is no conflict and the requestor holds a lock (in the same mode) on the node‘s parent. Search operations can release a lock on a node once they have acquired a lock on a child of that node. Insert operations can release a lock on a node if the node is split-safe and they have acquired a lock on a child of that node Theorem 9.2: Lock coupling for search and insert operations generates only OCSR schedules. 5/17/2019 Transactional Information Systems

Example: Lock Coupling insert (30): search (31): write lock r write lock n unlock r read lock r request read lock on n write lock p allocate new page p‘ write lock p‘ split contents of p onto p and p‘ adjust contents of n release locks on n, p, p‘ acquire read lock on n release lock on r read lock p‘ release lock on n return RID for key 31 release lock on p‘ 5/17/2019 Transactional Information Systems

Lock Coupling with Range Searches, Next, and Delete Operations the initial search (lowkey) of a range_search (lowkey, highkey) operation applies the locking rules for exact-key search operations a next (currentkey, currentpage, highkey) operation needs to acquire a read lock on currentpage, and it can acquire a lock on another leaf node only if it holds a lock on the preceding leaf. delete operations do not trigger node merging an empty node can be deallocated only when all transactions that were active at the time when the node became empty have terminated (“drain technique”) 5/17/2019 Transactional Information Systems

Correctness of Extended Lock Coupling Theorem 9.3: Lock coupling with next operations generates only OCSR schedules. Proof sketch: By Theorems 9.1 and 9.3, schedules with search, insert, delete, and next operations are tree reducible. So the remaining problem scenario is of the form: ... searchi (lowkey) ... insertk (x, RID1) ... nexti (currentkey1, ..., highkey) ... ... insertl (y, RID2) ... nexti (currentkey2, ..., highkey) ... with active transactions ti, tk, tl x cannot fall into [lowkey, currentkey1] and y cannot fall into [lowkey, currentkey2] because of previous-key lock conflicts So both insertk (x, ...) and insertl (y, ...) can be commuted to the left of ti Theorem 9.4: (Extended) Lock coupling at the page layer together with incremental key-range locking at the access layer ensure tree reducibility of all 2-level schedules. 5/17/2019 Transactional Information Systems

Example: Extended Lock Coupling range_search (24, 35): insert (30): search (24) read lock r, read lock n, unlock r read lock p, unlock n read lock key 22, unlock p write lock r, write lock n, unlock r next (25, p, 35) read lock p read lock key 25, unlock p write lock p next (27, p, 35) request read lock on p write lock key 30, write lock key 27 release locks on p, p‘, n acquire lock on p request read lock on key 27 commit transaction acquire lock on key 27 read lock p‘, unlock p, unlock p‘ next (30, p‘, 35) read lock p‘, read lock key 30, unlock p‘ ... 5/17/2019 Transactional Information Systems

Solution 2: Link Technique Link protocol: Search operations need only lock the currently accessed node (no need for holding two page locks simultaneously) Upon “not found”, search and next operations proceed to the right sibling node until they have seen a larger key Solution 3: Giveup Technique Giveup protocol: All operations need only lock the currently accessed node (no need for holding two page locks simultaneously) Each node contains a “range field” for its subtree, maintained by splits on a per node basis Upon seeing a node with a range field that does not contain the search key, the operation “gives up” and is retried, starting again from the root 5/17/2019 Transactional Information Systems

Example: Link Technique insert (30): search (31): read lock r release lock on r read lock n release lock on n write lock r write lock n unlock r write lock p request read lock on p allocate new page p‘ write lock p‘ split contents of p onto p and p‘ adjust contents of n release locks on n, p, p‘ acquire lock on p release lock on p read lock p‘ return RID for key 31 release lock on p‘ 5/17/2019 Transactional Information Systems

Chapter 9: Concurrency Control on Search Structures 9.2 Implementation by B+-trees 9.3 Key-Range Locking at the Access Layer 9.4 Techniques for the Page Layer 9.5 Further Optimizations 9.6 Lessons Learned 5/17/2019 Transactional Information Systems

Further Optimizations Index traversal can use deadlock-free page latching rather than full-fledged locks Insert operations for the same key interval are commutative  insert lock mode compatible with itself, but incompatible with read Insert operations merely need instant-duration lock on previous key Delete operations that leave a “ghost key” for deferred garbage collection need to lock only the deleted key Fewer locks (but possibly less concurrency) by locking (key, RID) pairs or only RIDs 5/17/2019 Transactional Information Systems

Chapter 9: Concurrency Control on Search Structures 9.2 Implementation by B+-trees 9.3 Key-Range Locking at the Access Layer 9.4 Techniques for the Page Layer 9.5 Further Optimizations 9.6 Lessons Learned 5/17/2019 Transactional Information Systems

Transactional Information Systems Lessons Learned Index concurrency control is a perfect example for layered schedules At the access layer, a primitive form of predicate locking is used, namely, key-range locking, and optimized for incremental, low-overhead lock acquisition At the page layer, short-term locks or latches are used to isolate index operations, with protocols ranging from S2PL for subtransactions to lock coupling, link techniques, or give-up protocols Locking rules at the two levels are integrated with each other 5/17/2019 Transactional Information Systems