diff options
| author | James Hartig <fastest963@gmail.com> | 2020-09-01 22:00:00 -0400 |
|---|---|---|
| committer | James Hartig <fastest963@gmail.com> | 2020-09-01 22:00:07 -0400 |
| commit | 8e54e345760c2dca12085311d6fe0cf7eba8b6a9 (patch) | |
| tree | 638806dd8e32e3fbdff1608c4a56f74ea021a656 | |
| parent | 2b14ae581916f324f8cc6fdf4778d948f9f3b6fd (diff) | |
| download | seaweedfs-8e54e345760c2dca12085311d6fe0cf7eba8b6a9.tar.xz seaweedfs-8e54e345760c2dca12085311d6fe0cf7eba8b6a9.zip | |
volume: Don't unmount before deleting volume in copy
If we unmount first and then delete, the delete fails because the volume
was unmounted. Delete ends up doing the same thing as the unmount anyways.
| -rw-r--r-- | weed/server/volume_grpc_copy.go | 9 | ||||
| -rw-r--r-- | weed/storage/disk_location.go | 3 | ||||
| -rw-r--r-- | weed/storage/store.go | 2 |
3 files changed, 6 insertions, 8 deletions
diff --git a/weed/server/volume_grpc_copy.go b/weed/server/volume_grpc_copy.go index 5c7d5572c..cd2b53c8a 100644 --- a/weed/server/volume_grpc_copy.go +++ b/weed/server/volume_grpc_copy.go @@ -27,17 +27,12 @@ func (vs *VolumeServer) VolumeCopy(ctx context.Context, req *volume_server_pb.Vo glog.V(0).Infof("volume %d already exists. deleted before copying...", req.VolumeId) - err := vs.store.UnmountVolume(needle.VolumeId(req.VolumeId)) - if err != nil { - return nil, fmt.Errorf("failed to mount existing volume %d: %v", req.VolumeId, err) - } - - err = vs.store.DeleteVolume(needle.VolumeId(req.VolumeId)) + err := vs.store.DeleteVolume(needle.VolumeId(req.VolumeId)) if err != nil { return nil, fmt.Errorf("failed to delete existing volume %d: %v", req.VolumeId, err) } - glog.V(0).Infof("deleted exisitng volume %d before copying.", req.VolumeId) + glog.V(0).Infof("deleted existing volume %d before copying.", req.VolumeId) } location := vs.store.FindFreeLocation() diff --git a/weed/storage/disk_location.go b/weed/storage/disk_location.go index c309b3f92..9ecc57459 100644 --- a/weed/storage/disk_location.go +++ b/weed/storage/disk_location.go @@ -174,6 +174,9 @@ func (l *DiskLocation) DeleteCollectionFromDiskLocation(collection string) (e er } func (l *DiskLocation) deleteVolumeById(vid needle.VolumeId) (found bool, e error) { + l.volumesLock.Lock() + defer l.volumesLock.Unlock() + v, ok := l.volumes[vid] if !ok { return diff --git a/weed/storage/store.go b/weed/storage/store.go index 3f16688bf..48cbeb3d1 100644 --- a/weed/storage/store.go +++ b/weed/storage/store.go @@ -380,7 +380,7 @@ func (s *Store) DeleteVolume(i needle.VolumeId) error { Ttl: v.Ttl.ToUint32(), } for _, location := range s.Locations { - if found, error := location.deleteVolumeById(i); found && error == nil { + if found, err := location.deleteVolumeById(i); found && err == nil { glog.V(0).Infof("DeleteVolume %d", i) s.DeletedVolumesChan <- message return nil |
