Repository navigation
fix(control): no missing-plan retry while a replan is pending - #1882
Merged
Merged
Conversation
The 5 s missing-plan retry cancelled any solve that took longer, so on a slow box no plan ever landed. Skip the retry while PlanSnapshot().Pending is true. 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 A10 of the stable plan.
Problem
After a restart the box has no plan, and the control tick fires
missing_plan_retryevery 5 s (main.go:3266-3270). It never checks whether a replan is already running. Each new request cancels the one in flight (service.go:1436-1438), and the cancelled result is dropped at publish. PlanStale stays true, so the retry keeps firing.Scenario: a site whose solve takes 6 s, such as an Energyplan site with an hourly import cap, demand charges or many slot-assets (5 s budget, plus input load and the caution pass). Every solve gets cancelled at 5 s. No plan lands until something stops the retry. In the scaled test (tick 20 ms, cooldown 100 ms, solve 120 ms), master started 20 solves in 2 s and published none.
Change
Skip the retry while
mpcSvc.PlanSnapshot().Pendingis true. The check moves into a small helper,missingPlanRetryDue, in a new file so a test can call it. The 5 s cooldown is unchanged. A failed solve clears Pending, so the retry still fires after a failure.Tests
go test ./cmd/ftw/ -run TestMissingPlanRetry -count=1with the guard removed: FAIL, "no plan published after 2 s; 20 solves started".-race -count=3).go test -race ./cmd/ftw/... ./internal/mpc/... -count=1: ok.go vet ./...andgo build ./...: clean.The test comes from the audit repro (caa-45). It now drives the real helper instead of a copy of the main.go condition.
Risk
Low. If a solve hangs and ignores cancel, the retry no longer starts a new one on top of it. Before, the new one could not finish either, since it would be cancelled 5 s later. The worker transports keep their own timeouts (energyplan 7 s, external optimizer
cfg.Timeout).🤖 Generated with Claude Code