Skip to content

Commit

Permalink
store/tikv: handle the error of "mismatch cluster id" (pingcap#7053)
Browse files Browse the repository at this point in the history
* store: handle the error of "mismatch cluster id"
  • Loading branch information
zimulala authored and ciscoxll committed Jul 16, 2018
1 parent b1bc420 commit b729a60
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions store/tikv/backoff.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"fmt"
"math"
"math/rand"
"strings"
"time"

"github.com/juju/errors"
Expand Down Expand Up @@ -201,6 +202,9 @@ func (b *Backoffer) WithVars(vars *kv.Variables) *Backoffer {
// Backoff sleeps a while base on the backoffType and records the error message.
// It returns a retryable error if total sleep time exceeds maxSleep.
func (b *Backoffer) Backoff(typ backoffType, err error) error {
if strings.Contains(err.Error(), mismatchClusterID) {
log.Fatalf("critical error %v", err)
}
select {
case <-b.ctx.Done():
return errors.Trace(err)
Expand Down
3 changes: 3 additions & 0 deletions store/tikv/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ var (
ErrBodyMissing = errors.New("response body is missing")
)

// mismatchClusterID represents the message that the cluster ID of the PD client does not match the PD.
const mismatchClusterID = "mismatch cluster id"

// TiDB decides whether to retry transaction by checking if error message contains
// string "try again later" literally.
// In TiClient we use `errors.Annotate(err, txnRetryableMark)` to direct TiDB to
Expand Down

0 comments on commit b729a60

Please sign in to comment.