Skip to content

Commit

Permalink
sql: retry schema change on a communication error
Browse files Browse the repository at this point in the history
return pgerror.CodeConnectionFailureError from distsql
when it sees a communication error.

related to #27958

Release note: None
  • Loading branch information
vivekmenezes committed Aug 21, 2018
1 parent a888a13 commit b1caf5f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pkg/sql/distsqlrun/inbound.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion pkg/sql/schema_changer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b1caf5f

Please sign in to comment.