-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Conversation
It looks like your PR touches production code but doesn't add or edit any test code. Did you consider adding tests to your PR? 🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed all commit messages.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @tbg)
pkg/storage/pebble_mvcc_scanner.go
line 890 at r1 (raw file):
p.mostRecentKey = append(p.mostRecentKey, p.curUnsafeKey.Key...) } // We don't have to fall through to `p.checkUncertainty` because FIXME.
We don't have to fall through to p.checkUncertainty
because we are already considering any key that is more recent to be a write-write conflict which will cause a write-too-old error to be thrown. Uncertainty checks are only needed if we would otherwise ignore keys that are more recent.
Here, we could return a WriteTooOld error immediately, but we defer that through mostRecentTS
so that we return the maximum conflicting timestamp. We are trying to do the same thing below in processRangeKeys
, but notice that there's no early return in the p.failOnMoreRecent
case (we don't want an early return, but a continue
or an else if
would work). As a result, the deferred-but-preferred error case loses out to the immediate-but-less-preferred case.
This does raise the question of whether we should actually make p.failOnMoreRecent
and p.checkUncertainty
mutually exclusive. We could set checkUncertainty
to false when failOnMoreRecent
is set to true, so that we don't need to rely on the logic in each of these functions getting it right. This would be easy to do in pebbleMVCCScanner.init
when setting checkUncertainty
.
Noticed while reviewing cockroachdb#131093. This commit fixes pebbleMVCCScanner to set the correct key for the mostRecentKey field when a locking read encounters multiple keys with more recent timestamps. These keys were added to WriteTooOld error in 52c6b1b, which had previously only been carrying the maximum conflicting timestamp. They are currently only used for debugging. Before this fix, we would always return the first conflicting key, even though we correctly returned the maximum conflicting timestamp. Epic: None Release note: None
131220: storage: set correct key in WriteTooOld error from pebbleMVCCScanner r=nvanbenschoten a=nvanbenschoten Noticed while reviewing #131093. This commit fixes `pebbleMVCCScanner` to set the correct key for the `mostRecentKey` field when a locking read encounters multiple keys with more recent timestamps. These keys were added to `WriteTooOldError` in 52c6b1b, which had previously only been carrying the maximum conflicting timestamp. They are currently only used for debugging. Before this fix, we would always return the first conflicting key, even though we correctly returned the maximum conflicting timestamp. I'm planning to backport this to each release branch to avoid any confusing during debugging odysseys, but could be convinced that doing so is not worth the (minimal) risk. Epic: None Release note: None Co-authored-by: Nathan VanBenschoten <[email protected]>
Noticed while reviewing #131093. This commit fixes pebbleMVCCScanner to set the correct key for the mostRecentKey field when a locking read encounters multiple keys with more recent timestamps. These keys were added to WriteTooOld error in 52c6b1b, which had previously only been carrying the maximum conflicting timestamp. They are currently only used for debugging. Before this fix, we would always return the first conflicting key, even though we correctly returned the maximum conflicting timestamp. Epic: None Release note: None
Noticed while reviewing #131093. This commit fixes pebbleMVCCScanner to set the correct key for the mostRecentKey field when a locking read encounters multiple keys with more recent timestamps. These keys were added to WriteTooOld error in 52c6b1b, which had previously only been carrying the maximum conflicting timestamp. They are currently only used for debugging. Before this fix, we would always return the first conflicting key, even though we correctly returned the maximum conflicting timestamp. Epic: None Release note: None
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @nvanbenschoten)
pkg/storage/pebble_mvcc_scanner.go
line 890 at r1 (raw file):
Previously, nvanbenschoten (Nathan VanBenschoten) wrote…
We don't have to fall through to
p.checkUncertainty
because we are already considering any key that is more recent to be a write-write conflict which will cause a write-too-old error to be thrown. Uncertainty checks are only needed if we would otherwise ignore keys that are more recent.Here, we could return a WriteTooOld error immediately, but we defer that through
mostRecentTS
so that we return the maximum conflicting timestamp. We are trying to do the same thing below inprocessRangeKeys
, but notice that there's no early return in thep.failOnMoreRecent
case (we don't want an early return, but acontinue
or anelse if
would work). As a result, the deferred-but-preferred error case loses out to the immediate-but-less-preferred case.This does raise the question of whether we should actually make
p.failOnMoreRecent
andp.checkUncertainty
mutually exclusive. We could setcheckUncertainty
to false whenfailOnMoreRecent
is set to true, so that we don't need to rely on the logic in each of these functions getting it right. This would be easy to do inpebbleMVCCScanner.init
when settingcheckUncertainty
.
Done. I still need to add a test.
6fae54e
to
a17d93e
Compare
Epic: none Release note: None
It was possible for reads with failOnMoreRecent to hit a ReadWithinUncertaintyIntervalError instead of the desired WriteTooOldError. This commit disables uncertainty checks when failOnMoreRecent is active, as the latter is a stronger check anyway. Fixes cockroachdb#119681. Fixes cockroachdb#131005. Epic: none Release note: None
a17d93e
to
10664ba
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @nvanbenschoten)
pkg/storage/pebble_mvcc_scanner.go
line 890 at r1 (raw file):
Previously, tbg (Tobias Grieger) wrote…
Done. I still need to add a test.
Done.
Noticed while reviewing cockroachdb#131093. This commit fixes pebbleMVCCScanner to set the correct key for the mostRecentKey field when a locking read encounters multiple keys with more recent timestamps. These keys were added to WriteTooOld error in 52c6b1b, which had previously only been carrying the maximum conflicting timestamp. They are currently only used for debugging. Before this fix, we would always return the first conflicting key, even though we correctly returned the maximum conflicting timestamp. Epic: None Release note: None
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 2 of 2 files at r2, 2 of 2 files at r3, all commit messages.
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @tbg)
bors r+ |
131093: storage: disable checkUncertainty on failOnMoreRecent in scanner r=tbg a=tbg It was possible for reads with failOnMoreRecent to hit a ReadWithinUncertaintyIntervalError instead of the desired WriteTooOldError. This commit disables uncertainty checks when failOnMoreRecent is active, as the latter is a stronger check anyway. Fixes #119681. Fixes #131005. Epic: none Release note: None Co-authored-by: Tobias Grieger <[email protected]>
Build failed: |
🤷🏽 bors r+ |
131093: storage: disable checkUncertainty on failOnMoreRecent in scanner r=tbg a=tbg It was possible for reads with failOnMoreRecent to hit a ReadWithinUncertaintyIntervalError instead of the desired WriteTooOldError. This commit disables uncertainty checks when failOnMoreRecent is active, as the latter is a stronger check anyway. Fixes #119681. Fixes #131005. Epic: none Release note: None Co-authored-by: Tobias Grieger <[email protected]>
Build failed: |
bors retry |
It was possible for reads with failOnMoreRecent to hit a
ReadWithinUncertaintyIntervalError instead of the desired
WriteTooOldError. This commit disables uncertainty checks when
failOnMoreRecent is active, as the latter is a stronger check anyway.
Fixes #119681.
Fixes #131005.
Epic: none
Release note: None