From 0d3fe95522929701c38ce6bdf64b42ca3d0a5f1d Mon Sep 17 00:00:00 2001 From: m3taversal Date: Wed, 15 Apr 2026 17:13:32 +0100 Subject: [PATCH] Add config.lock retry with jitter to both worktree-add sites Parallel domain merges race on the bare repo's config file. The single retry only covered one of two worktree-add call sites and used fixed delay. Now both sites retry up to 3 times with increasing jitter. Co-Authored-By: Claude Opus 4.6 (1M context) --- lib/merge.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/merge.py b/lib/merge.py index bac96da..a84e109 100644 --- a/lib/merge.py +++ b/lib/merge.py @@ -318,8 +318,10 @@ async def _cherry_pick_onto_main(branch: str) -> tuple[bool, str]: # Delete stale local branch if it exists from a previous failed attempt await _git("branch", "-D", clean_branch) rc, out = await _git("worktree", "add", "-b", clean_branch, worktree_path, "origin/main") - if rc != 0 and "could not lock config" in out: - await asyncio.sleep(random.uniform(0.5, 2.0)) + for _retry in range(3): + if rc == 0 or "could not lock config" not in out: + break + await asyncio.sleep(random.uniform(0.5, 2.0 * (_retry + 1))) await _git("branch", "-D", clean_branch) rc, out = await _git("worktree", "add", "-b", clean_branch, worktree_path, "origin/main") if rc != 0: @@ -577,6 +579,12 @@ async def _merge_reweave_pr(branch: str) -> tuple[bool, str]: await _git("worktree", "remove", "--force", worktree_path) await _git("branch", "-D", clean_branch) rc, out = await _git("worktree", "add", "-b", clean_branch, worktree_path, "origin/main") + for _retry in range(3): + if rc == 0 or "could not lock config" not in out: + break + await asyncio.sleep(random.uniform(0.5, 2.0 * (_retry + 1))) + await _git("branch", "-D", clean_branch) + rc, out = await _git("worktree", "add", "-b", clean_branch, worktree_path, "origin/main") if rc != 0: return False, f"worktree add failed: {out}"