Skip to content

Commit

Permalink
workload/schemachanger: fix ALTER COLUMN SET NOT NULL flakes
Browse files Browse the repository at this point in the history
Previously, ALTER COLUMN SET NOT NULL could flake if a concurrent INSERT
happened during this operation, when executing under the legacy schema
changer. To address this, this path allows null violations to be a
potential execution error, if the operation is run in the legacy schema
changer.

Fixes: #135692

Release note: None
  • Loading branch information
fqazi committed Nov 27, 2024
1 parent e6a5104 commit a0cb1ca
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkg/workload/schemachange/operation_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -2465,8 +2465,12 @@ func (og *operationGenerator) setColumnNotNull(ctx context.Context, tx pgx.Tx) (
}
if colContainsNull {
og.candidateExpectedCommitErrors.add(pgcode.NotNullViolation)
// If executed within the same txn as CREATE TABLE.
stmt.potentialExecErrors.add(pgcode.NotNullViolation)
}
// If we are running with the legacy schema changer, the not null constraint
// is enforced during the job phase. So it's still possible to INSERT not null
// data before then.
if !og.useDeclarativeSchemaChanger {
og.potentialCommitErrors.add(pgcode.NotNullViolation)
}
}

Expand Down

0 comments on commit a0cb1ca

Please sign in to comment.