Skip to content

Commit 7a46bb0

Browse files
craig[bot]spilchen
andcommitted
Merge #159308
159308: workload/schemachange: gate TRUNCATE FK error codes by version r=spilchen a=spilchen In mixed-version clusters, executing TRUNCATE on a table with foreign key references can result in inconsistent error codes depending on the node version. - Nodes prior to v26.1 return pgcode.Uncategorized. - Nodes running v26.1+ return pgcode.FeatureNotSupported (introduced in #154382). This change introduces version gating to distinguish between the two cases and handle the returned error appropriately based on the active cluster version. Resolves: #159034 Resolves: #159243 Epic: none Release note: none Co-authored-by: Matt Spilchen <[email protected]>
2 parents da00462 + 77179a6 commit 7a46bb0

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

pkg/workload/schemachange/operation_generator.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5729,7 +5729,19 @@ func (og *operationGenerator) truncateTable(ctx context.Context, tx pgx.Tx) (*op
57295729
// will fail with an error.
57305730
for fk := range fkSet {
57315731
if _, hasTable := tableSet[fk]; !hasTable {
5732-
op.expectedExecErrors.add(pgcode.FeatureNotSupported)
5732+
// In mixed version workloads, we can see either pgcode.Uncategorized
5733+
// (pre-v26.1) or pgcode.FeatureNotSupported (v26.1+) depending on which
5734+
// node handles the TRUNCATE. The pgcode was changed in #154382 (v26.1).
5735+
versionBefore261, err := isClusterVersionLessThan(ctx, tx, clusterversion.V26_1.Version())
5736+
if err != nil {
5737+
return nil, err
5738+
}
5739+
if versionBefore261 {
5740+
op.expectedExecErrors.add(pgcode.Uncategorized)
5741+
op.potentialExecErrors.add(pgcode.FeatureNotSupported)
5742+
} else {
5743+
op.expectedExecErrors.add(pgcode.FeatureNotSupported)
5744+
}
57335745
break
57345746
}
57355747
}

0 commit comments

Comments
 (0)