Browse Source

perf: Optimized volume handling duplicateUUID logic to avoid quitting when volume is actualy normal

Under normal circumstances, there will be no problems, but when the
master is debugged in the local environment, the volume client cannot
communicate with the master normally, so the sendHeartBeat logic is
restarted, and a new connection is created to report the heartbeat. If
the master has not cleared the uuid of the volume at this time, then The
master will respond to volume duplicateUUIDS, and the volume service
will exit, but in fact the uuid of the volume is not duplicated
pull/3159/head
shichanglin5 3 years ago
parent
commit
f5b0c04b14
  1. 1
      go.sum
  2. 24
      weed/server/volume_grpc_client_to_master.go
  3. 1
      weed/storage/volume.go

1
go.sum

@ -296,7 +296,6 @@ github.com/fluent/fluent-logger-golang v1.9.0/go.mod h1:2/HCT/jTy78yGyeNGQLGQsjF
github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw=
github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g=
github.com/frankban/quicktest v1.14.2/go.mod h1:mgiwOwqx65TmIk1wJ6Q7wvnVMocbUorkibMOrVTHZps=
github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=

24
weed/server/volume_grpc_client_to_master.go

@ -119,16 +119,30 @@ func (vs *VolumeServer) doHeartbeat(masterAddress pb.ServerAddress, grpcDialOpti
return
}
if len(in.DuplicatedUuids) > 0 {
var duplictedDir []string
var duplicatedDir []string
foundDuplicate := false
duplicateSet := make(map[string]struct{})
for _, loc := range vs.store.Locations {
directoryUuid := loc.DirectoryUuid
if _, exists := duplicateSet[directoryUuid]; !exists {
duplicateSet[directoryUuid] = struct{}{}
} else {
foundDuplicate = true
}
for _, uuid := range in.DuplicatedUuids {
if uuid == loc.DirectoryUuid {
duplictedDir = append(duplictedDir, loc.Directory)
if uuid == directoryUuid {
duplicatedDir = append(duplicatedDir, loc.Directory)
}
}
}
glog.Errorf("Shut down Volume Server due to duplicated volume directories: %v", duplictedDir)
os.Exit(1)
if foundDuplicate {
glog.Errorf("Shut down Volume Server due to duplicated volume directories: %v", duplicatedDir)
os.Exit(1)
} else {
glog.Warningf("Receive response of duplicated volume directories: %v, ignored(the check found no duplicates)", duplicatedDir)
}
}
if in.GetVolumeSizeLimit() != 0 && vs.store.GetVolumeSizeLimit() != in.GetVolumeSizeLimit() {
vs.store.SetVolumeSizeLimit(in.GetVolumeSizeLimit())

1
weed/storage/volume.go

@ -293,7 +293,6 @@ func (v *Volume) collectStatus() (maxFileKey types.NeedleId, datFileSize int64,
fileCount = uint64(v.nm.FileCount())
deletedCount = uint64(v.nm.DeletedCount())
deletedSize = v.nm.DeletedSize()
fileCount = uint64(v.nm.FileCount())
return
}

Loading…
Cancel
Save