aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2020-03-14 16:06:03 -0700
committerChris Lu <chris.lu@gmail.com>2020-03-14 16:06:06 -0700
commit0576a27f44a2264f39a2cc6bcfe13dcb58dda55a (patch)
tree64523856d1db9dbbec021226fb1a15c59d502f33
parent43ed730e90f04d9b58b912a59670bda8d8de735b (diff)
downloadseaweedfs-0576a27f44a2264f39a2cc6bcfe13dcb58dda55a.tar.xz
seaweedfs-0576a27f44a2264f39a2cc6bcfe13dcb58dda55a.zip
protect against possible nil
which is unlikely to happen though
-rw-r--r--weed/topology/store_replicate.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/weed/topology/store_replicate.go b/weed/topology/store_replicate.go
index 8c4996d45..24c32ef62 100644
--- a/weed/topology/store_replicate.go
+++ b/weed/topology/store_replicate.go
@@ -154,7 +154,11 @@ func distributedOperation(locations []operation.Location, store *storage.Store,
func getWritableRemoteReplications(s *storage.Store, volumeId needle.VolumeId, masterNode string) (
remoteLocations []operation.Location, err error) {
- copyCount := s.GetVolume(volumeId).ReplicaPlacement.GetCopyCount()
+ volume := s.GetVolume(volumeId)
+ if volume == nil {
+ return nil, fmt.Errorf("fail to find volume %d", volumeId)
+ }
+ copyCount := v.ReplicaPlacement.GetCopyCount()
if copyCount > 1 {
if lookupResult, lookupErr := operation.Lookup(masterNode, volumeId.String()); lookupErr == nil {
if len(lookupResult.Locations) < copyCount {