Browse Source

Retry until a leader is selected. (#4318)

Fixes regression introduced in
https://github.com/seaweedfs/seaweedfs/pull/4313

Related to #4307
pull/4321/head
Stewart Miles 2 years ago
committed by GitHub
parent
commit
264be0d2d4
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 15
      weed/topology/topology.go

15
weed/topology/topology.go

@ -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…
Cancel
Save