Skip to content

fix(server): wait one tick before the first queued-workflow reaper pass (RIG-11227) - #181

Closed
rigel-mintaka wants to merge 1 commit into
rigel-releasefrom
ci-pipelines/rig-11227-wait-one-tick-before-the-first-queued
Closed

rigel-mintaka wants to merge 1 commit into
rigel-releasefrom
ci-pipelines/rig-11227-wait-one-tick-before-the-first-queued

Conversation

@rigel-mintaka

@rigel-mintaka rigel-mintaka commented Nov 20, 2026 •

Copy link
Copy Markdown

What does this do

The queued-workflow reaper now waits one full tick before its first pass, so it no longer runs at server startup. The finalized queued workflow log line now names the dependency that blocked the workflow (dependency_workflow_id).

Why do we need it

When the server restarts, agents have not reconnected yet. A reaper pass at that moment can finalize workflows that are still alive. When the reaper does finalize a workflow, the log line did not say which dependency caused it, which made stalls hard to trace.

Summary

  • cmd/server/server.go: the inline loop becomes runOrphanReaper(ctx, ticks, reap). Nothing runs before the first tick. The interval is unchanged.
  • server/pipeline/pending_timeout.go: the new failedDependency helper returns the first dependency whose status alone makes ShouldRun() false, and the finalize log carries it.
  • New tests: TestRunOrphanReaperWaitsOneTickBeforeFirstPass, using synctest and an injected tick channel, and TestFinalizeDeadWorkflowsLogsFailedDependency, a 3-case table that includes a failure-only dependent.

Verification

  • CGO_ENABLED=1 go test -count=1 -tags test ./cmd/server ./server/pipeline: ok for both packages.
  • Each new test fails on the old code: "reaper ran before the first tick", and "Not equal" in all 3 cases.
  • Independent review: no findings.

Risks

After a restart, a truly orphaned workflow is finalized up to one interval later (5m by default).

Spec impact

Spec-impact: none.

Checks skipped: macpro2013 paused (RIG-11141); package tests ran locally with CGO=1 and passed

Refs RIG-11227

Co-authored-by: Matt Wilkinson matt@rigel.build

…ss (RIG-11227)

A restart reaped the whole persisted backlog in its first pass, finalizing 74 queued workflows as dependency-failed at once. The reaper now waits one interval before its first pass, and the dependency-failed finalize log names the failing dependency workflow ID.

Co-Authored-By: Matt Wilkinson <matt@rigel.build>

Co-authored-by: Matt Wilkinson <matt@rigel.build>
@linear-code

linear-code Bot commented Nov 20, 2026

Copy link
Copy Markdown

RIG-11227

@rigel-mintaka

Copy link
Copy Markdown
Author

Review round 1 (opus review, head 21240dd0): 0 high, 0 medium, 0 low.

  • Checked: context cancel, ticker ownership, no goroutine leak, interval unchanged, and that failedDependency names the right dependency for both run-on-success and failure-only dependents.
  • Both new tests fail on the old code (checked against a restored copy) and use synctest with no sleeps.
  • CGO_ENABLED=1 go test -count=1 -tags test ./cmd/server ./server/pipeline: ok.
  • The pushed diff matches the reviewed commit.

Fork CI will be red until RIG-11518 (the Petrel replay 403) is fixed; that is not caused by this change.

All-clear at 4fad3bd

@rigel-mintaka

Copy link
Copy Markdown
Author

All-clear at 4fad3bd
Base: rigel-release

@rigel-mintaka

Copy link
Copy Markdown
Author

Moved to RigelBuild/nebula#192 (RIG-10145 fork archive).

rigel-nemo Bot pushed a commit to RigelBuild/nebula that referenced this pull request Nov 21, 2026
…ss (RIG-11227) (#192)

The orphan reaper ran once at server startup, before agents had reconnected, and could finalize workflows that were still alive. The inline loop becomes runOrphanReaper, which waits one tick before its first pass. The interval is unchanged.

The finalized queued workflow log line now carries dependency_workflow_id, the dependency that blocked the workflow.

Ported from RigelBuild/woodpecker#181.

Co-authored-by: Matt Wilkinson <matt@rigel.build>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant