Skip to content

Conversation

@adityamaru
Copy link
Contributor

@adityamaru adityamaru commented Feb 10, 2026

Summary

Fixed a race condition where git's internal auto-gc (triggered by fetch/clone) would spawn a background daemon holding the mirror mount busy during unmount, causing checkout post-step failures. We now suppress auto-gc during fetch/clone operations (gc.auto=0) and run gc explicitly once with proper timeout and error handling.

Root Cause

git fetch and git clone --mirror trigger gc --auto internally. Since gc.autoDetach defaults to true, this forks a background daemon that holds cwd + mmap'd pack files on the mount. Even though our explicit runMirrorGC() uses gc.autoDetach=false, the background daemon from fetch/clone still blocks unmount.

Changes

  • Added gc.auto=0 to fetch args to suppress auto-gc during mirror refresh
  • Added gc.auto=0 to clone args to suppress auto-gc during initial mirror creation
  • Documented the race condition and solution in code comments

Fixes BLA-3202

🤖 Generated with Claude Code


Note

Low Risk
Small, localized change to git command arguments to prevent background processes; risk is limited to potential differences in GC timing/performance during mirror operations.

Overview
Prevents git mirror cleanup failures by disabling git’s automatic background GC during mirror creation and refresh.

ensureMirror and refreshMirror now pass -c gc.auto=0 to git clone --mirror and git fetch, and add comments explaining that auto-GC can spawn a detached process that keeps pack files/mount busy and blocks unmount; explicit GC remains handled separately.

Written by Cursor Bugbot for commit aec22c0. This will update automatically on new commits. Configure here.

…ent unmount race

git fetch and clone are porcelain commands that trigger gc --auto internally
after completing. Since gc.autoDetach defaults to true, this spawns a background
daemon holding cwd and mmap'd pack files on the mirror mount, blocking the
subsequent umount with EBUSY even though our explicit runMirrorGC() uses
gc.autoDetach=false.

Disable auto-gc during fetch/clone with gc.auto=0 to eliminate the race. This
makes runMirrorGC() the single place gc runs, with proper timeout and error
handling. Fixes unmount failures in post-checkout cleanup (BLA-3202).

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
@adityamaru adityamaru merged commit 41cdeed into main Feb 10, 2026
14 checks passed
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