Skip to content

Commit

Permalink
client: do not return error when a ctx.Done signal arrives (#4636)
Browse files Browse the repository at this point in the history
close #4629

Do not return error when a `ctx.Done` signal arrives.

Signed-off-by: JmPotato <ghzpotato@gmail.com>
  • Loading branch information
JmPotato authored Feb 11, 2022
1 parent 62c38e9 commit a6f72df
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
10 changes: 8 additions & 2 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,13 @@ tsoBatchLoop:
// Start to collect the TSO requests.
maxBatchWaitInterval := c.option.getMaxTSOBatchWaitInterval()
if err = tbc.fetchPendingRequests(dispatcherCtx, maxBatchWaitInterval); err != nil {
log.Error("[pd] fetch pending tso requests error", zap.String("dc-location", dc), errs.ZapError(errs.ErrClientGetTSO, err))
if err == context.Canceled {
log.Info("[pd] stop fetching the pending tso requests due to context canceled",
zap.String("dc-location", dc))
} else {
log.Error("[pd] fetch pending tso requests error",
zap.String("dc-location", dc), errs.ZapError(errs.ErrClientGetTSO, err))
}
return
}
if maxBatchWaitInterval >= 0 {
Expand All @@ -768,7 +774,7 @@ tsoBatchLoop:
log.Info("[pd] tso stream is not ready", zap.String("dc", dc))
c.updateConnectionCtxs(dispatcherCtx, dc, &connectionCtxs)
if retryTimeConsuming >= c.option.timeout {
err = errs.ErrClientCreateTSOStream.FastGenByArgs()
err = errs.ErrClientCreateTSOStream.FastGenByArgs("retry timeout")
log.Error("[pd] create tso stream error", zap.String("dc-location", dc), errs.ZapError(err))
c.ScheduleCheckLeader()
c.finishTSORequest(tbc.getCollectedRequests(), 0, 0, 0, errors.WithStack(err))
Expand Down
2 changes: 1 addition & 1 deletion errors.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ checker not found

["PD:client:ErrClientCreateTSOStream"]
error = '''
create TSO stream failed
create TSO stream failed, %s
'''

["PD:client:ErrClientGetLeader"]
Expand Down
2 changes: 1 addition & 1 deletion pkg/errs/errno.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ var (

// client errors
var (
ErrClientCreateTSOStream = errors.Normalize("create TSO stream failed", errors.RFCCodeText("PD:client:ErrClientCreateTSOStream"))
ErrClientCreateTSOStream = errors.Normalize("create TSO stream failed, %s", errors.RFCCodeText("PD:client:ErrClientCreateTSOStream"))
ErrClientGetTSOTimeout = errors.Normalize("get TSO timeout", errors.RFCCodeText("PD:client:ErrClientGetTSOTimeout"))
ErrClientGetTSO = errors.Normalize("get TSO failed, %v", errors.RFCCodeText("PD:client:ErrClientGetTSO"))
ErrClientGetLeader = errors.Normalize("get leader from %v error", errors.RFCCodeText("PD:client:ErrClientGetLeader"))
Expand Down

0 comments on commit a6f72df

Please sign in to comment.