Repository navigation
fix(state): one unreadable Parquet file never stops boot - #1901
Conversation
AbsorbColdHistory returned the first read error, and main.go exits on it. The bad file stayed in place, so every restart failed the same way. Now an unreadable bucket file is logged, kept for recovery and listed as unreadable_cold_files in the history health report. The other days import, and the day's older legacy copy is used when it reads. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 704ec9a7c0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } | ||
| var kept []string | ||
| for path := range unreadable { | ||
| keep[path] = true |
There was a problem hiding this comment.
Exclude retained unreadable files from history queries
When a damaged bucket file is retained here, every history query spanning that day still discovers it through aggregatePaths. In series_archive.go, walkMergedSeriesStatsBinned then falls back to walkAggregateSeries, which calls walkBucketFile on the damaged file and propagates its read error. Consequently, charts and exports spanning that day fail even for unrelated metrics or when the legacy fallback was successfully imported into SQLite. Keep the file for recovery, but exclude known-unreadable files from normal history discovery so the successfully imported data remains queryable.
Useful? React with 👍 / 👎.
The first version kept a damaged DD.buckets.parquet at its normal name. aggregatePaths still found it, so every series query over that day failed with the Parquet error, on every boot. Rename the file to DD.buckets.parquet.unreadable instead. No reader, importer or converter opens a name that does not end in .parquet. List these files in history health on every boot. Keep the day's legacy copy on disk, unimported, while its original is unreadable. It serves reads for the day. Importing it would make a good copy of the original, restored later, conflict with the stored hours and stop boot with "archive differs from stored hour". Tests open the store with the same cold folder for reads and absorb, as main.go does, and cover a restored original. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Item F3 of the stable plan.
Problem
At boot,
main.gocallsAbsorbColdHistoryand exits on any error. One damaged bucket file in the cold folder makesAbsorbColdHistoryreturn at the first read error (history_plain.go:229-243). The file stays in place, so systemd restarts Core every 5 s and it fails the same way each time. The site gets no control until someone moves the file by hand.Scenario: a cold folder holds two days. One file reads well; the next day's
.buckets.parquetis cut to half its size, as a bad copy would leave it. On master, boot stops withread 18.buckets.parquet: invalid magic footer of parquet file, and the cleanup of the good day never runs.Change
slog.Warnand renamed toDD.buckets.parquet.unreadable. The other days import and the cleanup runs..parquet, so the history readers (aggregatePaths), the cold converter and backup verification skip it. Day views, CSV exports and wide charts over that day keep working. With the file left at its normal name, every series query over the day failed with the Parquet error (review finding, and Codex P2 on the first version)..buckets.parquetis unreadable, its.legacy-buckets.parquetstays on disk, unimported, and serves reads for the day. Importing it would put its hours inhistory.db; a good copy of the original restored later would then differ from those hours, and boot would stop witharchive differs from stored hour. Now a restored original (put back under its normal name) imports on the next boot, and the legacy copy goes with no conflict./api/healthlists moved files underhistory_storage.unreadable_cold_fileson every boot, found by name, so the fault does not pass in silence.main.gois unchanged.Tests
TestAbsorbColdHistorySkipsUnreadableBucketFile, from the audit reproTestReproAbsorbColdHistoryCorruptDayFailsAll(caa-135). It runs for a truncated file and for a file with no read permission. It opens the store with the same cold folder for reads and for absorb, asmain.godoes. Over two boots it checks that the good day imports, the damaged file is moved aside and listed, the legacy copy stays and serves its hour, and series reads over the day succeed for the damaged metric and an unrelated one (maxPoints0 and 200), and for a year chart.TestAbsorbColdHistoryImportsRestoredBucketFile: a damaged file whose legacy copy holds one of its two minutes. After the first boot, a good copy goes back under the normal name. The second boot succeeds, the hour holds both minutes, both files go and nothing is listed.cd go && go test -race ./internal/state/...: okcd go && go test -race -run 'Health|Storage|History' ./internal/api/: okcd go && go vet ./internal/state ./cmd/ftw && go build ./...: okRisk
Low. Only the boot import of old bucket files changes. A damaged file now stays on disk under a new name across boots, where before it stopped boot. A file with no read permission still fails a backup, as before.
🤖 Generated with Claude Code