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.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
fix(log_buffer): re-check buffer before bailing with ResumeFromDiskError (#9804)
Chris Luf711868fb618
diff --git a/weed/util/log_buffer/log_read.go b/weed/util/log_buffer/log_read.goindex d62eea428d..364047f74f 100644--- a/weed/util/log_buffer/log_read.go+++ b/weed/util/log_buffer/log_read.go@@ -147,7 +147,17 @@ func (logBuffer *LogBuffer) LoopProcessLogData(readerName string, startPositionglog.V(4).Infof("%s: Caught up to disk head, backing off to %s poll", readerName, caughtUpDiskPollInterval)}} else if logBuffer.HasData() {- return lastReadPosition, isDone, ResumeFromDiskError+ // HasData() and ReadFromBuffer lock separately, so a racing write can make+ // HasData() see data the empty-buffer read missed. Re-read; only bail if the+ // position is genuinely behind the in-memory window (flushed to disk).+ reBuf, _, reErr := logBuffer.ReadFromBuffer(lastReadPosition)+ if reErr == ResumeFromDiskError {+ return lastReadPosition, isDone, ResumeFromDiskError+ }+ if reBuf != nil {+ logBuffer.ReleaseMemory(reBuf)+ }+ continue}// CRITICAL: Check if client is still connected@@ -362,7 +372,17 @@ func (logBuffer *LogBuffer) LoopProcessLogDataWithOffset(readerName string, starglog.V(4).Infof("%s: Caught up to disk head, backing off to %s poll", readerName, caughtUpDiskPollInterval)}} else if logBuffer.HasData() {- return lastReadPosition, isDone, ResumeFromDiskError+ // HasData() and ReadFromBuffer lock separately, so a racing write can make+ // HasData() see data the empty-buffer read missed. Re-read; only bail if the+ // position is genuinely behind the in-memory window (flushed to disk).+ reBuf, _, reErr := logBuffer.ReadFromBuffer(lastReadPosition)+ if reErr == ResumeFromDiskError {+ return lastReadPosition, isDone, ResumeFromDiskError+ }+ if reBuf != nil {+ logBuffer.ReleaseMemory(reBuf)+ }+ continue}// CRITICAL: Check if client is still connected after disk read