Fix tailer cursor not saved when context cancelled at EOF poll
When the tailer is parked at EOF polling for new log lines (the steady state between blocks), a context cancellation causes sleep() to return false, which previously triggered a bare return without force-saving the cursor. On restart the throttled saveCursor(false) call had last fired when the file was at offset 0 (empty on first open), so the tailer replayed the entire log from the beginning. The fix adds saveCursor(true) before the return so the cursor is always flushed at the position we actually read to, regardless of when the process is stopped. Found by TestTailerRun_CursorResume, which expects a resumed tailer to see only newly appended lines and not replay previously processed ones.
This commit is contained in:
@@ -235,6 +235,7 @@ func (t *Tailer) Run(ctx context.Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !sleep(ctx, t.PollWait) {
|
if !sleep(ctx, t.PollWait) {
|
||||||
|
saveCursor(true)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user