Repository navigation
fix(forecast): save the forecast identity outside the lock - #1883
Merged
Merged
Conversation
RefreshIdentity held forecastSiteConfig.mu across two SaveConfig calls, each up to 5 s against a busy SQLite writer. The control tick's Snapshot waited behind them. Compute under the lock, save after it, and wait 30 s before retrying a failed binding save. Configure's weather generation save moves out of the lock the same way. 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Item A9 of the stable plan (reports/stable-plan-20261027.md).
Problem
RefreshIdentityholdsforecastSiteConfig.muwhile it callsSaveConfigtwice: the identity binding (forecast_site.go:254) andconfig_revision(:262). Each save runs under a 5 s context withbusy_timeout(5000). While another writer holds the SQLite write lock, one refresh holds the lock for about 10 s. The control tick callsSnapshot(), which takes a read lock on the same mutex (main.go:3073, 3316, 2973), so the tick waits too. At a 5 s tick that drops about two ticks, and fuse and watchdog reactions come late.A failed binding save leaves
bindingDirtyset, and the 1 Hz identity poll tries again every second with no pause.Repro on master (from the audit, caa-49):
Snapshot waited 10.07s; RefreshIdentity took 10.17s.Change
RefreshIdentitycomputes the receipt and revision unders.mu, drops the lock, then saves. A successful binding save clearsbindingDirtyunder the lock. Callers already serializeRefreshIdentityunderforecastConfigMu, so the saves keep their order.bindingRetryAt30 s ahead. The poll skips the binding save until then. The binding stays dirty, so the next try still happens.Configuresaves the weather generation receipt after it dropss.mu, the same way.Tests
TestForecastSnapshotDoesNotWaitForIdentitySave(the audit repro, renamed): fails on master with a 10 s wait, passes here (Snapshot waited 31µs).TestForecastIdentityBindingSaveBacksOffAfterFailure: a failed save is not retried within 30 s and is retried after.cd go && go test -race ./cmd/ftw/... -count=1: ok (177 s).go vet ./...andgo build ./...: clean.Risk
Low. Only the time of the writes moves; what gets written is unchanged. During the 30 s pause after a failed save, the in-memory learning revision is already in use, as it was before when a save failed.
🤖 Generated with Claude Code