adm in istrivia
play

ADM IN ISTRIVIA Project #1 is due Fri Sept 27 th @ 11:59pm Homework - PowerPoint PPT Presentation

09 Index Concurrency Intro to Database Systems Andy Pavlo AP AP 15-445/15-645 Computer Science Carnegie Mellon University Fall 2019 2 ADM IN ISTRIVIA Project #1 is due Fri Sept 27 th @ 11:59pm Homework #2 is due Mon Sept 30 th @ 11:59pm


  1. 17 B+ TREE M ULTI- TH READED EXAM PLE T 1 : Delete 44 A 20 T 2 : Find 41 10 35 B C D 6 12 23 31 38 44 Rebalance! 3 4 6 9 10 11 12 13 20 22 23 31 35 36 38 41 44 E F G H I CMU 15-445/645 (Fall 2019)

  2. 17 B+ TREE M ULTI- TH READED EXAM PLE T 1 : Delete 44 A 20 T 2 : Find 41 10 35 B C D 6 12 23 31 38 44 Rebalance! 3 4 6 9 10 11 12 13 20 22 23 31 35 36 38 41 44 E F G H I CMU 15-445/645 (Fall 2019)

  3. 17 B+ TREE M ULTI- TH READED EXAM PLE T 1 : Delete 44 A 20 T 2 : Find 41 10 35 B C D 6 12 23 31 38 44 Rebalance! 3 4 6 9 10 11 12 13 20 22 23 31 35 36 38 41 44 E F G H I CMU 15-445/645 (Fall 2019)

  4. 17 B+ TREE M ULTI- TH READED EXAM PLE T 1 : Delete 44 A 20 T 2 : Find 41 10 35 B C D 6 12 23 31 38 44 41 Rebalance! 3 4 6 9 10 11 12 13 20 22 23 31 35 36 38 41 44 E F G H I CMU 15-445/645 (Fall 2019)

  5. 17 B+ TREE M ULTI- TH READED EXAM PLE T 1 : Delete 44 A 20 T 2 : Find 41 10 35 B C D 6 12 23 31 38 44 41 Rebalance! 3 4 6 9 10 11 12 13 20 22 23 31 35 36 38 41 44 E F G H I ??? CMU 15-445/645 (Fall 2019)

  6. 18 LATCH CRABBIN G/ CO UPLIN G Protocol to allow multiple threads to access/modify B+Tree at the same time. Basic Idea: → Get latch for parent. → Get latch for child → Release latch for parent if “safe”. A safe node is one that will not split or merge when updated. → Not full (on insertion) → More than half-full (on deletion) CMU 15-445/645 (Fall 2019)

  7. 19 LATCH CRABBIN G/ CO UPLIN G Find : Start at root and go down; repeatedly, → Acquire R latch on child → Then unlatch parent Insert/Delete : Start at root and go down, obtaining W latches as needed. Once child is latched, check if it is safe: → If child is safe, release all latches on ancestors. CMU 15-445/645 (Fall 2019)

  8. 20 EXAM PLE # 1 FIN D 38 R A 20 10 35 B C D 6 12 23 38 44 3 4 6 9 10 11 12 13 20 22 23 31 35 36 38 41 44 E F G H I CMU 15-445/645 (Fall 2019)

  9. 20 EXAM PLE # 1 FIN D 38 R A 20 R 10 35 B It’s safe to release the latch on A. C D 6 12 23 38 44 3 4 6 9 10 11 12 13 20 22 23 31 35 36 38 41 44 E F G H I CMU 15-445/645 (Fall 2019)

  10. 20 EXAM PLE # 1 FIN D 38 A 20 R 10 35 B C D 6 12 23 38 44 3 4 6 9 10 11 12 13 20 22 23 31 35 36 38 41 44 E F G H I CMU 15-445/645 (Fall 2019)

  11. 20 EXAM PLE # 1 FIN D 38 A 20 10 35 B R C D 6 12 23 38 44 3 4 6 9 10 11 12 13 20 22 23 31 35 36 38 41 44 E F G H I CMU 15-445/645 (Fall 2019)

  12. 20 EXAM PLE # 1 FIN D 38 A 20 10 35 B C D 6 12 23 38 44 R 3 4 6 9 10 11 12 13 20 22 23 31 35 36 38 41 44 E F G H I CMU 15-445/645 (Fall 2019)

  13. 20 EXAM PLE # 1 FIN D 38 A 20 10 35 B C D 6 12 23 38 44 3 4 6 9 10 11 12 13 20 22 23 31 35 36 38 41 44 E F G H I CMU 15-445/645 (Fall 2019)

  14. 21 EXAM PLE # 2 DELETE 38 W A 20 10 35 B C D 6 12 23 38 44 3 4 6 9 10 11 12 13 20 22 23 31 35 36 38 41 44 E F G H I CMU 15-445/645 (Fall 2019)

  15. 21 EXAM PLE # 2 DELETE 38 W A 20 W 10 35 B We may need to coalesce B, so we can’t release the latch on A. C D 6 12 23 38 44 3 4 6 9 10 11 12 13 20 22 23 31 35 36 38 41 44 E F G H I CMU 15-445/645 (Fall 2019)

  16. 21 EXAM PLE # 2 DELETE 38 W A 20 W 10 35 B W C D 6 12 23 38 44 We know that D will not need to merge with C, so it’s safe to 3 4 6 9 10 11 12 13 20 22 23 31 35 36 38 41 44 release latches on A and B. E F G H I CMU 15-445/645 (Fall 2019)

  17. 21 EXAM PLE # 2 DELETE 38 A 20 10 35 B W C D 6 12 23 38 44 We know that D will not need to merge with C, so it’s safe to 3 4 6 9 10 11 12 13 20 22 23 31 35 36 38 41 44 release latches on A and B. E F G H I CMU 15-445/645 (Fall 2019)

  18. 21 EXAM PLE # 2 DELETE 38 A 20 10 35 B C D 6 12 23 38 44 W 3 4 6 9 10 11 12 13 20 22 23 31 35 36 38 41 44 E F G H I CMU 15-445/645 (Fall 2019)

  19. 21 EXAM PLE # 2 DELETE 38 A 20 10 35 B C D 6 12 23 38 44 W 3 4 6 9 10 11 12 13 20 22 23 31 35 36 38 41 44 E F G H I CMU 15-445/645 (Fall 2019)

  20. 22 EXAM PLE # 3 IN SERT 4 5 A 20 10 35 B C D 6 12 23 38 44 3 4 6 9 10 11 12 13 20 22 23 31 35 36 38 41 44 45 E F G H I CMU 15-445/645 (Fall 2019)

  21. 22 EXAM PLE # 3 IN SERT 4 5 W A 20 W 10 35 B We know that if D needs to split, B has room so it’s safe to release the latch on A. C D 6 12 23 38 44 3 4 6 9 10 11 12 13 20 22 23 31 35 36 38 41 44 45 E F G H I CMU 15-445/645 (Fall 2019)

  22. 22 EXAM PLE # 3 IN SERT 4 5 A 20 W 10 35 B W C D 6 12 23 38 44 3 4 6 9 10 11 12 13 20 22 23 31 35 36 38 41 44 45 E F G H I CMU 15-445/645 (Fall 2019)

  23. 22 EXAM PLE # 3 IN SERT 4 5 A 20 W 10 35 B W C D 6 12 23 38 44 W 3 4 6 9 10 11 12 13 20 22 23 31 35 36 38 41 44 45 Node I won’t split, so we E F G H I can release B+D. CMU 15-445/645 (Fall 2019)

  24. 22 EXAM PLE # 3 IN SERT 4 5 A 20 10 35 B C D 6 12 23 38 44 W 3 4 6 9 10 11 12 13 20 22 23 31 35 36 38 41 44 45 Node I won’t split, so we E F G H I can release B+D. CMU 15-445/645 (Fall 2019)

  25. 23 EXAM PLE # 4 IN SERT 25 W A 20 W 10 35 B C D 6 12 23 31 38 44 3 4 6 9 10 11 12 13 20 22 23 31 35 36 38 41 44 E F G H I CMU 15-445/645 (Fall 2019)

  26. 23 EXAM PLE # 4 IN SERT 25 A 20 W 10 35 B C D 6 12 23 31 38 44 3 4 6 9 10 11 12 13 20 22 23 31 35 36 38 41 44 E F G H I CMU 15-445/645 (Fall 2019)

  27. 23 EXAM PLE # 4 IN SERT 25 A 20 W 10 35 B W C D 6 12 23 31 38 44 3 4 6 9 10 11 12 13 20 22 23 31 35 36 38 41 44 E F G H I CMU 15-445/645 (Fall 2019)

  28. 23 EXAM PLE # 4 IN SERT 25 A 20 10 35 B W C D 6 12 23 31 38 44 3 4 6 9 10 11 12 13 20 22 23 31 35 36 38 41 44 E F G H I CMU 15-445/645 (Fall 2019)

  29. 23 EXAM PLE # 4 IN SERT 25 A 20 10 35 B W C D 6 12 23 31 38 44 W 3 4 6 9 10 11 12 13 20 22 23 31 35 36 38 41 44 We need to split F so we need to E F G H I hold the latch on its parent node. CMU 15-445/645 (Fall 2019)

  30. 23 EXAM PLE # 4 IN SERT 25 A 20 10 35 B W C D 6 12 23 31 38 44 W 3 4 6 9 10 11 12 13 20 22 23 31 25 35 36 38 41 44 We need to split F so we need to E F G H I hold the latch on its parent node. CMU 15-445/645 (Fall 2019)

  31. 23 EXAM PLE # 4 IN SERT 25 A 20 10 35 B W C D 6 12 23 31 38 44 W 3 4 6 9 10 11 12 13 20 22 23 31 25 35 36 38 41 44 We need to split F so we need to E F G H I hold the latch on its parent node. 31 CMU 15-445/645 (Fall 2019)

  32. 24 O BSERVATIO N What was the first step that all the update examples did on the B+Tree? Delete 38 Insert 45 Insert 25 W W W A A A 20 20 20 CMU 15-445/645 (Fall 2019)

  33. 25 O BSERVATIO N What was the first step that all the update examples did on the B+Tree? Taking a write latch on the root every time becomes a bottleneck with higher concurrency. Can we do better? CMU 15-445/645 (Fall 2019)

  34. 26 BETTER LATCH IN G ALGO RITH M Assume that the leaf node is safe. Use read latches and crabbing to reach it, and then verify that it is safe. If leaf is not safe, then do previous algorithm using write latches. CMU 15-445/645 (Fall 2019)

  35. 27 EXAM PLE # 2 DELETE 38 R A 20 10 35 B C D 6 12 23 38 44 3 4 6 9 10 11 12 13 20 22 23 31 35 36 38 41 44 E F G H I CMU 15-445/645 (Fall 2019)

  36. 27 EXAM PLE # 2 DELETE 38 A 20 R 10 35 B C D 6 12 23 38 44 3 4 6 9 10 11 12 13 20 22 23 31 35 36 38 41 44 E F G H I CMU 15-445/645 (Fall 2019)

  37. 27 EXAM PLE # 2 DELETE 38 A 20 10 35 B R C D 6 12 23 38 44 3 4 6 9 10 11 12 13 20 22 23 31 35 36 38 41 44 E F G H I CMU 15-445/645 (Fall 2019)

  38. 27 EXAM PLE # 2 DELETE 38 A 20 10 35 B R C D 6 12 23 38 44 W 3 4 6 9 10 11 12 13 20 22 23 31 35 36 38 41 44 E F G H I CMU 15-445/645 (Fall 2019)

  39. 27 EXAM PLE # 2 DELETE 38 A 20 10 35 B C D 6 12 23 38 44 W 3 4 6 9 10 11 12 13 20 22 23 31 35 36 38 41 44 E F G H I H will not need to coalesce, so we’re safe! CMU 15-445/645 (Fall 2019)

  40. 27 EXAM PLE # 2 DELETE 38 A 20 10 35 B C D 6 12 23 38 44 W 3 4 6 9 10 11 12 13 20 22 23 31 35 36 38 41 44 E F G H I H will not need to coalesce, so we’re safe! CMU 15-445/645 (Fall 2019)

  41. 28 EXAM PLE # 4 IN SERT 25 A 20 10 35 B C D 6 12 23 38 44 W 3 4 6 9 10 11 12 13 20 22 23 31 35 36 38 41 44 We need to split F so we have to restart and re- E F G H I execute like before. CMU 15-445/645 (Fall 2019)

  42. 29 BETTER LATCH IN G ALGO RITH M Search : Same as before. Insert/Delete : → Set latches as if for search, get to leaf, and set W latch on leaf. → If leaf is not safe, release all latches, and restart thread using previous insert/delete protocol with write latches. This approach optimistically assumes that only leaf node will be modified; if not, R latches set on the first pass to leaf are wasteful. CMU 15-445/645 (Fall 2019)

  43. 30 O BSERVATIO N The threads in all the examples so far have acquired latches in a "top-down" manner. → A thread can only acquire a latch from a node that is below its current node. → If the desired latch is unavailable, the thread must wait until it becomes available. But what if we want to move from one leaf node to another leaf node? CMU 15-445/645 (Fall 2019)

  44. 31 LEAF N O DE SCAN EXAM PLE # 1 T 1 : Find Keys < 4 R 3 A 1 2 3 4 B C CMU 15-445/645 (Fall 2019)

  45. 31 LEAF N O DE SCAN EXAM PLE # 1 T 1 : Find Keys < 4 3 A R 1 2 3 4 B C CMU 15-445/645 (Fall 2019)

  46. 31 LEAF N O DE SCAN EXAM PLE # 1 T 1 : Find Keys < 4 Do not release latch on C 3 A until thread has latch on B R 1 2 3 4 B C CMU 15-445/645 (Fall 2019)

  47. 31 LEAF N O DE SCAN EXAM PLE # 1 T 1 : Find Keys < 4 Do not release latch on C 3 A until thread has latch on B R R 1 2 3 4 B C CMU 15-445/645 (Fall 2019)

  48. 31 LEAF N O DE SCAN EXAM PLE # 1 T 1 : Find Keys < 4 3 A R 1 2 3 4 B C CMU 15-445/645 (Fall 2019)

  49. 32 LEAF N O DE SCAN EXAM PLE # 2 T 1 : Find Keys < 4 T 2 : Find Keys > 1 3 A 1 2 3 4 B C CMU 15-445/645 (Fall 2019)

  50. 32 LEAF N O DE SCAN EXAM PLE # 2 T 1 : Find Keys < 4 R T 2 : Find Keys > 1 3 A 1 2 3 4 B C CMU 15-445/645 (Fall 2019)

  51. 32 LEAF N O DE SCAN EXAM PLE # 2 T 1 : Find Keys < 4 R T 2 : Find Keys > 1 3 A R R 1 2 3 4 B C CMU 15-445/645 (Fall 2019)

  52. 32 LEAF N O DE SCAN EXAM PLE # 2 T 1 : Find Keys < 4 T 2 : Find Keys > 1 3 A R R 1 2 3 4 B C CMU 15-445/645 (Fall 2019)

  53. 32 LEAF N O DE SCAN EXAM PLE # 2 T 1 : Find Keys < 4 T 2 : Find Keys > 1 Both T 1 and T 2 now hold Both T 1 and T 2 now hold 3 A this read latch. this read latch. R R 1 2 3 4 B C CMU 15-445/645 (Fall 2019)

  54. 32 LEAF N O DE SCAN EXAM PLE # 2 T 1 : Find Keys < 4 T 2 : Find Keys > 1 Only T 1 holds Only T 2 holds 3 A this read latch. this read latch. R R 1 2 3 4 B C CMU 15-445/645 (Fall 2019)

  55. 33 LEAF N O DE SCAN EXAM PLE # 3 T 1 : Delete 4 T 2 : Find Keys > 1 R 3 A 1 2 3 4 B C CMU 15-445/645 (Fall 2019)

  56. 33 LEAF N O DE SCAN EXAM PLE # 3 T 1 : Delete 4 T 2 : Find Keys > 1 3 A R W 1 2 3 4 B C CMU 15-445/645 (Fall 2019)

  57. 33 LEAF N O DE SCAN EXAM PLE # 3 T 1 : Delete 4 T 2 : Find Keys > 1 3 A T 2 cannot acquire the read latch on C R W 1 2 3 4 B C CMU 15-445/645 (Fall 2019)

  58. 33 LEAF N O DE SCAN EXAM PLE # 3 T 1 : Delete 4 T 2 : Find Keys > 1 3 A T 2 cannot acquire the read latch on C R W 1 2 3 4 B C T 2 does not know what T 1 is doing… CMU 15-445/645 (Fall 2019)

Recommend


More recommend