-
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
sqlstats: add retries to stats test on locked table #119977
sqlstats: add retries to stats test on locked table #119977
Conversation
Previously, the `TestSQLStatsReadLimitSizeOnLockedTable` test would fail very occasionally due to a rare scenario. When stats are written, they contain a column that's a hashed shard index. It's expected that statements are uniformly distributed across this shard, but that's not guaranteed. Later in the test we check a random shard to make sure its stats count exceeds a minimum of 1 (because we place a total lower bound of 8 in the cluster setting, which is then divided by 8 to derive the per-shard limit). This case will occasionally fail if the random shard that's picked happens to only contain a single statement within. This change modifies the loop at the end of the test to expect a `false` value and make sure to get at least a single `true` result after 3 iterations, instead of requiring 3 `true` results every single time. The requirement that the queries run despite contention will still stand since we'll return an error in that case. Resolves: cockroachdb#119067 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.
Nice!
@@ -705,7 +704,7 @@ func TestSQLStatsReadLimitSizeOnLockedTable(t *testing.T) { | |||
|
|||
// Set table size check interval to .0000001 second. So the next check doesn't | |||
// use the cached value. | |||
sqlConn.Exec(t, "SET CLUSTER SETTING sql.stats.limit_table_size_check.interval='.0000001s'") | |||
persistedsqlstats.SQLStatsLimitTableCheckInterval.Override(ctx, &s.ClusterSettings().SV, time.Nanosecond) |
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.
Why did we need to override this instead of using the set statement above?
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.
The new code does the same thing. Override just sets the setting value directly.
This is an unnecessary change but one that simplifies test execution by removing the need for a full SQL parse/exec loop when we have the ability to set the value directly.
TFTR bors r=xinhaoz |
Build succeeded: |
Previously, the
TestSQLStatsReadLimitSizeOnLockedTable
test would fail very occasionally due to a rare scenario. When stats are written, they contain a column that's a hashed shard index. It's expected that statements are uniformly distributed across this shard, but that's not guaranteed. Later in the test we check a random shard to make sure its stats count exceeds a minimum of 1 (because we place a total lower bound of 8 in the cluster setting, which is then divided by 8 to derive the per-shard limit). This case will occasionally fail if the random shard that's picked happens to only contain a single statement within.This change modifies the loop at the end of the test to expect a
false
value and make sure to get at least a singletrue
result after 3 iterations, instead of requiring 3true
results every single time. The requirement that the queries run despite contention will still stand since we'll return an error in that case.Resolves: #119067
Epic: None
Release note: None