summaryrefslogtreecommitdiff
path: root/internal/executor/executor.go
diff options
context:
space:
mode:
authorPeter Stone <thepeterstone@gmail.com>2026-03-15 23:32:14 +0000
committerPeter Stone <thepeterstone@gmail.com>2026-03-15 23:32:14 +0000
commitb91636be171bc8e43a3dba1b54f78e2048356ab1 (patch)
treeaa1e6bad56a09a438d31b8262bdef8ed5a61ad76 /internal/executor/executor.go
parent52f6bdee9297b48938242d3ac843cc054d7dbcaa (diff)
fix: promote stale BLOCKED parent tasks to READY on server startup
When the server restarts after all subtasks complete, the parent task was left stuck in BLOCKED state because maybeUnblockParent only fires during a live executor run. RecoverStaleBlocked() scans all BLOCKED tasks on startup and re-evaluates them using the existing logic. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/executor/executor.go')
-rw-r--r--internal/executor/executor.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/internal/executor/executor.go b/internal/executor/executor.go
index f85f1ff..c07171b 100644
--- a/internal/executor/executor.go
+++ b/internal/executor/executor.go
@@ -634,6 +634,21 @@ func (p *Pool) RecoverStaleQueued(ctx context.Context) {
}
}
+// RecoverStaleBlocked promotes any BLOCKED parent task to READY when all of its
+// subtasks are already COMPLETED. This handles the case where the server was
+// restarted after subtasks finished but before maybeUnblockParent could fire.
+// Call this once on server startup, after RecoverStaleRunning and RecoverStaleQueued.
+func (p *Pool) RecoverStaleBlocked() {
+ tasks, err := p.store.ListTasks(storage.TaskFilter{State: task.StateBlocked})
+ if err != nil {
+ p.logger.Error("RecoverStaleBlocked: list tasks", "error", err)
+ return
+ }
+ for _, t := range tasks {
+ p.maybeUnblockParent(t.ID)
+ }
+}
+
// terminalFailureStates are dependency states that cause the waiting task to fail immediately.
var terminalFailureStates = map[task.State]bool{
task.StateFailed: true,