Skip to content

Commit

Permalink
workload/schemachanger: ignore unique violation errors for CREATE INDEX
Browse files Browse the repository at this point in the history
Previously, the schema changer workload added logic to ignore potential
unique violation errors during CREATE UNIQUE INDEX. This logic was for
the statement phase, which is not when this error would be noticed, so
it did not work correctly. To address this, this patch adds the logic to
make unique violations error as  potential commit error for CREATE
INDEX.

Fixes: #129366

Release note: None
  • Loading branch information
fqazi committed Sep 9, 2024
1 parent 60313dc commit fb7a8e8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/workload/schemachange/operation_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -1118,7 +1118,7 @@ func (og *operationGenerator) createIndex(ctx context.Context, tx pgx.Tx) (*opSt
// When an index exists, but `IF NOT EXISTS` is used, then
// the index will not be created and the op will complete without errors.
if !(indexExists && def.IfNotExists) {
stmt.potentialExecErrors.addAll(codesWithConditions{
og.potentialCommitErrors.addAll(codesWithConditions{
// If there is data in the table such that a unique index cannot be created,
// a pgcode.UniqueViolation will occur and will be wrapped in a
// pgcode.TransactionCommittedWithSchemaChangeFailure. The schemachange worker
Expand Down

0 comments on commit fb7a8e8

Please sign in to comment.