Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

storage: disable checkUncertainty on failOnMoreRecent in scanner #131093

Merged
merged 2 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion pkg/storage/pebble_mvcc_scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,13 @@ func (p *pebbleMVCCScanner) init(
// because the local uncertainty limit cannot be applied to values with
// future-time timestamps with earlier local timestamps. We are only able
// to skip uncertainty checks if p.ts >= global_uncertainty_limit.
p.checkUncertainty = p.ts.Less(p.uncertainty.GlobalLimit)
//
// We disable checkUncertainty when the scanner is configured with failOnMoreRecent.
// This avoids cases in which a scan would have failed with a WriteTooOldError
// but instead gets an unexpected ReadWithinUncertaintyIntervalError
// See:
// https://github.com/cockroachdb/cockroach/issues/119681
p.checkUncertainty = p.ts.Less(p.uncertainty.GlobalLimit) && !p.failOnMoreRecent
}

// get seeks to the start key exactly once and adds one KV to the result set.
Expand Down
12 changes: 12 additions & 0 deletions pkg/storage/testdata/mvcc_histories/range_tombstone_scans
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,18 @@ scan k=b end=d ts=3 globalUncertaintyLimit=4
scan: "b"-"d" -> <no data>
error: (*kvpb.ReadWithinUncertaintyIntervalError:) ReadWithinUncertaintyIntervalError: read at time 3.000000000,0 encountered previous write with future timestamp 4.000000000,0 within uncertainty interval `t <= (local=0,0, global=0,0)`; observed timestamps: []

run error
scan k=b end=d ts=3 globalUncertaintyLimit=4 failOnMoreRecent
----
scan: "b"-"d" -> <no data>
error: (*kvpb.WriteTooOldError:) WriteTooOldError: write for key "c" at timestamp 3.000000000,0 too old; must write at or above 4.000000000,1

run error
get k=c ts=3 globalUncertaintyLimit=4 failOnMoreRecent
----
get: "c" -> <no data>
error: (*kvpb.WriteTooOldError:) WriteTooOldError: write for key "c" at timestamp 3.000000000,0 too old; must write at or above 4.000000000,1

run ok
scan k=b end=d ts=4 globalUncertaintyLimit=5
----
Expand Down
Loading