Browse Source
Merge pull request #1683 from qieqieplus/master
fix race condition when loading volumes concurrently
pull/1686/head
Chris Lu
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
7 additions and
5 deletions
-
weed/storage/disk_location.go
|
|
@ -99,12 +99,14 @@ func (l *DiskLocation) loadExistingVolume(fileInfo os.FileInfo, needleMapKind Ne |
|
|
|
} |
|
|
|
|
|
|
|
// avoid loading one volume more than once
|
|
|
|
l.volumesLock.RLock() |
|
|
|
_, found := l.volumes[vid] |
|
|
|
l.volumesLock.RUnlock() |
|
|
|
if found { |
|
|
|
l.volumesLock.Lock() |
|
|
|
if _, found := l.volumes[vid]; found { |
|
|
|
l.volumesLock.Unlock() |
|
|
|
glog.V(1).Infof("loaded volume, %v", vid) |
|
|
|
return true |
|
|
|
} else { |
|
|
|
l.volumes[vid] = nil |
|
|
|
l.volumesLock.Unlock() |
|
|
|
} |
|
|
|
|
|
|
|
// load the volume
|
|
|
|