Browse Source

avoid race conditions access to SuperBlock.Version (#3539)

* avoid race conditions access to  SuperBlock.Version
https://github.com/seaweedfs/seaweedfs/issues/3515

* superBlockAccessLock replace to sync.Mutex
pull/3551/merge
Konstantin Lebedev 2 years ago
committed by GitHub
parent
commit
ade94b0d0a
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      weed/storage/volume.go

3
weed/storage/volume.go

@ -36,6 +36,7 @@ type Volume struct {
super_block.SuperBlock
dataFileAccessLock sync.RWMutex
superBlockAccessLock sync.Mutex
asyncRequestsChan chan *needle.AsyncRequest
lastModifiedTsSeconds uint64 // unix time in seconds
lastAppendAtNs uint64 // unix time in nanoseconds
@ -97,6 +98,8 @@ func (v *Volume) FileName(ext string) (fileName string) {
}
func (v *Volume) Version() needle.Version {
v.superBlockAccessLock.Lock()
defer v.superBlockAccessLock.Unlock()
if v.volumeInfo.Version != 0 {
v.SuperBlock.Version = needle.Version(v.volumeInfo.Version)
}

Loading…
Cancel
Save