mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
master and volume server: avoid race condition
The volume server may disconnect and reconnect to the same master. The master's unregistration may happen after the reconnection. Thus the volume server will disappear.
This commit is contained in:
parent
98edec7c3e
commit
31583b5d6c
|
@ -24,8 +24,10 @@ func (ms *MasterServer) SendHeartbeat(stream master_pb.Seaweed_SendHeartbeatServ
|
|||
defer func() {
|
||||
if dn != nil {
|
||||
|
||||
glog.V(0).Infof("unregister disconnected volume server %s:%d", dn.Ip, dn.Port)
|
||||
// if the volume server disconnects and reconnects quickly
|
||||
// the unregister and register can race with each other
|
||||
t.UnRegisterDataNode(dn)
|
||||
glog.V(0).Infof("unregister disconnected volume server %s:%d", dn.Ip, dn.Port)
|
||||
|
||||
message := &master_pb.VolumeLocation{
|
||||
Url: dn.Url(),
|
||||
|
|
|
@ -35,6 +35,9 @@ func (vs *VolumeServer) heartbeat() {
|
|||
for {
|
||||
for _, master := range vs.SeedMasterNodes {
|
||||
if newLeader != "" {
|
||||
// the new leader may actually is the same master
|
||||
// need to wait a bit before adding itself
|
||||
time.Sleep(3 * time.Second)
|
||||
master = newLeader
|
||||
}
|
||||
masterGrpcAddress, parseErr := pb.ParseServerToGrpcAddress(master)
|
||||
|
|
Loading…
Reference in a new issue