Skip to content

Fix shard reverse scan ordering, GroupID dedup, pinReadTS nil panic, and leader S3 map overwrite#412

Merged
bootjp merged 2 commits intofeature/s3-implfrom
copilot/sub-pr-396
Mar 23, 2026
Merged

Fix shard reverse scan ordering, GroupID dedup, pinReadTS nil panic, and leader S3 map overwrite#412
bootjp merged 2 commits intofeature/s3-implfrom
copilot/sub-pr-396

Conversation

Copy link
Contributor

Copilot AI commented Mar 23, 2026

Four correctness issues identified in review: cross-shard reverse scans could return unsorted results for small result sets, the clampToRoutes=false path could redundantly scan the same shard after a range split, pinReadTS returned nil causing panics on defer readPin.Release(), and follower nodes could overwrite the leader's S3 endpoint mapping.

Changes

  • mergeAndTrimReverseScanResults (kv/shard_store.go): Sort descending unconditionally before the limit check — previously sort was skipped when len(out) <= limit, silently breaking key order for small cross-shard results.

  • reverseScanRoutesAt GroupID dedup (kv/shard_store.go): Track seenGroups in the clampToRoutes=false path and skip routes sharing an already-scanned GroupID. After a range split both halves inherit the same GroupID, causing the backing shard to be scanned twice and producing duplicate KV pairs.

  • pinReadTS no-op token (adapter/s3.go): Return &kv.ActiveTimestampToken{} instead of nil when readTracker is unconfigured. ActiveTimestampToken.Release() is a safe no-op on a zero value, so callers can unconditionally defer readPin.Release() without panic.

  • NewS3Server leader map guard (adapter/s3.go): Only populate leaderS3[leader] when the key is absent. Previously, a follower constructing NewS3Server with its own s3Addr would overwrite the leader's correctly-mapped endpoint, misrouting proxied requests.


⌨️ Start Copilot coding agent tasks without leaving your editor — available in VS Code, Visual Studio, JetBrains IDEs and Eclipse.

…lts, dedup by GroupID, pinReadTS no-op token, guard leader S3 map entry

Co-authored-by: bootjp <1306365+bootjp@users.noreply.github.com>
Agent-Logs-Url: https://github.com/bootjp/elastickv/sessions/2f32e04f-12e2-4392-9ee8-2f1291e6b67f
Copilot AI changed the title [WIP] Add S3 adapter to elastickv with routing support Fix shard reverse scan ordering, GroupID dedup, pinReadTS nil panic, and leader S3 map overwrite Mar 23, 2026
Copilot AI requested a review from bootjp March 23, 2026 08:58
@bootjp bootjp marked this pull request as ready for review March 23, 2026 08:58
@bootjp bootjp merged commit ca7a3b6 into feature/s3-impl Mar 23, 2026
4 checks passed
@bootjp bootjp deleted the copilot/sub-pr-396 branch March 23, 2026 08:58

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [golangci] reported by reviewdog 🐶
if clampToRoutes has complex nested blocks (complexity: 5) (nestif)

if clampToRoutes {

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.

2 participants