Skip to content

fix: stop readers of the latest version from seeing the next version's fast nodes during SaveVersion - #1172

Open
JayT106 wants to merge 8 commits into
cosmos:masterfrom
JayT106:jt/fastnode-commit-window-master
Open

JayT106 wants to merge 8 commits into
cosmos:masterfrom
JayT106:jt/fastnode-commit-window-master

Conversation

@JayT106

@JayT106 JayT106 commented Nov 27, 2026 •

Copy link
Copy Markdown

What

  • nodeDB and the tree read paths: readers of the latest version no longer see the next version's fast nodes during SaveVersion.

Issue

Solution

  • nodeDB tracks which version the fast index can serve; an iterator checks it after opening, Get under the read's lock.
  • During a save, and after a failed one until the next succeeds, iterators and missed Gets on the latest version read the tree; hits stay fast.
  • MemDB: read paths within 0.5% outside a save (10k keys). During one at 200k keys, a missed Get goes 0.46µs → 6.2µs, a 10-key scan 3.3µs → 22.7µs.

…s fast nodes during SaveVersion

Fast nodes are not versioned. A reader of version N could get version N+1 data
through them while SaveVersion ran: the batch may flush fast nodes before the
commit, and the latest version moved in a second lock section after it.

Mark the fast index dirty while fast node changes are uncommitted, move the
latest version in the same lock section as the batch write, and check both
after a fast node miss and after the fast iterator takes its snapshot.

Closes cosmos#1171
…eDB lock

A reader that held an open MemDB iterator and waited for the nodeDB lock
deadlocked with a commit waiting for the MemDB lock.
Commit no longer marks the fast index clean, so a batch commit from
pruning during SaveVersion cannot expose the next version's fast nodes.
@JayT106
JayT106 requested a review from a team as a code owner November 27, 2026 18:01
@greptile-apps

greptile-apps Bot commented Nov 27, 2026

Copy link
Copy Markdown

This PR does not match any of the 1 configured review trigger rule.

@mergify

mergify Bot commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue). If it does not match the queue conditions yet, it enters the queue once it does.

  • Queue this pull request once it meets the queue conditions

…dirty

A failed SaveVersion leaves its flushed fast nodes in the DB, and Rollback does not undo them.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Readers of the latest version can see the next version's fast nodes during SaveVersion

1 participant