Skip to content

Commit

Permalink
workload/schemachange: disable inserts when in 22.1 mixed version state
Browse files Browse the repository at this point in the history
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
  • Loading branch information
fqazi committed Aug 31, 2022
1 parent 0aeeb40 commit 1fd8251
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/cmd/roachtest/tests/mixed_version_schemachange.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func runSchemaChangeWorkloadStep(loadNode, maxOps, concurrency int) versionStep
// crashes, deadlocks, etc.
// TODO(spaskob): remove when https://github.com/cockroachdb/cockroach/issues/47430
// is closed.
"--tolerate-errors=true",
//"--tolerate-errors=true",
fmt.Sprintf("--max-ops %d", maxOps),
fmt.Sprintf("--concurrency %d", concurrency),
fmt.Sprintf("{pgurl:1-%d}", u.c.Spec().NodeCount),
Expand Down
11 changes: 10 additions & 1 deletion pkg/workload/schemachange/operation_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -2373,6 +2373,16 @@ 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 queries fail due to an optimizer bug.
skipInserts, err := isClusterVersionLessThan(ctx, tx, clusterversion.ByKey(clusterversion.Start22_2))
if err != nil {
return nil, err
}
if skipInserts {
tableExists = false
tableName.SchemaName = "InvalidObjectName"
}
if !tableExists {
return makeOpStmtForSingleError(OpStmtDML,
fmt.Sprintf(
Expand Down Expand Up @@ -2488,7 +2498,6 @@ func (og *operationGenerator) insertRow(ctx context.Context, tx pgx.Tx) (stmt *o
for _, row := range rows {
formattedRows = append(formattedRows, fmt.Sprintf("(%s)", strings.Join(row, ",")))
}

stmt.sql = fmt.Sprintf(
`INSERT INTO %s (%s) VALUES %s`,
tableName,
Expand Down

0 comments on commit 1fd8251

Please sign in to comment.