Skip to content

Commit

Permalink
address comment
Browse files Browse the repository at this point in the history
Signed-off-by: husharp <[email protected]>
  • Loading branch information
HuSharp committed Aug 29, 2023
1 parent 6405f53 commit 83ddbf5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion client/base_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func (c *baseClient) memberLoop() {
case <-c.checkLeaderCh:
case <-ticker.C:
case <-ctx.Done():
log.Info("[pd] exit member loop")
log.Info("[pd] exit member loop due to context canceled")
return
}
failpoint.Inject("skipUpdateMember", func() {
Expand Down
12 changes: 5 additions & 7 deletions client/retry/backoff.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,19 @@ func WithBackoff(
fn func() error,
bo *BackOffer,
) error {
err := fn()
if err != nil {
if err := fn(); err != nil {
select {
case <-ctx.Done():
return err
case <-time.After(bo.NextBackoff()):
failpoint.Inject("backOffExecute", func() {
testBackOffExecuteFlag = true
})
}
} else {
bo.ResetBackoff()
return nil
return err
}
return err
// Reset backoff when fn() succeed.
bo.ResetBackoff()
return nil
}

// InitialBackOffer make the initial state for retrying.
Expand Down

0 comments on commit 83ddbf5

Please sign in to comment.