fix: replace worktrees with fresh clones, fix watchdog issue filing
- Workers now git clone --depth=1 per issue instead of sharing base repos with worktrees. Eliminates all contention and branch collision errors. - Watchdog file_issue uses temp file + sys.argv for safe JSON escaping - Watchdog zombie detection only kills processes >5min old (was killing legitimate git pushes from active workers) - Simplified cleanup to plain rm -rf (no worktree bookkeeping needed) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -85,16 +85,9 @@ with open('$ACTIVE_FILE', 'r+') as f:
|
||||
" 2>/dev/null
|
||||
}
|
||||
|
||||
cleanup_worktree() {
|
||||
local wt="$1" branch="$2"
|
||||
if [ -d "$wt" ]; then
|
||||
local parent
|
||||
parent=$(git -C "$wt" rev-parse --git-common-dir 2>/dev/null | sed 's|/.git$||' || true)
|
||||
[ -n "$parent" ] && [ -d "$parent" ] && cd "$parent"
|
||||
git worktree remove --force "$wt" 2>/dev/null || rm -rf "$wt"
|
||||
git worktree prune 2>/dev/null
|
||||
git branch -D "$branch" 2>/dev/null || true
|
||||
fi
|
||||
cleanup_workdir() {
|
||||
local wt="$1"
|
||||
rm -rf "$wt" 2>/dev/null || true
|
||||
}
|
||||
|
||||
get_next_issue() {
|
||||
@@ -283,39 +276,19 @@ run_worker() {
|
||||
log "WORKER-${worker_id}: === ISSUE #${issue_num}: ${issue_title} (${repo_owner}/${repo_name}) ==="
|
||||
update_active "$worker_id" "$issue_num" "${repo_owner}/${repo_name}" "working"
|
||||
|
||||
# Ensure local clone
|
||||
local_repo="${WORKTREE_BASE}/gemini-base-${repo_owner}-${repo_name}"
|
||||
if [ ! -d "$local_repo" ]; then
|
||||
log "WORKER-${worker_id}: Cloning ${repo_owner}/${repo_name}..."
|
||||
git clone --depth=1 "http://gemini:${GITEA_TOKEN}@143.198.27.163:3000/${repo_owner}/${repo_name}.git" "$local_repo" 2>&1 || {
|
||||
log "WORKER-${worker_id}: ERROR cloning"
|
||||
unlock_issue "$issue_key"
|
||||
consecutive_failures=$((consecutive_failures + 1))
|
||||
sleep "$COOLDOWN"
|
||||
continue
|
||||
}
|
||||
cd "$local_repo"
|
||||
git fetch --unshallow origin main 2>/dev/null || true
|
||||
fi
|
||||
|
||||
cd "$local_repo"
|
||||
timeout 60 git fetch origin main 2>/dev/null || true
|
||||
git checkout main 2>/dev/null || true
|
||||
git reset --hard origin/main 2>/dev/null || true
|
||||
|
||||
[ -d "$worktree" ] && cleanup_worktree "$worktree" "$branch"
|
||||
cd "$local_repo"
|
||||
|
||||
if ! git worktree add "$worktree" -b "$branch" origin/main 2>&1; then
|
||||
log "WORKER-${worker_id}: ERROR creating worktree"
|
||||
# Fresh clone per issue — no shared state, no contention
|
||||
rm -rf "$worktree" 2>/dev/null
|
||||
if ! git clone --depth=1 -b main \
|
||||
"http://gemini:${GITEA_TOKEN}@143.198.27.163:3000/${repo_owner}/${repo_name}.git" \
|
||||
"$worktree" >/dev/null 2>&1; then
|
||||
log "WORKER-${worker_id}: ERROR cloning for #${issue_num}"
|
||||
unlock_issue "$issue_key"
|
||||
consecutive_failures=$((consecutive_failures + 1))
|
||||
sleep "$COOLDOWN"
|
||||
continue
|
||||
fi
|
||||
|
||||
cd "$worktree"
|
||||
git remote set-url origin "http://gemini:${GITEA_TOKEN}@143.198.27.163:3000/${repo_owner}/${repo_name}.git"
|
||||
git checkout -b "$branch" >/dev/null 2>&1
|
||||
|
||||
prompt=$(build_prompt "$issue_num" "$issue_title" "$worktree" "$repo_owner" "$repo_name")
|
||||
|
||||
@@ -372,7 +345,7 @@ else: print('')
|
||||
fi
|
||||
fi
|
||||
|
||||
cleanup_worktree "$worktree" "$branch"
|
||||
cleanup_workdir "$worktree"
|
||||
unlock_issue "$issue_key"
|
||||
update_active "$worker_id" "" "" "done"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user