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

workload/schemachanger: use show cluster settings for version #99162

Closed
wants to merge 1 commit into from

Conversation

fqazi
Copy link
Collaborator

@fqazi fqazi commented Mar 21, 2023

Previously, we would do SHOW CLUSTER SETTING version, which could block until an upgrade occurred. This statement could also timeout, if the upgrade between versions took a long time. To address this, this patch will use
SHOW CLUSTER SETTINGS with a where clause.

Fixes: #99115

Release note: None

Previously, we would do SHOW CLUSTER SETTING version,
which could block until an upgrade occurred. This statement
could also timeout, if the upgrade between versions took
a long time. To address this, this patch will use
SHOW CLUSTER SETTINGS with a where clause.

Fixes: cockroachdb#99115

Release note: None
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@fqazi fqazi marked this pull request as ready for review March 22, 2023 00:47
@fqazi fqazi requested a review from a team as a code owner March 22, 2023 00:47
@fqazi fqazi requested review from herkolategan, srosenberg and a team and removed request for a team March 22, 2023 00:47
Copy link
Contributor

@chengxiong-ruan chengxiong-ruan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Contributor

@renatolabs renatolabs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

I started a 100-run of this test on this branch this morning, mind if we wait for that to finish before merging? (Unless you already ran something similar on your end).

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @herkolategan and @srosenberg)

@fqazi
Copy link
Collaborator Author

fqazi commented Mar 22, 2023

@renatolabs Thanks, I'm gonna wait for that

@renatolabs
Copy link
Contributor

Saw one failure:

"message": "***UNEXPECTED COMMIT ERROR; Received an unexpected commit error: ERROR: write-job-info-delete: relation \"system.job_info\" does not exist (SQLSTATE 42P01)",

🤔

@fqazi
Copy link
Collaborator Author

fqazi commented Mar 22, 2023

@renatolabs Let me chase this with the jobs team think we have a bug with concurrent DDL

@renatolabs
Copy link
Contributor

99162_artifacts.zip

@fqazi
Copy link
Collaborator Author

fqazi commented Mar 22, 2023

The only failure being seen here intermittently is: #99241. I'll wait for Aditya to merge a fix first

@@ -3689,7 +3689,11 @@ func isClusterVersionLessThan(
ctx context.Context, tx pgx.Tx, targetVersion roachpb.Version,
) (bool, error) {
var clusterVersionStr string
row := tx.QueryRow(ctx, `SHOW CLUSTER SETTING version`)
// Directly querying the cluster version with SHOW CLUSTER
// SETTING version isn't safe, since it will wait for any
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you point me at that code? Is that new behavior? I'm also seeing a flake in #99459 that seems like the same thing, but we had that test for years so I'm wondering which PR changed semantics and whether that was intentional.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tbg This is not a new change, but linked to the behaviour we have inside: getCurrentEncodedVersionSettingValue. We have some long-running upgrade that exceeds 2 minutes. Or that's what my theory here was, it's possible we have a hang too during the upgrade, which would be horrible. But we were stuck on the fence version about 2 minutes which is bad :(

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not PR author, just looking at the code, but i see that show cluster setting will fail if local value != queried value from settings table (by searching the test error), while show settings seem to be delegating to querying crdb_internal.cluster_settings which doesn't check local values? That's my best guess.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The intent was for SHOW CLUSTER VERSION to guarantee that the version on disk and in memory is synced up, indicating that the upgrade is complete. Fence versions only get updated in memory, so this is probably by design.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This bit basically

return retry.WithMaxAttempts(ctx, retry.Options{}, math.MaxInt32, func() error {
return p.execCfg.InternalDB.Txn(ctx, func(ctx context.Context, txn isql.Txn) error {
datums, err := txn.QueryRowEx(
ctx, "read-setting",
txn.KV(),
sessiondata.RootUserSessionDataOverride,
"SELECT value FROM system.settings WHERE name = $1", name,
)
if err != nil {
return err
}
var kvRawVal []byte
if len(datums) != 0 {
dStr, ok := datums[0].(*tree.DString)
if !ok {
return errors.New("the existing value is not a string")
}
kvRawVal = []byte(string(*dStr))
} else if !p.execCfg.Codec.ForSystemTenant() {
// The tenant clusters in 20.2 did not ever initialize this value
// and utilized this hard-coded value instead. In 21.1, the builtin
// which creates tenants sets up the cluster version state. It also
// is set when the version is upgraded.
tenantDefaultVersion := clusterversion.ClusterVersion{
Version: roachpb.Version{Major: 20, Minor: 2},
}
encoded, err := protoutil.Marshal(&tenantDefaultVersion)
if err != nil {
return errors.WithAssertionFailure(err)
}
kvRawVal = encoded
} else {
// There should always be a version saved; there's a migration
// populating it.
return errors.AssertionFailedf("no value found for version setting")
}
localRawVal := []byte(s.Get(&st.SV))
if !bytes.Equal(localRawVal, kvRawVal) {
// NB: errors.Wrapf(nil, ...) returns nil.
// nolint:errwrap
return errors.Errorf(
"value differs between local setting (%v) and KV (%v); try again later (%v after %s)",
localRawVal, kvRawVal, ctx.Err(), timeutil.Since(tBegin))
}

which is not applicable for show all settings.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I don't understand is that in both #99115 and #99459, I don't see a migration taking more than a few seconds (let alone 2mins) to finish around the time of the test failure. Am I missing something?

Copy link
Contributor

@aliher1911 aliher1911 Mar 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO once version querying code is fixed, we'll see the real issue because version that test expects will diverge and give us more sensible failure. Same in other test.
edit: this one isn't a test, so maybe we shouldn't change it until we understand why upgrade is stuck.

@fqazi fqazi closed this Mar 27, 2023
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.

workload/schemachange: flakes in acceptance/versionupgrade roachtest
6 participants