fix: SubscribeMetadata stream blocked with slow consumers (#8730)

When a slow consumer's read position falls behind the in-memory buffer
window, LoopProcessLogData would block indefinitely in waitForDataFn
because ReadFromDiskFn is nil for MetaAggregator.MetaLogBuffer. The
consumer could never return to the caller's outer loop which has its
own disk-read path (ReadPersistedLogBuffer).

Now, when ReadFromDiskFn is nil and the buffer has data the consumer
can't reach, return ResumeFromDiskError to the caller instead of
blocking. The callers already handle this error correctly.
This commit is contained in:
Copilot committed 2026-03-23 14:04:30 -07:00
1 parent d5ee35c8df
commit afc8ab3425
3 files changed
+76 -24

No files matched your search

+17
View File
@@ -606,6 +606,23 @@ func (logBuffer *LogBuffer) invalidateAllDiskCacheChunks() {
func (logBuffer *LogBuffer) GetEarliestTime() time.Time {
return logBuffer.startTime
}
// HasData returns true if the buffer (current or previous) contains any data.
// This is used to distinguish "buffer empty" (no data written yet) from
// "consumer behind buffer window" (data exists but position is too old).
func (logBuffer *LogBuffer) HasData() bool {
logBuffer.RLock()
defer logBuffer.RUnlock()
if logBuffer.pos > 0 {
return true
}
for _, buf := range logBuffer.prevBuffers.buffers {
if buf.size > 0 {
return true
}
}
return false
}
func (logBuffer *LogBuffer) GetEarliestPosition() MessagePosition {
return MessagePosition{
Time: logBuffer.startTime,