mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
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.
This commit is contained in:
parent
2b14ae5819
commit
8e54e34576
|
@ -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()
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue