Repository navigation
fix: recover history writes after long counter gaps - #1184
Conversation
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. |
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_228d7703-0c29-4f30-bbde-bcd60525ce65) |
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_386edb03-0b28-4015-a0e1-ab268066a5b2) |
Several energy counters returning after a long gap can exhaust DuckDB memory inside one telemetry transaction. This also occurs at startup when a former hardware identity briefly becomes current again. Retrying or reopening the database cannot fix a transaction that consumes the same memory on every attempt.
Replace the per-bucket INSERT loop with one INSERT SELECT over the interval's five-minute buckets. Keep the same overlap-weighted energy, provenance, sample counts and conflict updates. History, scalar samples, all energy flows, cursors and the retry receipt still commit together. The database memory limit stays unchanged.
A small fresh-database reproduction with five counters returning after 24 hours and 161 scalar samples failed before the change at 243.9/244.1 MiB. It now passes at the same 256 MB setting. The regression also checks partial first/last buckets, rollback when the last observation is invalid, all five cursor updates and a same-receipt retry without duplicate energy. No large fixture or physical box change was needed.
When history writes are blocked during import, show the current write failure in the import panel and hide the rate/ETA. Recovery and disconnect clear or update that state. The display keeps the first error line and omits DuckDB tuning advice.
Validation: the focused ledger/full-tick tests pass with the race detector (3.236 s). The UI task ran ten focused tests and checked the rendered failure state in a browser using captured box health. Integrated
make verifypassed on the combined ledger/UI change (tests, vet and build). Its first run hit two unchanged control tests at a quarter-hour boundary; both passed in an isolated rerun and in the full rerun. Physical recovery belongs to the beta validation task. This PR does not change device identity selection.