Skip to content

crl-release-26.1: rowblk: fix IsLowerBound to account for synthetic suffix#6084

Merged
RaduBerinde merged 1 commit into
cockroachdb:crl-release-26.1from
RaduBerinde:rowblk-lower-bound-fix-26.1
May 27, 2026
Merged

crl-release-26.1: rowblk: fix IsLowerBound to account for synthetic suffix#6084
RaduBerinde merged 1 commit into
cockroachdb:crl-release-26.1from
RaduBerinde:rowblk-lower-bound-fix-26.1

Conversation

@RaduBerinde

Copy link
Copy Markdown
Member

Iter.firstUserKey has the synthetic prefix prepended but the on-disk
suffix is preserved; suffix replacement is only applied per-returned key
via maybeReplaceSuffix. Comparing firstUserKey directly against the
probe could return true even though the iterator's actual first key
(after synthetic suffix replacement) sorts strictly less than the probe,
violating the blockiter.Data.IsLowerBound contract.

When a synthetic suffix is in effect, only compare the prefix portion of
firstUserKey and require it to be strictly greater than the probe. The
contract permits false negatives, so this conservative comparison is
sound and avoids reasoning about the unknown suffix.

Adds TestIsLowerBoundRandomized which cross-checks IsLowerBound
against First() across random blocks and transform combinations, and
documents the transform state of firstUserKey.

`Iter.firstUserKey` has the synthetic prefix prepended but the on-disk
suffix is preserved; suffix replacement is only applied per-returned key
via `maybeReplaceSuffix`. Comparing `firstUserKey` directly against the
probe could return true even though the iterator's actual first key
(after synthetic suffix replacement) sorts strictly less than the probe,
violating the `blockiter.Data.IsLowerBound` contract.

When a synthetic suffix is in effect, only compare the prefix portion of
`firstUserKey` and require it to be strictly greater than the probe. The
contract permits false negatives, so this conservative comparison is
sound and avoids reasoning about the unknown suffix.

Adds `TestIsLowerBoundRandomized` which cross-checks `IsLowerBound`
against `First()` across random blocks and transform combinations, and
documents the transform state of `firstUserKey`.
@RaduBerinde RaduBerinde requested a review from sumeerbhola May 27, 2026 15:39
@RaduBerinde RaduBerinde requested a review from a team as a code owner May 27, 2026 15:39
@cockroach-teamcity

Copy link
Copy Markdown
Member

This change is Reviewable

@RaduBerinde RaduBerinde merged commit e675ee2 into cockroachdb:crl-release-26.1 May 27, 2026
7 checks passed
@RaduBerinde RaduBerinde deleted the rowblk-lower-bound-fix-26.1 branch May 27, 2026 17:07
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