From dd954ff1dcfe5918245f6e52a4b2de1a49df73e7 Mon Sep 17 00:00:00 2001 From: Faizan Qazi Date: Fri, 26 Aug 2022 18:00:38 +0000 Subject: [PATCH] workload/schemachange: disable inserts when in 22.1 mixed version state Previously, if we ran in a mixed version state with the schema changer workload we could run into an optimizer bug (#80820). To address this, this patch in a mixed version workload disables the insert portion of the workload. Release justification: improves test coverage by enabling the mixed version test Release note: None --- .../roachtest/tests/mixed_version_schemachange.go | 6 ------ pkg/workload/schemachange/operation_generator.go | 12 ++++++++++++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/pkg/cmd/roachtest/tests/mixed_version_schemachange.go b/pkg/cmd/roachtest/tests/mixed_version_schemachange.go index 65f37362aef8..63ba5cb8fae7 100644 --- a/pkg/cmd/roachtest/tests/mixed_version_schemachange.go +++ b/pkg/cmd/roachtest/tests/mixed_version_schemachange.go @@ -57,12 +57,6 @@ func runSchemaChangeWorkloadStep(loadNode, maxOps, concurrency int) versionStep t.L().Printf("Workload step run: %d", numFeatureRuns) runCmd := []string{ "./workload run schemachange --verbose=1", - // The workload is still in development and occasionally discovers schema - // change errors so for now we don't fail on them but only on panics, server - // crashes, deadlocks, etc. - // TODO(spaskob): remove when https://github.com/cockroachdb/cockroach/issues/47430 - // is closed. - "--tolerate-errors=true", fmt.Sprintf("--max-ops %d", maxOps), fmt.Sprintf("--concurrency %d", concurrency), fmt.Sprintf("{pgurl:1-%d}", u.c.Spec().NodeCount), diff --git a/pkg/workload/schemachange/operation_generator.go b/pkg/workload/schemachange/operation_generator.go index 692f5a905580..5a94ccecc7c7 100644 --- a/pkg/workload/schemachange/operation_generator.go +++ b/pkg/workload/schemachange/operation_generator.go @@ -2373,6 +2373,18 @@ func (og *operationGenerator) insertRow(ctx context.Context, tx pgx.Tx) (stmt *o if err != nil { return nil, err } + // If we aren't on 22.2 then disable the insert plugin, since 21.X + // can have schema instrospection queries fail due to an optimizer bug. + skipInserts, err := isClusterVersionLessThan(ctx, tx, clusterversion.ByKey(clusterversion.Start22_2)) + if err != nil { + return nil, err + } + // If inserts are to be skipped, we will intentionally, target the insert towards + // a non-existent table, so that they become no-ops. + if skipInserts { + tableExists = false + tableName.SchemaName = "InvalidObjectName" + } if !tableExists { return makeOpStmtForSingleError(OpStmtDML, fmt.Sprintf(