Skip to content

perf(pipeline): post per-workflow commit statuses once and concurrently - #7024

Open
slayerjain wants to merge 11 commits into
woodpecker-ci:mainfrom
slayerjain:pipeline-status-perf
Open

slayerjain wants to merge 11 commits into
woodpecker-ci:mainfrom
slayerjain:pipeline-status-perf

Conversation

@slayerjain

@slayerjain slayerjain commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

Split out of #6851 as requested. This one only has the pipeline status posting changes, the GraphQL config fetch was the other half and got merged as #7025.

Two related changes to the pipeline creation path. We run pipelines with 60+ workflows and these were where most of the time went.

1. Post per-workflow commit statuses concurrently

updatePipelineStatus posted one status per workflow, one after the other. For a pipeline with 63 workflows that alone takes tens of seconds. Statuses now go out with a concurrency of 4. That's low on purpose, forges rate limit concurrent writes from one user a lot harder than sequential ones.

It also fixes the old loop stopping at the first error, which left all remaining workflows without a status. Now every workflow is attempted, failures are logged per workflow, and there's a summary line if any failed.

2. Post forge statuses only once before start

Creating a pipeline posted the full set of per-workflow statuses three times before it started (after compile, on the pending transition and again in start()), all with the same pending state. Approve and restart did the same double posting.

The pubsub events stay for the UI, but forge statuses are now posted once, in start(). Blocked pipelines post theirs in the blocked branch since they never reach start().

On our instance (63 workflows, webhook to first workflow start) 1 + 2 took it from about 91s median to about 2s. That was measured with a concurrency of 10 and it's 4 here, so expect a bit more. Most of the win comes from dropping the two redundant rounds anyway.

Status ordering

With posts running concurrently, the same status posted from pipeline start and from an agent's Init/Done could reach the forge out of order and leave GitHub on pending after success. Posts of the same status now go one at a time, and each post re-reads the workflow and pipeline from the store, so whatever reaches the forge last carries the latest persisted state. A single post is capped at 30s and the wait for its turn at 2m, so one hung request can't hold up later posts forever.

Failure path

A failure in start() used to leave the pipeline pending forever, with pending commit statuses. Now the pipeline, its workflows and their steps move to error and the terminal statuses get posted, the same way decline.go does it.

There's also a debug-level timing line per phase (hook parse, config fetch, compile, status publishing, start) to help find whatever latency is left.

Posting one commit status per workflow sequentially delays the start of
pipelines with many workflows by tens of seconds (3 rounds x workflows
sequential forge calls before start). Post them with bounded concurrency
instead, and log a per-phase timing summary (hook parse, config fetch,
compile, status publishing, start) to locate remaining latency.

Signed-off-by: slayerjain <shubhamkjain@outlook.com>
Pipeline creation, approval and restart each posted the full set of
per-workflow commit statuses up to three times before the pipeline
started (after compile, on the pending transition and in start()),
all with identical pending states. Post them once, in start(), and only
publish the pubsub events for the earlier transitions.

Also harden the start() failure path: the pipeline and its workflows
now transition to error and post terminal statuses, instead of leaving
the pipeline pending forever.

Signed-off-by: slayerjain <shubhamkjain@outlook.com>
@woodpecker-bot

woodpecker-bot commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

Account with some automation detected 🤖🧑‍💻

@slayerjain

We noticed a mix of typical human activity and some patterns often associated with automation or AI agents.

Human? 57% likely to be a human.

Signal Points Detail
High PR volume (weekly) +43 64 PRs within a single 7-day window

Have thoughts about this account? Let the community know.

🕵🏽 Analyzed 300 public events via AgentScan

@woodpecker-bot

woodpecker-bot commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

Surge PR preview deployment succeeded. View it at https://woodpecker-ci-woodpecker-pr-7024.surge.sh

@codecov

codecov Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.08264% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.92%. Comparing base (7115035) to head (4f8204a).
⚠️ Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
server/pipeline/create.go 88.09% 5 Missing ⚠️
server/pipeline/helper.go 96.49% 2 Missing ⚠️
server/pipeline/restart.go 71.42% 2 Missing ⚠️
server/pipeline/approve.go 80.00% 1 Missing ⚠️
server/pipeline/decline.go 0.00% 1 Missing ⚠️
server/rpc/rpc.go 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7024      +/-   ##
==========================================
+ Coverage   67.60%   67.92%   +0.31%     
==========================================
  Files         452      453       +1     
  Lines       22867    22993     +126     
==========================================
+ Hits        15459    15617     +158     
+ Misses       7408     7376      -32     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread server/pipeline/helper.go Resolved
@6543 6543 self-assigned this Sep 26, 2026
…rder

start() queues a pipeline's workflows and then posts a status for each of
them from the pipeline's in-memory copy, in which every workflow is still
pending. With many workflows that takes a while (about 20s for 87 of them
at 4 concurrent posts), and an agent can run a short workflow to the end
meanwhile: its Init and Done post running and success, and the pipeline's
post of it lands after them with pending. A forge keeps the status posted
last, so the workflow shows pending forever. Over 20 pull-request
pipelines of one repo, 6 statuses were left pending that way and 182 went
back from running to pending while running.

Every status post now goes through PostWorkflowStatus, which posts the
workflow's (and for a deploy, the pipeline's) state as persisted when the
post is sent, and posts one status at a time: every state change is
persisted before it is posted, so the post that reaches the forge last
carries the latest state. Posts of different workflows still run
concurrently; a deploy pipeline's posts, which all set its one deployment,
are ordered across its workflows.

Signed-off-by: slayerjain <shubhamkjain@outlook.com>
Signed-off-by: slayerjain <shubhamkjain@outlook.com>
PostWorkflowStatus posts while holding the status's lock, and the forge
clients set no HTTP timeout of their own. A hung request therefore held up
every later post of the same status, including an agent's Init and Done. For
a deploy pipeline, whose workflows all share one lock, the last of N queued
posts waited N times as long, and the RPC path's context has no deadline to
cut that short.

Bound the post itself with a 30s deadline taken once the lock is held, and
bound the wait for the lock with the caller's context and a 2m limit, so a
post's worst case no longer grows with the queue. Addon forges ignore the
context and stay unbounded.

Past these bounds delivery is best effort. Abandoning a request does not stop
a forge that already received it, so ordering is no longer guaranteed, and a
post whose wait is abandoned is dropped without a retry: if the forge hangs
for longer than the bound and that post was the last one for its status, the
forge keeps the earlier state. Before this, such a post hung indefinitely.

Refresh the pipeline's Started/Finished along with its status - Bitbucket
Datacenter derives a duration from them - and the workflow's Error, Started
and Finished along with its state, which addon forges receive.

Tests: a failing test in the release/held pattern returned before releasing
its held post, leaving the key locked in the package-global statusLocks and
hanging the package to its timeout; release via t.Cleanup instead, and put a
watchdog on the waits so a wait that stops honoring its context fails
rather than hangs. Cover keyedMutex's refcounting under contention and on
abandoned waits, that a queued post still gets its whole budget, that a wait
gives up with its context and is bounded without one, and the refreshed
fields.

Signed-off-by: slayerjain <shubhamkjain@outlook.com>
@slayerjain

Copy link
Copy Markdown
Contributor Author

Updated:

  • wg.Go() as suggested (578bae1).
  • Fixed a race that the concurrent posting here makes more likely: posts of the same status from pipeline start and from an agent's Init/Done could reach the forge out of order, leaving GitHub on pending after success. Posts of one status are now serialized and send the state re-read from the store (4542f7b).
  • Bounded those posts, since they now run under a shared lock and the forge clients set no HTTP timeout: 30s per post, 2m to wait for the lock (c85f66c).

Merged current main; golangci-lint and -race tests are clean.

6543 and others added 3 commits October 20, 2026 09:33
Signed-off-by: slayerjain <shubhamkjain@outlook.com>
Create, Approve and Restart post each workflow's status once, from
start(), and a blocked pipeline posts its own round since it never gets
there. When start() fails, the pipeline, its workflows and their steps
have to end up in error, and that is what the forge gets. None of this
was covered, so dropping any of those posts or transitions went
unnoticed.

The harness keeps what Create & co. persist like a store would, so the
posts re-read the same state they would in production.

Also say in PostWorkflowStatus what gets posted when persisting a state
change failed.

Signed-off-by: slayerjain <shubhamkjain@outlook.com>
@slayerjain

Copy link
Copy Markdown
Contributor Author

Merged main. The conflicts were mostly with #7516 and #7520, cancel keeps the not-started handling from #7516 and posts through updatePipelineStatus like everything else.

Also added tests for when statuses get posted (4f8204a): once for Create, Approve and Restart, the blocked case, and start failures. None of that was covered before, so dropping any of those posts didn't fail anything.

Description is updated, the ordering fix from my last comment is in there now. -race tests and golangci-lint are clean.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants