Skip to content

tsdb/wlog: call SeriesReset on Run restart when checkpoint changes - #20090

Merged
bwplotka merged 1 commit into
mainfrom
bwplotka/wlog-watcher-restart-series-reset
Oct 26, 2026
Merged

bwplotka merged 1 commit into
mainfrom
bwplotka/wlog-watcher-restart-series-reset

Conversation

@bwplotka

@bwplotka bwplotka commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

Follow-up to #20041 suggested by @kgeckhart.

When the WAL watcher falls far enough behind that head truncation deletes its current segment, (*Watcher).Run restarts, reads lastCheckpoint, and sets w.lastCheckpoint = lastCheckpoint. If garbageCollectSeries never processed that checkpoint before the restart, w.writer.SeriesReset(checkpointIndex) was never called for it, leaving stale series from segments older than checkpointIndex in QueueManager until the next checkpoint.

Call w.writer.SeriesReset(checkpointIndex) in Run after w.readCheckpoint when lastCheckpoint != w.lastCheckpoint.

[PERF] Remote Write: Free stale series from memory immediately when a lagging WAL watcher restarts from a new checkpoint.

When a lagging WAL watcher has its current segment deleted by head truncation, Run restarts and reads the latest checkpoint. If garbageCollectSeries never processed that checkpoint, call w.writer.SeriesReset(checkpointIndex) so stale series from segments older than the checkpoint are dropped immediately instead of retained until the next checkpoint.

Signed-off-by: Bartek Plotka <[email protected]>

@kgeckhart kgeckhart left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@bwplotka
bwplotka merged commit db1d179 into main Oct 26, 2026
39 checks passed
@bwplotka
bwplotka deleted the bwplotka/wlog-watcher-restart-series-reset branch October 26, 2026 06:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants