fix: prevent git auto-gc from blocking mirror unmount#23
Merged
adityamaru merged 1 commit intomainfrom Feb 10, 2026
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 fetchandgit clone --mirrortriggergc --autointernally. Sincegc.autoDetachdefaults to true, this forks a background daemon that holds cwd + mmap'd pack files on the mount. Even though our explicitrunMirrorGC()usesgc.autoDetach=false, the background daemon from fetch/clone still blocks unmount.Changes
gc.auto=0to fetch args to suppress auto-gc during mirror refreshgc.auto=0to clone args to suppress auto-gc during initial mirror creationFixes 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.
ensureMirrorandrefreshMirrornow pass-c gc.auto=0togit clone --mirrorandgit 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.