Skip to main content
← PROBLEMS / SYSTEM-DESIGN
An end-to-end domain learning journey

Eliminating 64-Core B+Tree Latch Convoys
with Lehman-Yao B-Link Splits.

A 64-core index engine stalls under 100k writes/sec due to pessimistic root-to-leaf exclusive latch crabbing; refactor descent and split ordering into a Lehman-Yao B-Link Tree.
Start the journey2 stages· Last modified Dec 2, 2026
FIRST PRINCIPLES. PRODUCTION SCALE.
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
ChoiceWhat it buysWhat it costs
Pessimistic CrabbingSimpler splitSevere 64-core lock convoy
B-Link Single-Page LatchZero multi-level lock couplingMust 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.

Reader ThreadLeaf A (Splitting)Leaf B (New Right)1. Writer links A -> B beforeparent update2. Reader sees key > A.highKey3. Reader hops rightLink to B andfinds key
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/3

Why can't two threads deadlock on B-Link sibling latches?

Recommended Learning Flow