Skip to content

Conversation

@khanhtc1202
Copy link
Member

What this PR does:

SSIA

Why we need it:

The current implementation of the report stage command causes a deadlock.

Here's the problematic flow:

  • ReportStageCommandsHandled acquires a read lock (s.mu.RLock()) on line 287
  • Inside the loop (line 303), it calls s.reportCommandHandled
  • reportCommandHandled tries to acquire a write lock (s.mu.Lock()) on line 259
  • The write lock is blocked because the read lock is still held!

As a result, the WAIT_APPROVAL stage execution finished by plugin and stage status reported successfully, but as a part of stage execution on the piped side (ref: scheduler.go#L357-L358), this report stage's command will hold the piped stage execution routine, thus the stage will run forever (can not process to the next stage or finish deployment).

This change to fix that deadlock.

Which issue(s) this PR fixes:

Fixes #

Does this PR introduce a user-facing change?:

  • How are users affected by this change:
  • Is this breaking change:
  • How to migrate (if breaking change):

Signed-off-by: khanhtc1202 <khanhtc1202@gmail.com>
@codecov
Copy link

codecov bot commented Oct 9, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 28.81%. Comparing base (7625a37) to head (d2618ac).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6302      +/-   ##
==========================================
+ Coverage   28.75%   28.81%   +0.05%     
==========================================
  Files         560      560              
  Lines       59858    59867       +9     
==========================================
+ Hits        17215    17251      +36     
+ Misses      41322    41295      -27     
  Partials     1321     1321              
Flag Coverage Δ
. 23.29% <100.00%> (+0.07%) ⬆️
.-pkg-app-pipedv1-plugin-analysis 32.64% <ø> (ø)
.-pkg-app-pipedv1-plugin-kubernetes 58.35% <ø> (ø)
.-pkg-app-pipedv1-plugin-kubernetes_multicluster 67.63% <ø> (ø)
.-pkg-app-pipedv1-plugin-scriptrun 54.83% <ø> (ø)
.-pkg-app-pipedv1-plugin-terraform 38.65% <ø> (ø)
.-pkg-app-pipedv1-plugin-wait 33.92% <ø> (ø)
.-pkg-app-pipedv1-plugin-waitapproval 52.71% <ø> (ø)
.-pkg-plugin-sdk 50.34% <ø> (ø)
.-tool-actions-gh-release 19.23% <ø> (ø)
.-tool-actions-plan-preview 25.51% <ø> (ø)
.-tool-codegen-protoc-gen-auth 0.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 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.

@khanhtc1202 khanhtc1202 merged commit 27aca15 into master Oct 9, 2025
46 checks passed
@khanhtc1202 khanhtc1202 deleted the fix-stage-commnd-report-deadlock branch October 9, 2025 08:14
@github-actions github-actions bot mentioned this pull request Dec 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants