Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/admin-audit-compaction-bound.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
---

fix(admin): keep the admin audit log bounded across restarts and retry a failed compaction

`<config>/admin-audit.jsonl` was compacted once every 2,000 appends by an in-process counter, so restarting the relay more often than that, or a compaction that kept failing (the counter was reset before the attempt), let the file grow without bound, and every compaction staged through one shared file name. An append now counts the file itself (once per process, and again when the file is not the length this process left it) and compacts at 4,000 entries to the newest 2,000; a failed compaction is logged and retried by the next append, which still reports its entry as written; each compaction stages through an exclusive per-process `.admin-audit.<pid>.<n>.tmp`; and an append whose count finds the last line cut short by an interrupted write starts a new line, so that fragment no longer swallows the entry. Deliberate limits: while a compaction keeps failing the file keeps growing; a rewrite that leaves the file at exactly the length this process left is not noticed until the next compaction; and an entry another process appends during a compaction can still be lost, so one config directory keeps one writer.
Loading
Loading