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