diff options
| author | Konstantin Lebedev <9497591+kmlebedev@users.noreply.github.com> | 2022-08-30 12:08:00 +0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-30 00:08:00 -0700 |
| commit | ade94b0d0a71db7db117454c075dc93f839e1c9c (patch) | |
| tree | cee03f6e42c99f1d78fae517b025bb3a972eec97 | |
| parent | ae6292f9f0337dd364ffca20357155f66223bedb (diff) | |
| download | seaweedfs-ade94b0d0a71db7db117454c075dc93f839e1c9c.tar.xz seaweedfs-ade94b0d0a71db7db117454c075dc93f839e1c9c.zip | |
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
| -rw-r--r-- | weed/storage/volume.go | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/weed/storage/volume.go b/weed/storage/volume.go index 91d2d0d1f..e48a2f49a 100644 --- a/weed/storage/volume.go +++ b/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) } |
