kv: fix ReverseScanAt cross-shard ordering when clampToRoutes=false#411
Merged
bootjp merged 3 commits intofeature/s3-implfrom Mar 23, 2026
Merged
kv: fix ReverseScanAt cross-shard ordering when clampToRoutes=false#411bootjp merged 3 commits intofeature/s3-implfrom
bootjp merged 3 commits intofeature/s3-implfrom
Conversation
Merged
…es=false Co-authored-by: bootjp <1306365+bootjp@users.noreply.github.com> Agent-Logs-Url: https://github.com/bootjp/elastickv/sessions/f96f5f26-a7f9-4563-b9a8-db083ce32609
Copilot
AI
changed the title
[WIP] Add S3 adapter to elastickv
kv: fix ReverseScanAt cross-shard ordering when clampToRoutes=false
Mar 23, 2026
Owner
|
@copilot add test code |
…ReverseScanResults Co-authored-by: bootjp <1306365+bootjp@users.noreply.github.com> Agent-Logs-Url: https://github.com/bootjp/elastickv/sessions/845127a7-c957-4c22-8699-b8584a84033d
Contributor
Author
Added in commit
|
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.
reverseScanRoutesAtwithclampToRoutes=false(used for S3 manifest scans spanning multiple shards) concatenated per-route results with a shrinking limit, producing out-of-order output and silently dropping keys when shard ranges interleave in descending keyspace.Changes
reverseScanRoutesAt: whenclampToRoutes=false, fetchlimitresults from every route then merge+sort descending — mirroring the approachscanRoutesAtalready uses for the ascending case. WhenclampToRoutes=true, preserve the original short-circuit onlen(out) >= limit.mergeAndTrimReverseScanResults: new helper symmetric tomergeAndTrimScanResultsbut sorting descending (bytes.Compare > 0).Tests
New tests added in
kv/shard_store_test.go:TestShardStoreReverseScanAt_DescendingOrderAcrossShards: verifies that a nil-start scan (clampToRoutes=false) across two shards returns all keys merged in descending order.TestShardStoreReverseScanAt_LimitAcrossShards: verifies that the top-N keys are correctly selected across shard boundaries (e.g. limit=4 from 3+3 keys picks the 4 largest).TestShardStoreReverseScanAt_SingleShard: single-shard baseline for descending order.TestShardStoreReverseScanAt_IncludesS3ManifestKeysDescending: mirrors the existing forward-scan manifest test — reverse scan over manifest keys returns descending order.TestMergeAndTrimReverseScanResults/_EmptyInput/_WithinLimit/_ExactLimit: unit tests for the new helper covering merge, descending sort, and limit trimming edge cases.📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.