fix: correct Pebble iterator bounds and use pre-allocated txn prefix bytes#432
Merged
bootjp merged 5 commits intofeature/refactorfrom Mar 25, 2026
Merged
fix: correct Pebble iterator bounds and use pre-allocated txn prefix bytes#432bootjp merged 5 commits intofeature/refactorfrom
bootjp merged 5 commits intofeature/refactorfrom
Conversation
…cated prefix bytes Co-authored-by: bootjp <1306365+bootjp@users.noreply.github.com> Agent-Logs-Url: https://github.com/bootjp/elastickv/sessions/8c736c29-0405-4197-93a2-8f290254f51d
Copilot
AI
changed the title
[WIP] Fix address critical data safety, consistency, and performance issues
fix: correct Pebble iterator bounds and use pre-allocated txn prefix bytes
Mar 25, 2026
bootjp
approved these changes
Mar 25, 2026
Owner
|
@copilot このPRの変更にかかわらず、 golangci-lint をパスさせてください |
bootjp
approved these changes
Mar 25, 2026
…rdinator_abort_test.go, and lsm_store.go Co-authored-by: bootjp <1306365+bootjp@users.noreply.github.com> Agent-Logs-Url: https://github.com/bootjp/elastickv/sessions/aed61b49-9084-425e-bd0e-899be4c0bf9d
…ction - kv/fsm.go: extract decodeLegacyRaftRequest from decodeRaftRequests default case - cmd/server/demo.go: extract setupFSMStore from run function - store/lsm_store.go: extract compactEntryState/shouldDeleteEntry/compactFlushBatch for Compact; extract restoreMVCCEntries for restoreFromStreamingMVCC; extract restoreGobEntries for restoreFromLegacyGob; add hash import - store/mvcc_store.go: lift compactEntry to package scope; extract computeScanCapHint/collectScanResults for ScanAt; extract compactPhase1/compactPhase2 for Compact - store/mvcc_store_concurrency_test.go: extract goroutine bodies into concurrentGetAtWriter/concurrentGetAtReader, scanAtWriter/scanAtScanner, snapshotConsistencyWriter/snapshotConsistencyScanner helpers - kv/lock_resolver.go: fix pre-existing undefined ok/userKey variables by using txnUserKeyFromLockKey; apply gofmt alignment Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…etypeassert, wrapcheck, mnd, gosec, unused) Co-authored-by: bootjp <1306365+bootjp@users.noreply.github.com> Agent-Logs-Url: https://github.com/bootjp/elastickv/sessions/aed61b49-9084-425e-bd0e-899be4c0bf9d
Contributor
Author
Fixed all 23 golangci-lint issues in commit e27d5ab (plus e6ea2b8 for the gci auto-fixes):
Local golangci-lint v2.11.4 now reports 0 issues. |
bootjp
approved these changes
Mar 25, 2026
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.
Two issues in the previous PR: iterator bounds in
GetAt/LatestCommitTSleaked adjacent user keys into the scan range, andtxnLockKey/txnIntentKeyweren't using the pre-allocated prefix byte slices.Iterator upper-bound bug (
store/lsm_store.go)With the
[userKey][8-byte inverted TS]encoding, the old upper boundencodeKey(key, 0) + 0x00=key + \xFF×8 + \x00does not confine iteration to a single user key. Any key wherekeyis a byte-prefix leaks in — e.g. forkey="a", all versions of"ab"satisfy"ab\xFF…" < "a\xFF…\x00"and fall inside the range.Adds a
keyUpperBoundhelper (next lexicographic prefix, standard LSM idiom) and applies it to bothGetAtandLatestCommitTS:In practice the userKey equality check after
SeekGE/Firstwould catch the mismatch, but incorrect bounds mean Pebble may scan unnecessary SST blocks, and conflict checks inLatestCommitTScould return a false negative if the seek lands on a prefix-adjacent key first.txn prefix byte slices (
kv/txn_keys.go)txnLockKeyandtxnIntentKeywere appending the string constants directly instead of the pre-allocatedtxnLockPrefixBytes/txnIntentPrefixBytesslices introduced in the same prior commit:💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.