mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
Retry until a leader is selected. (#4318)
Fixes regression introduced in https://github.com/seaweedfs/seaweedfs/pull/4313 Related to #4307
This commit is contained in:
parent
d695119073
commit
264be0d2d4
|
@ -101,7 +101,20 @@ func (t *Topology) Leader() (l pb.ServerAddress, err error) {
|
|||
exponentialBackoff := backoff.NewExponentialBackOff()
|
||||
exponentialBackoff.InitialInterval = 100 * time.Millisecond
|
||||
exponentialBackoff.MaxElapsedTime = 20 * time.Second
|
||||
return backoff.RetryWithData(t.MaybeLeader, exponentialBackoff)
|
||||
leaderNotSelected := errors.New("leader not selected yet")
|
||||
l, err = backoff.RetryWithData(
|
||||
func() (l pb.ServerAddress, err error) {
|
||||
l, err = t.MaybeLeader()
|
||||
if err == nil && l == "" {
|
||||
err = leaderNotSelected
|
||||
}
|
||||
return l, err
|
||||
},
|
||||
exponentialBackoff)
|
||||
if err == leaderNotSelected {
|
||||
l = ""
|
||||
}
|
||||
return l, err
|
||||
}
|
||||
|
||||
func (t *Topology) MaybeLeader() (l pb.ServerAddress, err error) {
|
||||
|
|
Loading…
Reference in a new issue