Skip to content

Commit 1e9b4bc

Browse files
craig[bot]fqazi
andcommitted
Merge #130361
130361: workload/schemachange: add unique constraint hits duplicate key errors r=fqazi a=fqazi Previously, the ALTER TABLE ADD UNIQUE CONSTRAINT operation could encounter duplicate key errors. This would occur because our scan query was not exhaustive enough. To address this and to help stabilize the workload, we will allow unique violations to be potential commit errors. Fixes: #129909 Release note: None Co-authored-by: Faizan Qazi <[email protected]>
2 parents 7571549 + 84d1d18 commit 1e9b4bc

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

pkg/workload/schemachange/operation_generator.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,11 @@ func (og *operationGenerator) addUniqueConstraint(ctx context.Context, tx pgx.Tx
400400

401401
if !canApplyConstraint {
402402
og.candidateExpectedCommitErrors.add(pgcode.UniqueViolation)
403+
} else {
404+
// Otherwise there is still a possibility for an error,
405+
// so add it in the potential set, since our validation query
406+
// above isn't exhaustive enough.
407+
og.potentialCommitErrors.add(pgcode.UniqueViolation)
403408
}
404409

405410
stmt.sql = fmt.Sprintf(

0 commit comments

Comments
 (0)