fix(hot): MemKvRwTx read cursor now sees queued writes#32
Merged
Conversation
`HotKvRead for MemKvRwTx` previously returned `MemKvCursor` which only sees committed data. This caused read cursors on write transactions to miss pending writes, creating an inconsistency with `raw_get` which already checked queued ops. Change `Traverse` type to `MemKvCursorMut` which merges committed data with queued writes. Also fix a pre-existing bug in `MemKvCursorMut::last_of_k1` where the k1 comparison used full MAX_KEY_SIZE bytes against the shorter encoded key, causing it to always return None. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
HotKvRead for MemKvRwTxnow usesMemKvCursorMutinstead ofMemKvCursor, so read cursors on write transactions see pending (queued) writes — matching the behavior ofraw_getwhich already checked queued ops.MemKvCursorMut::last_of_k1bug: The k1 comparison compared the full MAX_KEY_SIZE (64 bytes) padded key against the shorter encoded key, causinglast_of_k1to always returnNone. Now correctly compares only the relevant prefix, matchingMemKvCursor's implementation.Test plan
cargo clippy -p signet-hot --all-features --all-targetscargo clippy -p signet-hot --no-default-features --all-targetscargo +nightly fmtcargo t -p signet-hot(103 unit tests + 4 integration tests pass)mem_unwind_conformancetest now validates real history index data (previously was a vacuous 0 == 0 comparison since history indices were never built within single transactions)🤖 Generated with Claude Code