Skip to content

Commit

Permalink
Merge branch 'release-6.5' into cherry-pick-7143-to-release-6.5
Browse files Browse the repository at this point in the history
  • Loading branch information
bufferflies authored Jan 26, 2025
2 parents 291d2bf + 3e55a4f commit beb9c5a
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions server/region_syncer/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import (
const (
keepaliveTime = 10 * time.Second
keepaliveTimeout = 3 * time.Second
retryInterval = time.Second
)

// StopSyncWithLeader stop to sync the region with leader.
Expand Down Expand Up @@ -163,7 +164,15 @@ func (s *RegionSyncer) StartSyncWithLeader(addr string) {
}
}
log.Error("server failed to establish sync stream with leader", zap.String("server", s.server.Name()), zap.String("leader", s.server.GetLeader().GetName()), errs.ZapError(err))
time.Sleep(time.Second)
timer := time.NewTimer(retryInterval)
select {
case <-ctx.Done():
log.Info("stop synchronizing with leader due to context canceled")
timer.Stop()
return
case <-timer.C:
timer.Stop()
}
continue
}

Expand All @@ -175,7 +184,15 @@ func (s *RegionSyncer) StartSyncWithLeader(addr string) {
if err = stream.CloseSend(); err != nil {
log.Error("failed to terminate client stream", errs.ZapError(errs.ErrGRPCCloseSend, err))
}
time.Sleep(time.Second)
timer := time.NewTimer(retryInterval)
select {
case <-ctx.Done():
log.Info("stop synchronizing with leader due to context canceled")
timer.Stop()
return
case <-timer.C:
timer.Stop()
}
break
}
if s.history.GetNextIndex() != resp.GetStartIndex() {
Expand Down

0 comments on commit beb9c5a

Please sign in to comment.