High-Concurrency Locking in R-Trees

26
High-Concurrency Locking in R-Trees Presented by: Robertas Kerpys Marcel Kornacker Universität Hamburg Douglas Banks University of California at Berkeley VLDB 1995 November 11, 2010

description

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. p16. p10. p15. p14. p4. p5. p6. p7. p8. p9. p13. p11. p1. p2. - PowerPoint PPT Presentation

Transcript of High-Concurrency Locking in R-Trees

Page 1: High-Concurrency Locking  in R-Trees

High-Concurrency Locking inR-Trees

Presented by: Robertas Kerpys

Marcel Kornacker Universität Hamburg

Douglas Banks University of

California at Berkeley

VLDB 1995

November 11, 2010

Page 2: High-Concurrency Locking  in R-Trees

Database Specialization Course 2

Motivation

November 11, 2010

p1

p16

p2

p3

p4

p5p6

p7

p8

p9

p10

p11

p12

p13

R2

R1

p1 p2 p3 p4 p5 p13 p6 p7p11 p12p8 p9 p10

R5 R6 R7

R3

R4

R5R6

R7

R3 R4

R1 R2

p16

Query

Page 3: High-Concurrency Locking  in R-Trees

Database Specialization Course 3

Motivation

November 11, 2010

p1

p16

p2

p3

p4

p5p6

p7

p8

p9

p10

p11

p12

p13

R2

R1

p1 p2 p3 p4 p5 p13 p6 p7p11 p12p8 p9 p10

R5 R6 R7

R3

R4

R5R6

R7

R3 R4

R1 R2

p16

Query

Page 4: High-Concurrency Locking  in R-Trees

Database Specialization Course 4

Motivation

November 11, 2010

p1

p16

p2

p3

p4

p5p6

p7

p8

p9

p10

p11

p12

p13

R2

R1

p1 p2 p5 p16p3 p4 p13 p6 p7p11 p12p8 p9 p10

R5 R6 R7

R3

R4

R5R6

R7

R3 R4 R8

R1 R2 Query

R8

Page 5: High-Concurrency Locking  in R-Trees

Database Specialization Course 5

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

Page 6: High-Concurrency Locking  in R-Trees

Database Specialization Course 6

Overview

• Motivation• B-link tree• R-link tree• Algorithms (Search, Insert, Delete)• Empirical study• Conclusion• Critique

November 11, 2010

Page 7: High-Concurrency Locking  in R-Trees

Database Specialization Course 7

Blink - tree

November 11, 2010

Page 8: High-Concurrency Locking  in R-Trees

Database Specialization Course 8

Obstacles

• The main difficulty is that R-tree does not have a linear ordering

• Keys cannot conclusively tell us when a node has split

November 11, 2010

p1

p2

p3 p6

p8

p9

p10

p11

p12

R2R1

p1 p2 p3 p4 p5 p13 p6 p7p11 p12p8 p9 p10

R5 R6 R7

R3R5

R6

R3 R4

R1 R2

Page 9: High-Concurrency Locking  in R-Trees

Database Specialization Course 9

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

Page 10: High-Concurrency Locking  in R-Trees

Database Specialization Course 10

Structure of an R-link tree

November 11, 2010

5 6 4 2 1c1 c2 c3 c4 c5

5x

2y

4w

1z

p1 p2

Page 11: High-Concurrency Locking  in R-Trees

Database Specialization Course 11

Search

November 11, 2010

5 6 4 2 1c1 c2 c3 c4 c5

5x

2y

4w

1z

p1 p2

zwyx

c5c2 c3

Qualifyingentries:

Stack

Page 12: High-Concurrency Locking  in R-Trees

Database Specialization Course 12

Insertioninsert(Rect r):

stack = findLeaf(root, r, root-lsn)leaf = pop(stack)insert r on leafif leaf was split

extendParent(leaf, leaf.MBR, leaf.LSN, right_sibling, right_sibling.MBR, right_sibling.LSN,

stack)else

if bounding-rect of leaf changed updateParent(leaf, leaf.MBR, stack)

elsew-unlock(leaf)

November 11, 2010

Page 13: High-Concurrency Locking  in R-Trees

Database Specialization Course 13

Insertion. Find Leaf

November 11, 2010

p1 p2 p3 p4 p5 p13 p6 p7p11 p12p8 p9 p10

R5 R6 R7R3 R4

R1 R2findLeaf(root, r, root-lsn)

Stack:

N

N1 N2

N3 N4 N5 N6 N7

N

N1

N4

- shared lock - exclusive lock

Page 14: High-Concurrency Locking  in R-Trees

Database Specialization Course 14

Insertion. Extend Parent

November 11, 2010

p1 p2 p3 p4 p13 p6 p7p11 p12p8 p9 p10

R5 R6 R7R3 R4

R1 R2extendParent

Stack:

N

N1 N2

N3 N4 N5 N6 N7

N N1

- shared lock - exclusive lock

p5 p16

R8

N8

Page 15: High-Concurrency Locking  in R-Trees

Database Specialization Course 15

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

Page 16: High-Concurrency Locking  in R-Trees

Database Specialization Course 16

Deletion

November 11, 2010

p13 p6 p7p11 p12p8 p9 p10

R5 R6 R7R3 R4

R1 R2N1 N2

N3 N4 N5 N6 N7p5 p16

R8

TGC

9

p2p1

10

p4p3

N = 9

N

N1 = 9N2 = 9N3 = 9

N4 = 9N5 = 9N6 = 9N7 = 9

N4 = 10

Page 17: High-Concurrency Locking  in R-Trees

Database Specialization Course 17

Overview

• Motivation• B-link tree• R-link tree• Algorithms (Search, Insert, Delete)• Empirical study• Conclusion• Critique

November 11, 2010

Page 18: High-Concurrency Locking  in R-Trees

Database Specialization Course 18

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

Page 19: High-Concurrency Locking  in R-Trees

Database Specialization Course 19

Empirical Evaluation

November 11, 2010

Page 20: High-Concurrency Locking  in R-Trees

Database Specialization Course 20

Empirical Evaluation (cont.)

November 11, 2010

Page 21: High-Concurrency Locking  in R-Trees

Database Specialization Course 21

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

Page 22: High-Concurrency Locking  in R-Trees

Database Specialization Course 22

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

Page 23: High-Concurrency Locking  in R-Trees

Database Specialization Course 23

Critique. Advantages

• Recovery is addressed• R-link tree was implemented for commercial

database• Examples were good and where needed

November 11, 2010

Page 24: High-Concurrency Locking  in R-Trees

Database Specialization Course 24

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

Page 25: High-Concurrency Locking  in R-Trees

Database Specialization Course 25

Thank you!

November 11, 2010

Page 26: High-Concurrency Locking  in R-Trees

Database Specialization Course 26

Questions?Spørgsmål?Întrebare? Klausimai?

November 11, 2010