Skip to content

Commit 94996a7

Browse files
authored
Merge pull request #162059 from DrewKimball/backport26.1-161961
release-26.1: sql/copy: deflake TestLargeCopy
2 parents 479d46c + 826439b commit 94996a7

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

pkg/sql/copy/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ go_test(
2727
"//pkg/sql/catalog",
2828
"//pkg/sql/catalog/desctestutils",
2929
"//pkg/sql/parser",
30+
"//pkg/sql/pgwire/pgcode",
3031
"//pkg/sql/randgen",
3132
"//pkg/sql/sem/tree",
3233
"//pkg/sql/sqltestutils",

pkg/sql/copy/copy_test.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131
"github.com/cockroachdb/cockroach/pkg/sql/catalog"
3232
"github.com/cockroachdb/cockroach/pkg/sql/catalog/desctestutils"
3333
"github.com/cockroachdb/cockroach/pkg/sql/parser"
34+
"github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgcode"
3435
"github.com/cockroachdb/cockroach/pkg/sql/randgen"
3536
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
3637
"github.com/cockroachdb/cockroach/pkg/sql/types"
@@ -736,9 +737,13 @@ func TestLargeCopy(t *testing.T) {
736737
if err == nil {
737738
return true
738739
}
739-
if atomicCopy && strings.Contains(err.Error(), "restart transaction") {
740-
// We can only retry txn errors with non-atomic COPY.
741-
return true
740+
if atomicCopy {
741+
// Ignore retriable errors in atomic COPY mode, since we only have
742+
// automatic retries when atomic=false.
743+
var pgErr = new(pgconn.PgError)
744+
if errors.As(err, &pgErr) && pgcode.MakeCode(pgErr.Code) == pgcode.SerializationFailure {
745+
return true
746+
}
742747
}
743748
if !doAlterPK {
744749
return false

0 commit comments

Comments
 (0)