The idea to keep with you
When implementing B-Link splits, link left->right siblings before updating parent and only hop left-to-right.
TL;DR30-second simplified summary▾
Sustains 100k+ concurrent writes/sec across 64 cores.
Before you begin · Building blocksAlready know these? Jump to Stage 01 ↓
B+Tree Page Splits
Splits full pages and inserts separator keys into parents.
Shared vs Exclusive Latches
Page-level reader/writer synchronization primitives.
Full walkthrough · 2 stages
01
STAGE 01intermediate
Breaking Upper-Tree Lock Coupling.
Why this matters: Remove multi-level exclusive latch holds from B+Tree descent.
Threads latch only one page at a time during descent, checking highKey before hopping right.
Before · Pessimistic Crabbing Convoy
After · B-Link Single-Page Latch
| Choice | What it buys | What it costs |
|---|---|---|
| Pessimistic Crabbing | Simpler split | Severe 64-core lock convoy |
| B-Link Single-Page Latch | Zero multi-level lock coupling | Must enforce left->right split ordering |
// Safe B-Link split ordering: link right sibling BEFORE updating parent
rightSibling.highKey = leftPage.highKey;
rightSibling.rightLink = leftPage.rightLink;
leftPage.highKey = splitKey;
leftPage.rightLink = rightSibling; // Readers can now hop left -> right safely!
02
STAGE 02advanced
Left-to-Right Latch Order & Deadlock Freedom.
Why this matters: Prove why B-Link horizontal hops never deadlock.
Latches are only ever acquired top-down or strictly left-to-right; since no thread ever acquires a left sibling while holding a right sibling, cycles are impossible.
Engineering Decision Framework
- Problem
- Eliminate 64-core lock convoys during 100k/s concurrent B+Tree inserts without introducing search misses or latch deadlocks.
- Naive Solution
- Keep pessimistic latch crabbing or allow readers to hop both left and right across siblings.
- Why It Fails
- Pessimistic crabbing serializes upper nodes; bidirectional sibling hopping creates AB-BA latch cycles and deadlocks.
- Alternatives
- Pessimistic crabbing, optimistic lock coupling with full-tree restarts, or Lehman-Yao B-Link with strict left-to-right hops.
- Engineering Decision
- Adopt Lehman-Yao B-Link splitting (link right sibling before parent insert) and restrict sibling hops strictly left-to-right.
- Trade-Offs
- Requires 16 bytes/page for High Key + rightLink and bottom-up split ordering, but guarantees deadlock freedom and 100k+ writes/s.
Decision Exercise · Make the Call
Why must B-Link traversals only hop left-to-right (never right-to-left) when following sibling pointers?
def split_leaf_blink(left, new_right, split_key):
new_right.high_key = left.high_key
new_right.right_link = left.right_link
left.high_key = split_key
left.right_link = new_right
Practice · Explain the consequences
Practice: Make the trade-off yourself.
Question 1 of 3
Score: 0/3Why can't two threads deadlock on B-Link sibling latches?
Recommended Learning Flow