HighConcurrency Locking in RTrees Marcel Kornacker Universitt Hamburg
High-Concurrency Locking in R-Trees Marcel Kornacker Universität Hamburg Douglas Banks University of California at Berkeley VLDB 1995 Presented by: Robertas Kerpys November 11, 2010
Motivation Query R 1 R 2 R 3 R 4 p 1 p 2 R 5 R 6 R 7 p 3 p 4 p 5 p 8 p 9 p 10 p 11 p 12 R 2 p 16 R 1 p 9 p 8 R 5 p 2 R 3 p 3 R 4 November 11, 2010 p 13 p 6 p 7 p 5 p 4 p 16 p 10 R 6 p 11 p 12 p 13 R 7 Database Specialization Course p 7 2
Motivation Query R 1 R 2 R 3 R 4 p 1 p 2 R 5 R 6 R 7 p 3 p 4 p 5 p 8 p 9 p 10 p 11 p 12 R 2 p 16 R 1 p 9 p 8 R 5 p 2 R 3 p 3 R 4 November 11, 2010 p 13 p 6 p 7 p 5 p 4 p 16 p 10 R 6 p 11 p 12 p 13 R 7 Database Specialization Course p 7 3
Motivation Query R 1 R 2 R 3 R 4 R 8 p 1 p 2 p 3 p 4 R 5 R 6 R 7 p 5 p 16 p 8 p 9 p 10 p 11 p 12 R 1 p 9 p 8 R 5 p 2 R 3 p 3 R 4 November 11, 2010 p 13 p 6 p 7 p 5 p 4 R 8 p 16 p 10 R 6 p 11 p 12 p 13 R 7 Database Specialization Course p 7 4
Motivation • Concurrency requires special handling of the index structure to ensure consistency • Many of the methods which offers concurrent tree traversal employ top-down lock-coupling • Main goal is to enable queries and updates execute concurrently while ensuring the correctness of the results November 11, 2010 Database Specialization Course 5
Overview • • Motivation B-link tree R-link tree Algorithms (Search, Insert, Delete) Empirical study Conclusion Critique November 11, 2010 Database Specialization Course 6
Blink - tree November 11, 2010 Database Specialization Course 7
Obstacles • The main difficulty is that R-tree does not have a linear ordering • Keys cannot conclusively tell us when a node has split R 1 R 2 R 3 R 4 p 1 p 2 R 5 R 6 R 7 p 3 p 4 p 5 p 8 p 9 p 10 p 11 p 12 R 1 p 1 R 3 November 11, 2010 p 13 p 6 p 7 p 9 p 8 p 2 R 5 Database Specialization Course p 10 R 6 p 12 8
How to adapt links on an R-tree? • System of sequence numbers is introduced to determine when and how to traverse sibling links November 11, 2010 Database Specialization Course 9
Structure of an R-link tree p 1 c 1 5 November 11, 2010 x 5 c 2 6 p 2 y 2 w 4 c 3 4 Database Specialization Course c 4 2 z 1 c 5 1 10
Search Stack x y w z Qualifying entries: p 1 c 1 5 November 11, 2010 x 5 c 2 6 p 2 y 2 w 4 c 3 4 Database Specialization Course c 4 2 z 1 c 5 1 11
Insertion insert(Rect r): stack = find. Leaf(root, r, root-lsn) leaf = pop(stack) insert r on leaf if leaf was split extend. Parent(leaf, leaf. MBR, leaf. LSN, right_sibling. MBR, right_sibling. LSN, stack) else if bounding-rect of leaf changed update. Parent(leaf, leaf. MBR, stack) else w-unlock(leaf) November 11, 2010 Database Specialization Course 12
Insertion. Find Leaf - exclusive lock - shared lock Stack: N N 1 R 2 R 3 R 4 N 3 N 4 p 1 p 2 p 3 p 4 p 5 November 11, 2010 find. Leaf(root, r, root-lsn) N 2 R 5 R 6 R 7 N 5 p 8 p 9 p 10 Database Specialization Course N 6 N 7 p 11 p 12 p 13 p 6 p 7 13
Insertion. Extend Parent - exclusive lock - shared lock Stack: N N 1 N R 1 R 2 N 1 R 3 R 4 R 8 N 3 N 4 p 1 p 2 p 3 p 4 November 11, 2010 extend. Parent N 2 R 5 R 6 R 7 N 8 N 5 p 16 p 8 p 9 p 10 Database Specialization Course N 6 p 11 p 12 N 7 p 13 p 6 p 7 14
Deletion • A combination of the search and insert algorithms • Nodes are removed as soon as they become empty • In order to not employ the lock-coupling when descending the tree we have to take care of invalid pointers when removing nodes • A tree-global generation counter (TGC) is introduced November 11, 2010 Database Specialization Course 15
Deletion N R 1 R 2 N 1 N 2 R 3 R 4 R 8 N 3 N 4 p 1 p 2 p 3 p 4 TGC 10 9 November 11, 2010 R 5 R 6 R 7 N 5 p 16 N 6 p 8 p 9 p 10 N=9 N 1 = 9 N 2 = 9 N 3 = 9 p 11 p 12 N 7 p 13 p 6 p 7 N 4 = 10 9 N 5 = 9 N 6 = 9 N 7 = 9 Database Specialization Course 16
Overview • • Motivation B-link tree R-link tree Algorithms (Search, Insert, Delete) Empirical study Conclusion Critique November 11, 2010 Database Specialization Course 17
Experimental Setup • R-tree implementation employs a variation of Bayer-Schkolnick-style lock-coupling for concurrent insertions • Three different workloads: – The low-contention workload consists of a varying number of searchers and a single inserter – The moderate-contention workload of inserters only – The high-contention workload of an equal number of searchers and inserters • The index was pre-loaded with 30600 2 dimensional non-overlapping rectangles November 11, 2010 Database Specialization Course 18
Empirical Evaluation November 11, 2010 Database Specialization Course 19
Empirical Evaluation (cont. ) November 11, 2010 Database Specialization Course 20
Related Work • Blink – tree “Efficient Locking for Concurrent Operations on B-trees” by Philip L. Lehman, S. Bing Yao – Applied on B-trees – All ideas are drawn from this paper November 11, 2010 Database Specialization Course 21
Conclusion • R-link trees look and work similar to B-link trees • Holds only a few locks at one time • Descending an R-link tree to a leaf requires no lock-coupling November 11, 2010 Database Specialization Course 22
Critique. Advantages • Recovery is addressed • R-link tree was implemented for commercial database • Examples were good and where needed November 11, 2010 Database Specialization Course 23
Critique. Disadvantages • Workload is to small (30600 rectangles which does not even overlap) • Authors review only papers for concurrency in B-trees • They did not implemented everything they talked about • The notation in pseudo-code is not introduced in the text thus it was not obvious right away e. g. r-lock November 11, 2010 Database Specialization Course 24
Thank you! November 11, 2010 Database Specialization Course 25
Questions? Spørgsmål? Întrebare? Klausimai? November 11, 2010 Database Specialization Course 26
- Slides: 26