wait a bit before getting the next volume id if the leader is recently elected

This commit is contained in:
chrislu
2024-11-23 19:58:45 -08:00
parent 04081128a9
commit ccf1795e6f
3 changed files with 10 additions and 0 deletions

View File

@@ -55,6 +55,8 @@ type Topology struct {
UuidAccessLock sync.RWMutex
UuidMap map[string][]string
LastLeaderChangeTime time.Time
}
func NewTopology(id string, seq sequence.Sequencer, volumeSizeLimit uint64, pulse int, replicationAsMin bool) *Topology {

View File

@@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"github.com/seaweedfs/seaweedfs/weed/pb/master_pb"
"github.com/seaweedfs/seaweedfs/weed/server/constants"
"math/rand/v2"
"reflect"
"sync"
@@ -126,6 +127,10 @@ func (vg *VolumeGrowth) findAndGrow(grpcDialOption grpc.DialOption, topo *Topolo
if e != nil {
return nil, e
}
for !topo.LastLeaderChangeTime.Add(constants.VolumePulseSeconds * 2).Before(time.Now()) {
glog.V(0).Infof("wait for volume servers to join back")
time.Sleep(constants.VolumePulseSeconds / 2)
}
vid, raftErr := topo.NextVolumeId()
if raftErr != nil {
return nil, raftErr