mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
volume: avoid deadlock when deleting volumes
fix https://github.com/chrislusf/seaweedfs/issues/1501
This commit is contained in:
parent
a34bad2cee
commit
a1c01d716b
|
@ -174,9 +174,6 @@ func (l *DiskLocation) DeleteCollectionFromDiskLocation(collection string) (e er
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *DiskLocation) deleteVolumeById(vid needle.VolumeId) (found bool, e error) {
|
func (l *DiskLocation) deleteVolumeById(vid needle.VolumeId) (found bool, e error) {
|
||||||
l.volumesLock.Lock()
|
|
||||||
defer l.volumesLock.Unlock()
|
|
||||||
|
|
||||||
v, ok := l.volumes[vid]
|
v, ok := l.volumes[vid]
|
||||||
if !ok {
|
if !ok {
|
||||||
return
|
return
|
||||||
|
|
|
@ -380,10 +380,12 @@ func (s *Store) DeleteVolume(i needle.VolumeId) error {
|
||||||
Ttl: v.Ttl.ToUint32(),
|
Ttl: v.Ttl.ToUint32(),
|
||||||
}
|
}
|
||||||
for _, location := range s.Locations {
|
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)
|
glog.V(0).Infof("DeleteVolume %d", i)
|
||||||
s.DeletedVolumesChan <- message
|
s.DeletedVolumesChan <- message
|
||||||
return nil
|
return nil
|
||||||
|
} else {
|
||||||
|
glog.Errorf("DeleteVolume %d: %v", i, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue