Skip to content

sstable/colblk,cockroachkvs: fix equalPrefix in KeySeeker.SeekGE#5996

Merged
RaduBerinde merged 1 commit intocockroachdb:masterfrom
RaduBerinde:key-seeker-seek-ge-fix
Apr 24, 2026
Merged

sstable/colblk,cockroachkvs: fix equalPrefix in KeySeeker.SeekGE#5996
RaduBerinde merged 1 commit intocockroachdb:masterfrom
RaduBerinde:key-seeker-seek-ge-fix

Conversation

@RaduBerinde
Copy link
Copy Markdown
Member

Separating this from #5928

Both defaultKeySeeker.SeekGE (sstable/colblk) and cockroachKeySeeker.SeekGE
(cockroachkvs) unconditionally returned equalPrefix=true whenever the seek
key's prefix matched a row in the prefix-bytes column. The helper
seekGEOnSuffix, however, may walk past the matched prefix's last row when
no row in that prefix group has a suffix >= the seek suffix; in that case
it returns the first row of the next prefix group (or one past maxRow).
The caller mislabeled such results as having an equal prefix.

This commit changes seekGEOnSuffix in both keySeekers to also return
whether the resulting row still belongs to the seek key's prefix group
(i.e. whether the binary search stayed strictly below the next prefix
boundary), and propagates that value out of SeekGE.

In existing code, this return value is only used in a specific case
(synthetic suffix), where we pass a bare prefix (which cannot exercise
the bug).

Both defaultKeySeeker.SeekGE (sstable/colblk) and cockroachKeySeeker.SeekGE
(cockroachkvs) unconditionally returned equalPrefix=true whenever the seek
key's prefix matched a row in the prefix-bytes column. The helper
seekGEOnSuffix, however, may walk past the matched prefix's last row when
no row in that prefix group has a suffix >= the seek suffix; in that case
it returns the first row of the next prefix group (or one past maxRow).
The caller mislabeled such results as having an equal prefix.

This commit changes seekGEOnSuffix in both keySeekers to also return
whether the resulting row still belongs to the seek key's prefix group
(i.e. whether the binary search stayed strictly below the next prefix
boundary), and propagates that value out of SeekGE.

In existing code, this return value is only used in a specific case
(synthetic suffix), where we pass a bare prefix (which cannot exercise
the bug).
@RaduBerinde RaduBerinde requested a review from sumeerbhola April 24, 2026 16:23
@RaduBerinde RaduBerinde requested a review from a team as a code owner April 24, 2026 16:24
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

Copy link
Copy Markdown
Collaborator

@sumeerbhola sumeerbhola left a comment

Choose a reason for hiding this comment

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

:lgtm:

@sumeerbhola reviewed 3 files and made 1 comment.
Reviewable status: all files reviewed (commit messages unreviewed), all discussions resolved (waiting on RaduBerinde).

@RaduBerinde
Copy link
Copy Markdown
Member Author

TFTR!

@RaduBerinde RaduBerinde merged commit 521683e into cockroachdb:master Apr 24, 2026
8 checks passed
@RaduBerinde RaduBerinde deleted the key-seeker-seek-ge-fix branch April 24, 2026 18:46
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.

3 participants