1
0
Fork 0
mirror of https://github.com/chrislusf/seaweedfs synced 2024-07-06 00:57:10 +02:00

volume: avoid deadlock when deleting volumes

fix https://github.com/chrislusf/seaweedfs/issues/1501
This commit is contained in:
Chris Lu 2020-10-01 07:10:03 -07:00
parent a34bad2cee
commit a1c01d716b
2 changed files with 3 additions and 4 deletions

View file

@ -174,9 +174,6 @@ 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

View file

@ -380,10 +380,12 @@ func (s *Store) DeleteVolume(i needle.VolumeId) error {
Ttl: v.Ttl.ToUint32(),
}
for _, location := range s.Locations {
if found, err := location.deleteVolumeById(i); found && err == nil {
if err := location.DeleteVolume(i); err == nil {
glog.V(0).Infof("DeleteVolume %d", i)
s.DeletedVolumesChan <- message
return nil
} else {
glog.Errorf("DeleteVolume %d: %v", i, err)
}
}