Skip to content

Only auto-cancel older pipelines - #7345

Merged
6543 merged 1 commit into
woodpecker-ci:mainfrom
savv:codex/fix-pipeline-cancel-race
Nov 9, 2026
Merged

6543 merged 1 commit into
woodpecker-ci:mainfrom
savv:codex/fix-pipeline-cancel-race

Conversation

@savv

@savv savv commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Concurrent webhook handlers can each see the other pipeline in GetActivePipelineList and cancel it, leaving no surviving run.
We observed this on v3.18.1 after two synchronize deliveries for the same PR and commit arrived 61 ms apart: each run recorded the other as superseded_by.
The same cancellation logic is present on current main.
Only cancel pipelines with a lower repository-scoped pipeline number; exclude both the current run and newer runs.
The regression test uses identical active-run snapshots to reproduce both handler orders for PR and push events, and checks that other contexts/events are untouched.

Test: the four ordering cases fail on the original code because both runs are canceled; they pass with this fix.
Test: go test -race -tags test ./server/pipeline -count=1 passes (Go 1.27.2, macOS arm64).

@6543 6543 changed the title fix: only auto-cancel older pipelines Only auto-cancel older pipelines Oct 21, 2026
@6543 6543 added the bug Something isn't working label Oct 21, 2026
@qwerty287

Copy link
Copy Markdown
Contributor

@savv could you check out the linter? https://ci.woodpecker-ci.org/repos/3780/pipeline/38897/31#L3

Signed-off-by: Chris Savvopoulos <chris@green-triangle.com>
@savv
savv force-pushed the codex/fix-pipeline-cancel-race branch from f15cb3f to 4252162 Compare November 9, 2026 08:48
@savv

savv commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

@savv could you check out the linter? https://ci.woodpecker-ci.org/repos/3780/pipeline/38897/31#L3

thanks for the feedback! and sorry for the delay. All addressed.

@savv
savv requested a review from lafriks November 9, 2026 08:53
@6543 6543 added the server label Nov 9, 2026
@6543
6543 enabled auto-merge (squash) November 9, 2026 10:27
@6543
6543 merged commit 96614b3 into woodpecker-ci:main Nov 9, 2026
7 checks passed
@codecov

codecov Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.26%. Comparing base (3c13524) to head (4252162).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7345      +/-   ##
==========================================
+ Coverage   66.16%   66.26%   +0.10%     
==========================================
  Files         449      449              
  Lines       22422    22422              
==========================================
+ Hits        14835    14858      +23     
+ Misses       7587     7564      -23     

☔ 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.

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

Labels

bug Something isn't working server

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants