Sitelet https://github.com/pipe-cd/pipecd/pull/7201
Skip to content

Fix git worktree race condition issue - #7201

Merged
khanhtc1202 merged 1 commit into
masterfrom
fix-git-worktree-race-condition
Aug 21, 2026
Merged

khanhtc1202 merged 1 commit into
masterfrom
fix-git-worktree-race-condition

Conversation

@khanhtc1202

@khanhtc1202 khanhtc1202 commented Aug 21, 2026 •

Copy link
Copy Markdown
Member

What this PR does:

  • Add a mutex for worktree to the repo structure, call it in Copy, and places that work with git worktree command to avoid race condition when multiple worktree add command calls to the same repo
  • Change some repo method from value receiver to pointer receiver to keep the repo type methods consistent

Why we need it:

There was a race condition reported by users, when the piped runs multiple workers (approximately 13) that execute git worktree add in parallel on the same repository. Running multiple add commands simultaneously causes the underlying git directories to vanish mid-process, resulting in failed to read common dir or could not open gitdir errors.

Which issue(s) this PR fixes:

Follow PR #5412
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>
@khanhtc1202
khanhtc1202 requested a review from a team as a code owner August 21, 2026 07:29
@netlify

netlify Bot commented Aug 21, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for pipecd-site canceled.

Name Link
🔨 Latest commit 6c71907
🔍 Latest deploy log https://app.netlify.com/projects/pipecd-site/deploys/6a87fe5599c9d80008687e38

@codecov

codecov Bot commented Aug 21, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 68.42105% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 29.53%. Comparing base (fccc8cc) to head (6c71907).

Files with missing lines Patch % Lines
pkg/git/repo.go 68.42% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7201      +/-   ##
==========================================
- Coverage   29.54%   29.53%   -0.01%     
==========================================
  Files         601      601              
  Lines       64336    64352      +16     
==========================================
+ Hits        19005    19009       +4     
- Misses      43850    43862      +12     
  Partials     1481     1481              
Flag Coverage Δ
. 23.36% <68.42%> (+<0.01%) ⬆️
.-pkg-app-pipedv1-plugin-analysis 32.43% <ø> (ø)
.-pkg-app-pipedv1-plugin-ecs 31.74% <ø> (ø)
.-pkg-app-pipedv1-plugin-kubernetes 58.39% <ø> (ø)
.-pkg-app-pipedv1-plugin-kubernetes_multicluster 59.62% <ø> (ø)
.-pkg-app-pipedv1-plugin-scriptrun 54.83% <ø> (ø)
.-pkg-app-pipedv1-plugin-terraform 38.46% <ø> (ø)
.-pkg-app-pipedv1-plugin-wait 33.04% <ø> (ø)
.-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 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.

@rahulshendre rahulshendre left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@khanhtc1202
khanhtc1202 merged commit 71bb32f into master Aug 21, 2026
98 of 101 checks passed
@khanhtc1202
khanhtc1202 deleted the fix-git-worktree-race-condition branch August 21, 2026 12:27
srinivasr pushed a commit to srinivasr/pipecd that referenced this pull request Aug 24, 2026
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