When implementing concurrent B+Trees, release parent latches early and follow rightLink whenever searchKey > highKey.
TL;DR30-second simplified summary▾
Sustains 100k+ concurrent writes/sec without 64-core root lock convoys.
Why Pessimistic Latch Crabbing Stalls 64-Core Servers.
Why this matters: Contrast lock-coupled latch crabbing against B-Link horizontal recovery.
Holding exclusive latches on upper internal nodes blocks every reader and writer traversing that subtree.
| Choice | What it buys | What it costs |
|---|---|---|
| Pessimistic Crabbing | No right-link pointer needed | Serializes writes behind upper-level X-latches |
| Lehman-Yao B-Link | Zero parent-child lock coupling; 100k+ writes/s | Requires High Key + right-sibling pointer per page |
def blink_search(root, key: int):
curr = root
while not curr.is_leaf:
curr.shared_lock()
while curr.right_link is not None and key > curr.high_key:
nxt = curr.right_link
curr.shared_unlock()
curr = nxt
curr.shared_lock()
child = curr.find_child(key)
curr.shared_unlock() # Released BEFORE latching child
curr = child
return curr
Right-Link Split Ordering & Deadlock Freedom.
Why this matters: Guarantee readers never miss a key during a concurrent split.
A splitting writer creates the new right sibling, sets its High Key and rightLink, and links left->right BEFORE updating the parent—ensuring a continuous left-to-right path.
- Problem
- How to allow 64+ concurrent threads to search and insert into a B+Tree simultaneously without holding multi-level exclusive latches.
- Naive Solution
- Use pessimistic latch crabbing: hold parent exclusive latches until verifying the child will not split.
- Why It Fails
- Near-full internal nodes force threads to hold exclusive latches near the root, creating a severe lock convoy.
- Alternatives
- Global tree lock, pessimistic latch crabbing, or Lehman-Yao B-Link Trees with High Keys and right-sibling links.
- Engineering Decision
- Store a High Key and right-sibling link on every page, release parent latches before acquiring child latches, and hop right if key > highKey.
- Trade-Offs
- Adds ~16 bytes per page for High Key + rightLink and requires left-to-right split ordering, but eliminates upper-tree lock convoys.
A reader releases the parent latch and lands on Child Page A for key 45, but a writer just split Child A (highKey=40) and moved 45 to Child B. What prevents a false 'not found'?
public Page descendBLink(Page curr, int key) {
curr.sharedLock();
while (curr.rightLink != null && key > curr.highKey) {
Page right = curr.rightLink;
curr.sharedUnlock();
curr = right;
curr.sharedLock();
}
Page child = curr.findChild(key);
curr.sharedUnlock();
return child;
}
Practice: Make the trade-off yourself.
What two fields enable Lehman-Yao B-Link Trees to release parent latches early?