diff --git a/deploy/sync-mirror.sh b/deploy/sync-mirror.sh index 4446c49..a1b6b96 100755 --- a/deploy/sync-mirror.sh +++ b/deploy/sync-mirror.sh @@ -230,7 +230,9 @@ sync_github_to_forgejo_with_prs() { BRANCH_SHA=$(git rev-parse "refs/remotes/origin/$branch" 2>/dev/null || true) fi if [ -n "$BRANCH_SHA" ]; then - TRACKED_PR=$(sqlite3 "$PIPELINE_DB" "SELECT pr_number FROM sync_autocreate_tracker WHERE branch=$(printf "'%s'" "${branch//\'/\'\'}") AND sha=$(printf "'%s'" "$BRANCH_SHA") LIMIT 1;" 2>/dev/null || true) + # stderr → $LOG so sustained sqlite3 contention surfaces in ops logs + # rather than silently falling through to a redundant auto-create. + TRACKED_PR=$(sqlite3 "$PIPELINE_DB" "SELECT pr_number FROM sync_autocreate_tracker WHERE branch=$(printf "'%s'" "${branch//\'/\'\'}") AND sha=$(printf "'%s'" "$BRANCH_SHA") LIMIT 1;" 2>>"$LOG" || echo "") if [ -n "$TRACKED_PR" ]; then log "Skip auto-create: $branch SHA $BRANCH_SHA already tracked (PR #$TRACKED_PR)" continue @@ -310,8 +312,13 @@ print('no') # Record (branch, sha, pr_number) so the tracker gate above can short- # circuit the next time we see this exact (branch, sha) combination. # INSERT OR IGNORE: idempotent if a concurrent run already inserted. + # WARN log on failure: silent INSERT failure under sustained sqlite3 + # contention would mask the loop reappearing on the next cycle (HAS_PR + # only saves us while the closed PR is in the 50-item pagination window). if [ -n "$BRANCH_SHA" ] && [[ "$PR_NUM" =~ ^[0-9]+$ ]]; then - sqlite3 "$PIPELINE_DB" "INSERT OR IGNORE INTO sync_autocreate_tracker (branch, sha, pr_number) VALUES ($(printf "'%s'" "${branch//\'/\'\'}"), $(printf "'%s'" "$BRANCH_SHA"), $PR_NUM);" 2>/dev/null || true + if ! sqlite3 "$PIPELINE_DB" "INSERT OR IGNORE INTO sync_autocreate_tracker (branch, sha, pr_number) VALUES ($(printf "'%s'" "${branch//\'/\'\'}"), $(printf "'%s'" "$BRANCH_SHA"), $PR_NUM);" 2>>"$LOG"; then + log "WARN: tracker insert failed for $branch SHA $BRANCH_SHA (PR #$PR_NUM) — duplicate auto-create possible next cycle" + fi fi # Step 4.5: Link GitHub PR to Forgejo PR in pipeline DB