diff --git a/pkg/sql/distsqlrun/inbound.go b/pkg/sql/distsqlrun/inbound.go index 0a27aeaac4cd..d0745e54734d 100644 --- a/pkg/sql/distsqlrun/inbound.go +++ b/pkg/sql/distsqlrun/inbound.go @@ -18,6 +18,7 @@ import ( "context" "io" + "github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgerror" "github.com/cockroachdb/cockroach/pkg/sql/sqlbase" "github.com/cockroachdb/cockroach/pkg/util/log" "github.com/pkg/errors" @@ -95,8 +96,7 @@ func processInboundStreamHelper( if err != nil { if err != io.EOF { // Communication error. - err = errors.Wrap( - err, log.MakeMessage(ctx, "communication error", nil /* args */)) + err = pgerror.NewErrorf(pgerror.CodeConnectionFailureError, "communication error: %s", err) sendErrToConsumer(err) errChan <- err return diff --git a/pkg/sql/schema_changer.go b/pkg/sql/schema_changer.go index e6ee9c3779e3..21cab6c6b98d 100644 --- a/pkg/sql/schema_changer.go +++ b/pkg/sql/schema_changer.go @@ -164,12 +164,14 @@ func isPermanentSchemaChangeError(err error) bool { return false case *pgerror.Error: switch err.Code { - case pgerror.CodeSerializationFailureError: + case pgerror.CodeSerializationFailureError, pgerror.CodeConnectionFailureError: return false + case pgerror.CodeInternalError: if err.Message == context.DeadlineExceeded.Error() { return false } + } } return true