fix(backend): give each report file a name of its own (closes #61)
check / check (push) Successful in 49s

Report files were named by a millisecond timestamp and created with
O_EXCL, so two flushes in the same millisecond, such as a flush for
size and the final flush at shutdown, got the same name and the second
failed, losing its reports. Each name now carries a number after the
timestamp that goes up by one for each file the server starts to
write, so names still sort by time and never repeat within a run; a
failed write leaves a gap in the numbers. The buffer reads the time
through a clock the new test stops, so its two flushes share one
timestamp on every run; the 1 ms pauses earlier tests used to dodge
the collision are gone.

Model: opus-5-5
This commit is contained in:
2026-09-29 04:23:25 +00:00
parent ced1956b06
commit f665ab17bc
5 changed files with 114 additions and 15 deletions
+7 -3
View File
@@ -102,9 +102,13 @@ which `netwatch` owns.
### Report storage
Reports are written as `reports-<timestamp>.jsonl.zst` files in `DATA_DIR`.
Each file contains one JSON object per line, compressed with zstd. Files are
created with `O_EXCL` to prevent overwrites.
Reports are written as `reports-<timestamp>-<number>.jsonl.zst` files in
`DATA_DIR`. The timestamp is in UTC to the millisecond, so the names sort by
time. The number starts at 1 when the server starts and goes up by one for each
file the server starts to write, so two files written in the same millisecond
still get different names, and a failed write leaves a gap in the numbers. Each
file contains one JSON object per line, compressed with zstd. Files are created
with `O_EXCL` to prevent overwrites.
### Report limits