Check gc.pid in addition to FETCH_HEAD.lock before cleaning temp packs
The removeNewTemporaryPackFiles cleanup used a set-difference that could capture tmp_pack_* files created by concurrent git operations (e.g. git gc, git repack) that don't hold FETCH_HEAD.lock. Expand the lock check to also detect gc.pid, which git gc creates for the duration of garbage collection.
This commit is contained in:
1 file changed
+13
-8
@@ -968,7 +968,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
|
||||
];
|
||||
});
|
||||
|
||||
const hasActiveFetchLock = Effect.fn("GitVcsDriver.hasActiveFetchLock")(function* (
|
||||
const hasActiveGitPackLock = Effect.fn("GitVcsDriver.hasActiveGitPackLock")(function* (
|
||||
gitCommonDir: string,
|
||||
): Effect.fn.Return<boolean> {
|
||||
const lockPaths = yield* listFetchHeadLockPaths(gitCommonDir);
|
||||
@@ -988,6 +988,14 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
|
||||
return true;
|
||||
}
|
||||
}
|
||||
const gcPidExists = yield* fileSystem.exists(path.join(gitCommonDir, "gc.pid")).pipe(
|
||||
Effect.catchTags({
|
||||
PlatformError: () => Effect.succeed(false),
|
||||
}),
|
||||
);
|
||||
if (gcPidExists) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
@@ -1004,13 +1012,10 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
|
||||
if (newFiles.length === 0) {
|
||||
return;
|
||||
}
|
||||
if (yield* hasActiveFetchLock(gitCommonDir)) {
|
||||
yield* Effect.logWarning(
|
||||
"Skipped temporary Git pack cleanup while a fetch lock is active",
|
||||
{
|
||||
temporaryPackCount: newFiles.length,
|
||||
},
|
||||
);
|
||||
if (yield* hasActiveGitPackLock(gitCommonDir)) {
|
||||
yield* Effect.logWarning("Skipped temporary Git pack cleanup while a git lock is active", {
|
||||
temporaryPackCount: newFiles.length,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user