-
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: add new CheckSSTConflicts randomized test #98408
base: master
Are you sure you want to change the base?
Conversation
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.
This test is currently failing. I'm hoping it's failing due to #94141 and the test can be used to produce a simpler reproduction of that issue.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @sumeerbhola)
51a3474
to
2b1fec5
Compare
Previously we were missing some cases of range key overlaps with other range keys, or were too eagerly stepping over engine keys that did not conflict with sstable keys, resulting in incorrect stats. This change adds more targeted test cases to TestEvalAddSSTable to test for those previously-unaccounted cases, and fixes them in CheckSSTConflicts. Informs cockroachdb#94140 and cockroachdb#98408. Fixes cockroachdb#94141. 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 @jbowens and @sumeerbhola)
pkg/storage/meta/run.go
line 58 at r2 (raw file):
// each item. It's intended to be used with a function returned by Weighted, // whhere the item itself is func(rng *rand.Rand). func Generate[I any](rng *rand.Rand, n int, fn func(*rand.Rand) func(*rand.Rand) I) []I {
I don't get the generic-ness of ItemWeight
if we're only going to use them with this function which assumes that the items are a func(*rand.Rand) I
.
Can't we have a GenWithWeight[I] struct { Gen func(*rand.Rand) I; Weight int }
and pass a ...GenWithWeight[I]
to Generate
? Are we envisioning any other kind of usage?
98426: storage: Fix CheckSSTConflicts stats calculations r=erikgrinaker a=itsbilal Previously we were missing some cases of range key overlaps with other range keys, or were too eagerly stepping over engine keys that did not conflict with sstable keys, resulting in incorrect stats. This change adds more targeted test cases to TestEvalAddSSTable to test for those previously-unaccounted cases, and fixes them in CheckSSTConflicts. Informs #94140 and #98408. Fixes #94141. Epic: none Release note: None Co-authored-by: Bilal Akhtar <[email protected]>
2b1fec5
to
d15ea19
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.
@itsbilal — looks like this is still failing after rebasing over master, including #98426.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @RaduBerinde and @sumeerbhola)
pkg/storage/meta/run.go
line 58 at r2 (raw file):
Are we envisioning any other kind of usage?
Yes. Picking among weighted items is expected to be useful during generation of the individual options themselves as well. For example, the Pebble metamorphic tests pick among IterOptions.KeyTypes enum values.
d15ea19
to
4c0343b
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.
Looks like this one is still failing, even if kvnemesis isn't 🤔
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @RaduBerinde and @sumeerbhola)
@jbowens I realized that the randomized test produces sst range keys that are of different timestamps. While the function supports that, it's unlikely (impossible I believe?) for that to happen with practical uses of |
I'm forgetting, do we support RESTORE-ing with history, or only backing up with history and restoring the most recent values? If we RESTORE with history, that must use AddSSTable without setting the I suppose the disaggregated storage RESTORE will need to restore with history or perform read-time timestamp rewriting, but that'll be for 23.2 in any case. |
@itsbilal I asked in #disaster-recovery and it sounds like both cluster-to-cluster streaming and tenant restores both use AddSSTable with varied timestamps. |
Previously, the nexting logic around both iterators being at a range key and not a point key was flawed in that we'd miss ext points that were in between the current and next sst keys, when we'd next both of them. This change addresses that. It also addresses other miscellaneous corner cases around stats calculations with overlapping sst/engine range keys and point keys. All these bugs were found with the upcoming CheckSSTConflicts randomized test in cockroachdb#98408. Epic: none Release note: None
Previously, the nexting logic around both iterators being at a range key and not a point key was flawed in that we'd miss ext points that were in between the current and next sst keys, when we'd next both of them. This change addresses that. It also addresses other miscellaneous corner cases around stats calculations with overlapping sst/engine range keys and point keys. All these bugs were found with the upcoming CheckSSTConflicts randomized test in cockroachdb#98408. Epic: none Release note: None
Previously, the nexting logic around both iterators being at a range key and not a point key was flawed in that we'd miss ext points that were in between the current and next sst keys, when we'd next both of them. This change addresses that. It also addresses other miscellaneous corner cases around stats calculations with overlapping sst/engine range keys and point keys. All these bugs were found with the upcoming CheckSSTConflicts randomized test in cockroachdb#98408. Epic: none Release note: None
…99239 #99263 #99278 98980: kvcoord: Add metric to keep track of restarted ranges in rangefeed r=miretskiy a=miretskiy Add a `distsender.rangefeed.restart_ranges` metric to keep track of the number of ranges restarted due to transient error. Epic: CRDB-25044 Release note: None 99069: storage/cloud: correct the flag name in implicit credentials error message r=rhu713 a=taroface When `--external-io-disable-implicit-credentials` is set and the user issues a command with `AUTH=implicit`, the resulting error message has the wrong flag name (`disable` is left out). Searching for that flag name in the docs doesn't return any results. The flag name is corrected in this PR. Release note: none Release justification: CLI bug 99077: changefeedccl: Allow timeout override r=miretskiy a=miretskiy Add timeout URL parameter for schema registry URIs. Prior to this change, all schema registry calls used default time out of 3 seconds. This PR increases the timeout to 30 seconds, and allows timeout to be specified via `timeout=T` URL parameter. Informs https://github.com/cockroachlabs/support/issues/2173 Release note (enterprise change): AVRO schema registry URI allow additional `timeout=T` query parameter to change the default timeout for contacting schema registry. 99141: storage: CheckSSTConflict fix for nexting over overlapping points r=jbowens a=itsbilal Previously, the nexting logic around both iterators being at a range key and not a point key was flawed in that we'd miss ext points that were in between the current and next sst keys, when we'd next both of them. This change addresses that. It also addresses other miscellaneous corner cases around stats calculations with overlapping sst/engine range keys and point keys. All these bugs were found with the upcoming CheckSSTConflicts randomized test in #98408. Epic: none Release note: None 99146: opt: speed up lookup constraint builder r=mgartner a=mgartner #### opt: add benchmark with many lookup joins This commit adds an optimizer benchmark that explores many lookup joins. It explores many potential lookup joins that do not ultimately get added to the memo, as well as many lookup joins that do get added to the memo. Release note: None #### opt: split HasSingleColumnConstValues into two functions This commit splits HasSingleColumnConstValues into two functions - one that returns a boolean if a constraint set constrains a single column to a set of constant, non-null values, and another function that returns the constant values. The former is more efficient when the only the boolean is needed. Release note: None #### opt: simplify lookup join constraint builder This commit reduces computation and allocations when attempting to build lookup join constraints by performing a simple column ID equality before more complex computations and allocations. Release note: None #### opt: reduce allocations when building lookup join constraints During the construction of lookup join constraints, two allocations of a `opt.ColList` have been combined into a single allocation, and allocation of a `memo.FiltersExpr` to store remaining filters is now only performed if necessary. Release note: None These changes offer a nice speedup for the newly added benchmark: ``` name old time/op new time/op delta SlowQueries/slow-query-1-10 15.8ms ± 1% 15.7ms ± 1% ~ (p=0.690 n=5+5) SlowQueries/slow-query-2-10 220ms ± 0% 219ms ± 0% ~ (p=0.095 n=5+5) SlowQueries/slow-query-3-10 63.0ms ± 1% 62.4ms ± 0% -0.98% (p=0.008 n=5+5) SlowQueries/slow-query-4-10 1.70s ± 1% 1.38s ± 0% -19.22% (p=0.008 n=5+5) name old alloc/op new alloc/op delta SlowQueries/slow-query-1-10 7.04MB ± 0% 6.98MB ± 0% -0.79% (p=0.008 n=5+5) SlowQueries/slow-query-2-10 48.7MB ± 0% 48.7MB ± 0% -0.11% (p=0.008 n=5+5) SlowQueries/slow-query-3-10 45.1MB ± 0% 44.9MB ± 0% -0.55% (p=0.008 n=5+5) SlowQueries/slow-query-4-10 878MB ± 0% 737MB ± 0% -16.03% (p=0.008 n=5+5) name old allocs/op new allocs/op delta SlowQueries/slow-query-1-10 76.1k ± 0% 75.8k ± 0% -0.38% (p=0.008 n=5+5) SlowQueries/slow-query-2-10 401k ± 0% 400k ± 0% -0.25% (p=0.008 n=5+5) SlowQueries/slow-query-3-10 390k ± 0% 389k ± 0% -0.21% (p=0.008 n=5+5) SlowQueries/slow-query-4-10 18.2M ± 0% 17.4M ± 0% -4.44% (p=0.008 n=5+5) ``` Epic: None 99154: ui: stop polling in stmt fingerprint details page, change default sort on stmts r=maryliag a=xinhaoz See individual commits. https://www.loom.com/share/17569db4a0c04a968dabbc4421d429bf 99169: kv: unflake TestDelegateSnapshot r=kvoli a=andrewbaptist Fixes: #96841 Fixes: #96525 Previously this test would assume that all snapshots came from the sending of snapshots through the AdminChangeReplicasRequest which end up as type OTHER. However occassionally we get a spurious raft snapshot which makes this test flaky. This change ignores any raft snapshots that are sent. Epic: none Release note: None 99172: upgrades: hardcode descriptors in system_rbr_indexes r=JeffSwenson a=JeffSwenson Previously, if a change was made to the system.sql_instances, system.lease, or system.sqlliveness bootstrap schema, it would change the behavior of the upgrade attached to the V23_1_SystemRbrReadNew version gate. Now, the content of the descriptors is hard coded in the upgrade so that the behavior is not accidentally changed in the future. Fixes: #99074 Release note: None 99180: builtins: add builtin functions which cast to OID to the distSQL block list r=michae2,cucaroach a=msirek Distributed SQL which executes functions or casts to OID rely on `planner` receiver functions to execute internal SQL to get information about the OID from system tables. If these casts occur on a remote processor, the `planner` is not accessible and a dummy planner is used, which does not implement these receiver functions. To prevent internal errors, these casts or problem functions are added to a distSQL block list by `distSQLExprCheckVisitor`. A cast to an OID can also be done via a builtin function of the same name as the target type, e.g. `regproc`. These builtins do not currently have `DistsqlBlocklist` set, allowing distributed execution. The solution is to mark `DistsqlBlocklist` as true for any builtin function which casts to an OID type. Fixes #98373 Release note: None 99239: appstats: fix percentile greater than max latency r=maryliag a=maryliag Part Of #99070 When an execution happens, its latency is added to a stream and then ordered so percentiles can be queried. When getting the percentile values, we don't have the timestamp of when each value was added, meaning when we query the stream we could be getting values from a previous aggregation timestamp, if the current windows has very few executions (the stream has a limit, so we only have the most recent execution, but if the statement is not run frequently this stream can have old data). The way this information is stored will need to be changed, but for now a patchy solution was added so we don't have the case where we show percentiles greater than the actual max. Release note (bug fix): Add a check so percentiles are never greater than the max latency value. 99263: roachtest: copyfrom fix cluster package install r=aliher1911 a=aliher1911 When installing packages, look on cluster remoteness as proxy for arch instead of roachtest runtime which is runs different arch. Epic: none Release note: None 99278: sql: fix update helper optional from clause r=rytaft a=lyang24 fixes #98662 sanity testing: output <img width="265" alt="Screen Shot 2023-03-22 at 1 01 10 PM" src="https://user-images.githubusercontent.com/20375035/227027849-34f34bb4-d52b-4de4-8a5b-456ee8b27f1b.png"> sample sql <img width="874" alt="Screen Shot 2023-03-22 at 1 10 15 PM" src="https://user-images.githubusercontent.com/20375035/227027874-3f6515f4-fdbe-4c64-9d6f-03eb9b5c67f3.png"> Release note (sql change): fix helper message on update sql to correctly position the optional from cause. Co-authored-by: Yevgeniy Miretskiy <[email protected]> Co-authored-by: Ryan Kuo <[email protected]> Co-authored-by: Bilal Akhtar <[email protected]> Co-authored-by: Marcus Gartner <[email protected]> Co-authored-by: Xin Hao Zhang <[email protected]> Co-authored-by: Andrew Baptist <[email protected]> Co-authored-by: Jeff <[email protected]> Co-authored-by: Mark Sirek <[email protected]> Co-authored-by: maryliag <[email protected]> Co-authored-by: Oleg Afanasyev <[email protected]> Co-authored-by: Eric.Yang <[email protected]>
Previously, the nexting logic around both iterators being at a range key and not a point key was flawed in that we'd miss ext points that were in between the current and next sst keys, when we'd next both of them. This change addresses that. It also addresses other miscellaneous corner cases around stats calculations with overlapping sst/engine range keys and point keys. All these bugs were found with the upcoming CheckSSTConflicts randomized test in #98408. Epic: none Release note: None
4c0343b
to
524b9e5
Compare
Fixes some additional cases of stats divergence in CheckSSTConflicts' handling of inbound sst range key fragments that shadow points in engine and fragment existing engine range keys. Found by randomized test in #98408. Epic: none Release note: None
8d3cbdb
to
443368c
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.
I'd sometimes see this error in this test, which would cause a panic and fail the test:
I fixed this—there was a sequence of during generation that could leave rangeStart
unset, generating a key with a NUL key start bound.
With
./dev test -f TestCheckSSTConflictsRandomized pkg/storage --stress
it looks like we still have at least one more stats calculation issue :(
Reviewable status: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @itsbilal, @RaduBerinde, and @sumeerbhola)
This came up in the storage weekly, but the stats failures I'm seeing are involving the same key being present in the sst at different timestamps, of which one has a conflict but we don't error on the conflict (and I believe this function has never errored on this type of a conflict). Here's one example:
We should have errored on the ni@970 conflict but we didn't, instead our stats are incorrect as it just assumed ni@1035 is the only inbound key with the prefix "ni". Asking disaster recovery on whether this is possible in the first place. |
In addition, I noticed that there's a subtle bug in how we set start and end when calling
|
Took a look at all uses of Knowing this, I think we should update the randomized test to only output one TS per user key for point keys. |
There's a lot of subtlety there in the |
443368c
to
93983fd
Compare
8994dd3
to
76fdfa2
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.
4417 runs so far, 0 failures, over 21m55s
😎
Thanks for your help here @itsbilal!
Reviewable status: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @itsbilal, @RaduBerinde, and @sumeerbhola)
76fdfa2
to
caba2d1
Compare
TFTRs! bors r+ |
Build failed (retrying...): |
On CI run:
bors r- |
Canceled. |
caba2d1
to
52ebe94
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.
LGTM
Does the failing seed pass with this change?
Yes, although stressing locally again uncovered another failure:
This might be a consequence of the SST defining
|
@jbowens At first glance that looks like a genuine failure i.e we should be returning a WriteTooOld error (I think) if a point is sliding under an existing range key. But maybe we aren't because it's also under an existing sst range key, which is an idempotent write with the existing ext range key (i.e. same timestamp). Idempotent writes cause all sorts of special cases and are a headache to handle in I imagine the stats failure would occur even if the point didn't exist, as it looks like it's about the handling of partially-idempotent range keys merging into existing range keys. The point seems to be correctly accounted for (even if maybe it should be a conflict). |
Move the storage test formatStats function onto the MVCCStats type itself in preparation for using it in additional places. Epic: None Release note: None
Callers of CheckSSTConflicts pass in start and end boundaries for the sstable. Previously, these were passed as MVCCKeys, although the end key's timestamp was ignored. This resulted in confusing semantics whereby the end boundary was interpreted as exclusive end bound of `end.Key`. Epic: none Release note: none
Add a new randomized test exercising CheckSSTConflicts. Additionally, sketch out a `meta` package to aid in writing randomized tests like this one. In the future, this package may be extracted to the cockroachdb/metamorphic repository. Epic: None Release note: None
52ebe94
to
02b91dc
Compare
enginepb: add MVCCStats.Formatted
Move the storage test formatStats function onto the MVCCStats type itself in
preparation for using it in additional places.
storage: change CheckSSTConflicts start and end types
Callers of CheckSSTConflicts pass in start and end boundaries for the sstable.
Previously, these were passed as MVCCKeys, although the end key's timestamp was
ignored. This resulted in confusing semantics whereby the end boundary was
interpreted as exclusive end bound of
end.Key
.storage: add new CheckSSTConflicts randomized test
Add a new randomized test exercising CheckSSTConflicts. Additionally, sketch
out a
meta
package to aid in writing randomized tests like this one. In thefuture, this package may be extracted to the cockroachdb/metamorphic
repository.
Epic: None
Release note: None
Informs #94141.
Informs cockroachdb/pebble#2086.