[PATCH 09/11] builtin/maintenance: fix locking race when packing refs and reflogs
- From
Patrick Steinhardt <ps@pks.im>
- Date
- May 27, 2025, 14:04 UTC
- Message-ID
- <20250527-b4-pks-maintenance-ref-lock-race-v1-9-e1ceb2dea66e@pks.im>
- In-Reply-To
- <20250527-b4-pks-maintenance-ref-lock-race-v1-0-e1ceb2dea66e@pks.im>
As explained in the preceding commit, git-gc(1) knows to detach only after it has already packed references and reflogs. This is done to avoid racing around their respective lockfiles.
Adapt git-maintenance(1) accordingly and run the "pack-refs" and "reflog-expire" tasks before detaching. Note that the "gc" task has the same issue, but the fix is a bit more involved there and will thus be done in a subsequent commit.
Signed-off-by: Patrick Steinhardt <ps@pks.im> --- builtin/gc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/builtin/gc.c b/builtin/gc.c index 57f3bbf5344..e5d1114bd2d 100644 --- a/builtin/gc.c +++ b/builtin/gc.c @@ -1577,12 +1577,12 @@ static const struct maintenance_task tasks[] = { }, [TASK_PACK_REFS] = { .name = "pack-refs", - .after_detach = maintenance_task_pack_refs, + .before_detach = maintenance_task_pack_refs, .auto_condition = pack_refs_condition, }, [TASK_REFLOG_EXPIRE] = { .name = "reflog-expire", - .after_detach = maintenance_task_reflog_expire, + .before_detach = maintenance_task_reflog_expire, .auto_condition = reflog_expire_condition, }, [TASK_WORKTREE_PRUNE] = {
-- 2.49.0.1266.g31b7d2e469.dirty