Skip to content

fix: enforce RotatingWriter retention across restarts#414

Merged
yulnr merged 1 commit into
dial9-rs:mainfrom
dxiao:dxiao/codex/dial9-restart-retention
May 19, 2026
Merged

fix: enforce RotatingWriter retention across restarts#414
yulnr merged 1 commit into
dial9-rs:mainfrom
dxiao:dxiao/codex/dial9-restart-retention

Conversation

@dxiao
Copy link
Copy Markdown
Contributor

@dxiao dxiao commented May 17, 2026

RotatingWriter enforces max_total_size from its in-memory closed_files queue. After a process restart that queue starts empty, so existing trace.N.bin / trace.N.bin.gz artifacts are not counted toward the disk budget and the writer can start again at trace.0.bin.active.

That means repeated daemon restarts can grow the trace directory past the configured cap.

This makes startup discover retained artifacts for the same base path, seed closed_files oldest-first, and continue writing at the next segment index. Eviction now removes the whole artifact family for a segment (.bin, .bin.gz, and future write-back suffixes), so background-processed files stay under the same budget.

Stale .active files from dead writers are discarded on startup because the worker cannot process them.

@dxiao dxiao force-pushed the dxiao/codex/dial9-restart-retention branch from 85696b2 to 26803ca Compare May 18, 2026 03:20
return None;
}
Some(SegmentArtifact::Retained {
index: index.parse().ok()?,
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.

this won't happen currently but because of how the code works if we ever started producing something like 01 as an index, that could never be deleted.

@yulnr yulnr marked this pull request as ready for review May 19, 2026 11:31
@yulnr
Copy link
Copy Markdown
Collaborator

yulnr commented May 19, 2026

LGTM. I'll follow up with @rcoh comments

@yulnr yulnr added this pull request to the merge queue May 19, 2026
Merged via the queue into dial9-rs:main with commit f52a5cc May 19, 2026
21 checks passed
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.

3 participants