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:
Chris Lu
2020-04-28 17:29:10 -07:00
parent 98edec7c3e
commit 31583b5d6c
2 changed files with 6 additions and 1 deletions

View File

@@ -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)