fix: honor execution activity in workflow stale reaper - #5
Closed
ddbaron wants to merge 3 commits into
Closed
Conversation
📊 Coverage gateThresholds from
✅ Gate passedNo surface regressed past the allowed threshold and the aggregate stayed above the floor. |
📐 Patch coverage gateThreshold: 80% on lines this PR touches vs
✅ Patch gate passedEvery surface whose lines were touched by this PR has patch coverage at or above the threshold. |
MarkStaleWorkflowExecutions now repeats its candidate predicates in the conditional UPDATE, but MarkStaleExecutions still only re-checked status. A heartbeat that lands between its candidate selection and that UPDATE therefore still flips a live execution row to timeout — the same false timeout the workflow reaper just stopped producing, through a narrower window (its candidate query reads the clock the heartbeat writes, so the race is the millisecond gap between the two statements rather than the whole run). Give it the same treatment: the conditional UPDATE re-evaluates the activity clock against the sweep cutoff and the non-terminal-child guard, and the body moves behind the same post-selection seam the workflow reaper uses so the interleaving is testable without sleeps. Tests: a real execution-note write landing in that window leaves the row running with its note intact; a seam that writes nothing still reaps the silent row with the existing "no activity" message. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Owner
Author
|
Closing as redundant: this change landed upstream in Agent-Field#1046, merged as squash commit 78215f1. That merge contains both commits from this branch, plus a maintainer commit extending the same race guard to the legacy execution reaper. Nothing in this branch is unmerged, so the fork PR is no longer needed. |
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.
Summary
Problem
The control plane maintains two activity clocks:
executionsandworkflow_executions. Heartbeat/status writes update onlyexecutions.updated_at, while the workflow stale-sweeper read onlyworkflow_executions.updated_at. Productively active leaf executions could therefore be reaped on a frozen clock: four sampled coder executions were reaped 10–13 minutes after start, matching the 10-minute fuse, despite heartbeat notes arriving every 90 seconds and file commits continuing afterward. Late completions then hit terminal records and returned HTTP 409s.Solution
This implements the read-path fix: workflow reaping considers the newer of the workflow clock and the active paired execution clock, so both clocks must exceed the fuse before reaping. Terminal legacy rows are not treated as active activity, allowing the ordered cleanup passes to finish synchronizing both tables. This adds no heartbeat write load and makes activity in the execution record visible to the workflow reaper. It deliberately does not extend the timeout or change the SDK, SWE-AF node, or delivery semantics.
Validation
cd control-plane && go test ./internal/storage -count=1cd control-plane && go test ./internal/storage ./internal/handlers -count=1cd control-plane && go vet ./...gofmtandgit diff --checkThe repository
make lintcommand was attempted, butgolangci-lintandruffare not installed in this environment. The full control-plane suite was also attempted; it has unrelated failures in unmodified package/server tests, while the affected storage and handler packages pass.