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.

Fixes unlocked read from logBuffer.LastTsNs that is racey. (#5536)

M@abf01a0eb724
diff --git a/weed/util/log_buffer/log_read.go b/weed/util/log_buffer/log_read.go
index c3dd0f288e..0d044fc147 100644
--- a/weed/util/log_buffer/log_read.go
+++ b/weed/util/log_buffer/log_read.go
@@ -66,9 +66,17 @@ func (logBuffer *LogBuffer) LoopProcessLogData(readerName string, startPosition
isDone = true
return
}
+ logBuffer.RLock()
lastTsNs := logBuffer.LastTsNs
- for lastTsNs == logBuffer.LastTsNs {
+ logBuffer.RUnlock()
+ loopTsNs := lastTsNs // make a copy
+
+ for lastTsNs == loopTsNs {
if waitForDataFn() {
+ // Update loopTsNs and loop again
+ logBuffer.RLock()
+ loopTsNs = logBuffer.LastTsNs
+ logBuffer.RUnlock()
continue
} else {
isDone = true