Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

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

Konstantin Lebedevade94b0d0a71
diff --git a/weed/storage/volume.go b/weed/storage/volume.go
index 91d2d0d1f7..e48a2f49a4 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)
}