From b4162eabbf700d4b4a6b0780f0ea209b8042ee10 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 22:58:46 +0000 Subject: [PATCH] fix(ci): bound every git transfer by its byte rate so a stalled checkout or history fetch retries instead of eating the step budget A git HTTP request that moves under 1000 bytes/s for 120 s now exits 128 (curl 28), so actions/checkout's own fetch retry and fetch-history.sh's retry run. The measured stalls never started the pack while the server's sideband progress kept the log growing, so fetch-history.sh's silence bound never fired. The script now exports the same defaults, prints each phase as it starts, and keeps the silence bound as a backstop. lint-eslint reads no history and checks out at depth 1. Step budgets and job walls are unchanged. Claude-Session: https://claude.ai/code/session_01WGufzgwLiKcfujYUug7sPs Co-Authored-By: Claude --- .github/workflows/ci.yml | 21 +++++++++ .github/workflows/lint.yml | 63 ++++++++++++++++++-------- scripts/ci/fetch-history.selftest.sh | 63 ++++++++++++++++++++++++-- scripts/ci/fetch-history.sh | 67 ++++++++++++++++++++++++---- 4 files changed, 184 insertions(+), 30 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2d3e1759390..748e7c044a6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -185,6 +185,22 @@ concurrency: # main-only job reads the probe. The 4-hourly `schedule` run is untouched: it # is the full battery. +# ⭐ EVERY GIT TRANSFER IN THIS FILE IS BOUNDED BY ITS BYTE RATE (#34994). +# A git HTTP request that moves under 1000 bytes/s for 120 s is aborted by curl +# (exit 128, "curl 28 Operation too slow"), so the retry around it runs: +# actions/checkout's own fetch retry (3 attempts) and the "Fetch this commit's +# history" step's (scripts/ci/fetch-history.sh, 3 attempts). On 2026-11-16/17, +# 48 checkout or fetch steps here and in lint.yml ran to their 8-25 minute +# budget with no index-pack running: the server never started the pack, while +# its `remote:` progress kept the log moving, and siblings in the same run +# took 51-65 s. The slowest healthy wait for the pack is ~15 s and a healthy +# receive runs at MiB/s, so neither number cuts a slow transfer that moves. +# The step budgets stay the outer wall. Same block in lint.yml; the script +# sets the same defaults for a local run. +env: + GIT_HTTP_LOW_SPEED_LIMIT: '1000' + GIT_HTTP_LOW_SPEED_TIME: '120' + jobs: queue-verdict: name: Queue verdict @@ -1105,6 +1121,11 @@ jobs: # group and retried (#34561): on 2026-11-16/17 a stalled transfer held # attempt 1 silent until this budget killed it, four times, so the retry # never ran, while sibling shards fetched the same history in 47-96 s. + # That bound missed the next stalls: a server that never starts the pack + # keeps printing `remote:` progress, so the log never went silent. Each + # attempt is now also cut by its byte rate, under 1000 bytes/s for 120 s + # (the workflow `env:` block above, #34994), and the script prints each + # phase as it starts, so a step that still hits this budget names it. # A fetch that keeps moving is never cut. The script's header has the # reading; its self-test runs in lint.yml. # diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index df925d09e67..11970a2f7d7 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -214,6 +214,20 @@ concurrency: # affected-package type check) carries its own note saying how. # ───────────────────────────────────────────────────────────────────────────── +# ⭐ EVERY GIT TRANSFER IN THIS FILE IS BOUNDED BY ITS BYTE RATE (#34994). +# A git HTTP request that moves under 1000 bytes/s for 120 s is aborted by curl +# (exit 128, "curl 28 Operation too slow"), so actions/checkout's own fetch +# retry (3 attempts) runs instead of the CHECKOUT BUDGET expiring. On +# 2026-11-16/17, 20 of this file's full-history checkouts ran to that 20-25 +# minute budget with no index-pack running: the server never started the pack. +# The slowest healthy wait for the pack is ~15 s (this fetch reuses the +# server's packs: ~4 s), and a healthy receive runs at MiB/s, so neither number +# cuts a slow transfer that moves. The CHECKOUT BUDGET stays the outer wall. +# ci.yml carries the same block and says more. +env: + GIT_HTTP_LOW_SPEED_LIMIT: '1000' + GIT_HTTP_LOW_SPEED_TIME: '120' + jobs: schedule-gate: @@ -311,10 +325,11 @@ jobs: # header). What each lane repeats is the six setup steps, the gate-family # selector where the lane carries a scoped step, and, since #23191, the # `Lane verdict` step that ends it (it replaced the unmeasured-tail - # reporter pair). Every lane keeps the single job's full-history checkout: - # which of the ~190 gates read history was not re-derived for this split, - # and a gate that loses its history degrades to "not verified" rather than - # going red. + # reporter pair). Every lane but `lint-eslint` keeps the single job's + # full-history checkout: which of the ~190 gates read history was not + # re-derived for this split, and a gate that loses its history degrades to + # "not verified" rather than going red. `lint-eslint`'s three steps were + # re-derived (#34994): none reads history, so it checks out at depth 1. # # The lanes are independent. The only inter-step reads in the single job # were `steps.gate-families.outputs.*` (nine `if:` lines, one step `id:`), @@ -525,12 +540,11 @@ jobs: # CHECKOUT BUDGET: `typecheck-source-gates` sizes it; the `lint` job # above says why every lane carries it. timeout-minutes: 25 - with: - # The slot-lookup ratchet compares the baseline against its state at - # the merge base with main — the only way to see a file being ADDED - # to the grandfather list. A shallow clone has no merge base, and the - # check would degrade to "not verified" on every run. - fetch-depth: 0 + # Depth 1, the default (#34994): nothing in this lane reads history. + # ESLint and the engine test-double gate read the working tree only, + # and the slot-lookup ratchet that once needed the merge base here + # runs in `lint-scoped-slot-corpus` since the lane split. The other + # lanes keep `fetch-depth: 0` for their own history readers. - name: Setup workspace uses: ./.github/actions/setup-workspace @@ -610,7 +624,12 @@ jobs: # above says why every lane carries it. timeout-minutes: 25 with: - # `fetch-depth: 0`: same reason as the `lint-eslint` checkout above. + # Gates in this lane and the scoped lanes below compare against the + # merge base with main — the slot-lookup ratchet, for one, sees a + # file being ADDED to its grandfather list only that way. A shallow + # clone has no merge base, and such a check degrades to "not + # verified" on every run. (This note stood on `lint-eslint`'s + # checkout until that lane, which reads no history, went to depth 1.) fetch-depth: 0 - name: Setup workspace @@ -1956,7 +1975,7 @@ jobs: # above says why every lane carries it. timeout-minutes: 25 with: - # `fetch-depth: 0`: same reason as the `lint-eslint` checkout above. + # `fetch-depth: 0`: same reason as the `lint-repo-tooling` checkout above. fetch-depth: 0 - name: Setup workspace @@ -3008,7 +3027,7 @@ jobs: # above says why every lane carries it. timeout-minutes: 25 with: - # `fetch-depth: 0`: same reason as the `lint-eslint` checkout above. + # `fetch-depth: 0`: same reason as the `lint-repo-tooling` checkout above. fetch-depth: 0 - name: Setup workspace @@ -4158,7 +4177,7 @@ jobs: # above says why every lane carries it. timeout-minutes: 25 with: - # `fetch-depth: 0`: same reason as the `lint-eslint` checkout above. + # `fetch-depth: 0`: same reason as the `lint-repo-tooling` checkout above. fetch-depth: 0 - name: Setup workspace @@ -4318,7 +4337,7 @@ jobs: # above says why every lane carries it. timeout-minutes: 25 with: - # `fetch-depth: 0`: same reason as the `lint-eslint` checkout above. + # `fetch-depth: 0`: same reason as the `lint-repo-tooling` checkout above. fetch-depth: 0 - name: Setup workspace @@ -4464,7 +4483,7 @@ jobs: # above says why every lane carries it. timeout-minutes: 25 with: - # `fetch-depth: 0`: same reason as the `lint-eslint` checkout above. + # `fetch-depth: 0`: same reason as the `lint-repo-tooling` checkout above. fetch-depth: 0 - name: Setup workspace @@ -4654,7 +4673,7 @@ jobs: # above says why every lane carries it. timeout-minutes: 25 with: - # `fetch-depth: 0`: same reason as the `lint-eslint` checkout above. + # `fetch-depth: 0`: same reason as the `lint-repo-tooling` checkout above. fetch-depth: 0 - name: Setup workspace @@ -4816,6 +4835,11 @@ jobs: # one retry inside the same total gains nothing (the hazard is flat). # Healthy runs pay nothing for it: max 435 s over 3,576 checkouts of this # workflow after the incident. The queries are in #29980's dev report. + # That flat hazard is a SLOW transfer's. A STALLED one (the server never + # starts the pack, 2026-11-16/17) is cut inside git by the workflow `env:` + # block above, and actions/checkout retries it within this budget (#34994), + # so the budget only binds a transfer that moves. `lint-eslint` checks out + # at depth 1 since then and keeps the same budget, unchanged. # The one exception is `typecheck-workspace`: its body budget is 35, and # 35 + 20 = 55 is already the cap the `lint` job argues, so that lane # keeps 20 until its body is faster or the fetch is narrowed (#22034). @@ -4855,8 +4879,9 @@ jobs: # touches no spec file at all) go red for "deleting" # ui/BulkActionDef:requiredPermissions — a key main had just ADDED. # - # Same line as the ESLint job above, opposite failure mode, and that - # is why it is spelled out here rather than cross-referenced: shallow + # Same line as the `lint-repo-tooling` checkout above, opposite + # failure mode, and that is why it is spelled out here rather than + # cross-referenced: shallow # degrades the slot-lookup ratchet to "not verified" (a false GREEN), # and degrades this gate to a false RED on an innocent PR. fetch-depth: 0 diff --git a/scripts/ci/fetch-history.selftest.sh b/scripts/ci/fetch-history.selftest.sh index 112f8590d1b..bc196335623 100644 --- a/scripts/ci/fetch-history.selftest.sh +++ b/scripts/ci/fetch-history.selftest.sh @@ -7,7 +7,10 @@ # # The property under test is the one the four 2026-11-16/17 step timeouts # broke: an attempt that STALLS is ended and retried, while an attempt that -# keeps moving is left alone. A real stalled transfer cannot be ordered on +# keeps moving is left alone. Since #34994 a stall is also one that keeps +# PRINTING server progress while no pack arrives: curl's low-speed abort ends +# it (exit 128, "curl 28"), so the cases pin that the script hands git that +# bound and retries what it ends, and that each phase prints as it starts. A real stalled transfer cannot be ordered on # demand, so a stub `git` on PATH plays `fetch` per attempt (healthy, silent # hang, hang after some progress, slow but moving, fast failure) and hands # every other git command to the real git. A healthy `fetch` IS the real one, @@ -17,8 +20,10 @@ # Each case pins the exit status, the attempt count, the `fetch` arguments, the # ::warning:: / ::error:: lines, and for a hang that the stub's child process # (standing in for git-remote-https) is gone afterwards -- the process-group -# kill. The last section reads ci.yml and pins that all five jobs call the -# script and no inline copy of the old loop is left. +# kill. The last sections read ci.yml and lint.yml: all five ci.yml jobs call +# the script and no inline copy of the old loop is left; both workflows carry +# the same low-speed bound as the script's defaults; `lint-eslint` checks out +# at depth 1. # # Offline; ~40 s (the stall bound is 2 s here, 60 s in CI). Every fixture path # is under a mktemp directory; none is spelled as a repo path @@ -28,6 +33,7 @@ cd "$(git rev-parse --show-toplevel)" || exit 1 SCRIPT_REL='scripts/ci/fetch-history.sh' WORKFLOW_REL='.github/workflows/ci.yml' +LINT_WORKFLOW_REL='.github/workflows/lint.yml' SCRIPT="$PWD/$SCRIPT_REL" REAL_GIT="$(command -v git)" FIX=$(mktemp -d "${TMPDIR:-/tmp}/os-fetch-history-selftest.XXXXXX") || exit 1 @@ -58,6 +64,7 @@ if [ "${1:-}" != fetch ]; then exec "$STUB_REAL_GIT" "$@"; fi n=$(( $(cat "$STUB_DIR/attempts" 2> /dev/null || echo 0) + 1 )) echo "$n" > "$STUB_DIR/attempts" echo "$*" >> "$STUB_DIR/argv" +echo "${GIT_HTTP_LOW_SPEED_LIMIT-unset} ${GIT_HTTP_LOW_SPEED_TIME-unset}" >> "$STUB_DIR/env" step=$(echo "$STUB_PLAN" | cut -d, -f"$n") case "$step" in ok) exec "$STUB_REAL_GIT" "$@" ;; @@ -69,6 +76,14 @@ case "$step" in wait exit 1 ;; + talk-then-curl28) + # The 2026-11-17 shape: no pack, but server progress every second, longer + # than the stall bound, then curl's low-speed abort as git reports it. + for i in 1 2 3 4 5; do printf 'remote: Counting objects: %d0%% (%d/10)\r' "$i" "$i" >&2; sleep 1; done + echo "error: RPC failed; curl 28 Operation too slow. Less than 1000 bytes/sec transferred the last 120 seconds" >&2 + echo "fatal: expected 'packfile'" >&2 + exit 128 + ;; slow) for i in 1 2 3 4 5; do printf 'Receiving objects: %d0%% (%d/10)\r' "$i" "$i" >&2; sleep 1; done exec "$STUB_REAL_GIT" "$@" @@ -90,8 +105,13 @@ run_case() { fi local start end start=$(date +%s) + local low=() + if [ -n "${CASE_LOW_SPEED:-}" ]; then + low=(GIT_HTTP_LOW_SPEED_LIMIT="${CASE_LOW_SPEED% *}" GIT_HTTP_LOW_SPEED_TIME="${CASE_LOW_SPEED#* }") + fi ( cd "$case_dir/ws" && + env -u GIT_HTTP_LOW_SPEED_LIMIT -u GIT_HTTP_LOW_SPEED_TIME ${low[@]+"${low[@]}"} \ PATH="$bin:$PATH" STUB_REAL_GIT="$REAL_GIT" STUB_DIR="$case_dir/stub" STUB_PLAN="$plan" \ FETCH_HISTORY_STALL_SECONDS=2 FETCH_HISTORY_RETRY_SLEEP=0 PR_BASE_REF="$base" RUNNER_TEMP="$case_dir" \ bash "$SCRIPT" > "$case_dir/out" 2>&1 @@ -102,6 +122,7 @@ run_case() { attempts=$(cat "$case_dir/stub/attempts" 2> /dev/null || echo 0) out=$(cat "$case_dir/out") argv1=$(head -n 1 "$case_dir/stub/argv" 2> /dev/null) + env1=$(head -n 1 "$case_dir/stub/env" 2> /dev/null) ws="$case_dir/ws" } children_gone() { @@ -124,6 +145,13 @@ check "healthy clone has all 5 commits" '[ "$("$REAL_GIT" -C "$ws" rev-list --co check "healthy fetched no tag" '[ -z "$("$REAL_GIT" -C "$ws" tag)" ]' check "healthy prints the History line" 'grep -q "^History: 5 commit(s) behind HEAD, shallow=false, no tags" <<< "$out"' check "healthy prints no warning" '! grep -q "::warning::" <<< "$out"' +check "healthy hands git the low-speed defaults (1000 B/s for 120 s)" '[ "$env1" = "1000 120" ]' +check "healthy names the bound once" '[ "$(grep -c "^Each attempt ends when it moves under 1000 bytes/s for 120s (curl) or writes nothing for 2s, and is retried.$" <<< "$out")" = 1 ]' + +echo "-- #34994: a bound the workflow already set is kept, not overwritten" +CASE_LOW_SPEED="5 7" run_case preset ok +check "preset exits 0" '[ "$rc" = 0 ]' +check "preset hands git the workflow's values" '[ "$env1" = "5 7" ]' echo "-- a PR into another branch fetches that branch too; a PR into main does not repeat main" run_case pr-release ok shallow release-x @@ -160,6 +188,17 @@ check "slow takes one attempt" '[ "$attempts" = 1 ]' check "slow ran longer than the stall bound" '[ "$elapsed" -ge 4 ]' check "slow prints no warning" '! grep -q "::warning::" <<< "$out"' check "slow prints one line for its progress phase" '[ "$(grep -c "^Receiving objects:" <<< "$out")" = 1 ]' +check "slow names its phase live, once" '[ "$(grep -cE "^fetch-history: \+[0-9]+s Receiving objects$" <<< "$out")" = 1 ]' + +echo "-- #34994: a fetch that keeps printing server progress but gets no pack is ended by curl and retried" +run_case talk-then-ok talk-then-curl28,ok +check "talk-then-ok exits 0" '[ "$rc" = 0 ]' +check "talk-then-ok takes two attempts" '[ "$attempts" = 2 ]' +check "talk-then-ok: the silence bound did not fire (it cannot: the log kept growing)" '! grep -q "::warning::git fetch wrote nothing" <<< "$out"' +check "talk-then-ok: both attempts ran under the low-speed bound" '[ "$(grep -c "^1000 120$" "$case_dir/stub/env")" = 2 ]' +check "talk-then-ok shows curl's abort" 'grep -q "curl 28 Operation too slow" <<< "$out"' +check "talk-then-ok names the server phase it stood in, live" 'grep -qE "^fetch-history: \+[0-9]+s remote: Counting objects$" <<< "$out"' +check "talk-then-ok ends unshallowed" '[ "$("$REAL_GIT" -C "$ws" rev-parse --is-shallow-repository)" = false ]' echo "-- three fast failures end red, named" run_case fail3 fail,fail,fail @@ -188,6 +227,24 @@ check "each fetch step's run line is the script" '[ "$(grep -A4 "^ - name: check "each fetch step passes PR_BASE_REF" '[ "$(grep -A4 "^ - name: Fetch this commit'"'"'s history and the base branch$" "$wf" | grep -c "PR_BASE_REF: \${{ github.event.pull_request.base.ref }}")" = 5 ]' check "no inline fetch loop is left in ci.yml" '! grep -q "git fetch --no-tags \"\${deepen\[@\]}\"" "$wf"' +echo "-- #34994: both workflows set the script's low-speed bound for every job" +lint_wf="$PWD/$LINT_WORKFLOW_REL" +script_limit=$(sed -n 's/^export GIT_HTTP_LOW_SPEED_LIMIT="\${GIT_HTTP_LOW_SPEED_LIMIT:-\([0-9]*\)}"$/\1/p' "$SCRIPT") +script_time=$(sed -n 's/^export GIT_HTTP_LOW_SPEED_TIME="\${GIT_HTTP_LOW_SPEED_TIME:-\([0-9]*\)}"$/\1/p' "$SCRIPT") +check "the script's defaults read as 1000 and 120" '[ "$script_limit" = 1000 ] && [ "$script_time" = 120 ]' +for f in "$wf" "$lint_wf"; do + name=$(basename "$f") + block=$(awk '/^env:$/ { on = 1; next } on && /^[^ ]/ { on = 0 } on' "$f") + check "$name has one workflow-level env: block" '[ "$(grep -c "^env:$" "$f")" = 1 ]' + check "$name's env: sets GIT_HTTP_LOW_SPEED_LIMIT to the script's default" 'grep -qx " GIT_HTTP_LOW_SPEED_LIMIT: '"'"'$script_limit'"'"'" <<< "$block"' + check "$name's env: sets GIT_HTTP_LOW_SPEED_TIME to the script's default" 'grep -qx " GIT_HTTP_LOW_SPEED_TIME: '"'"'$script_time'"'"'" <<< "$block"' +done + +echo "-- #34994: lint-eslint reads no history, so it checks out at depth 1" +eslint_job=$(awk '/^ lint-eslint:$/ { on = 1; next } on && /^ [a-z0-9_-]+:$/ { on = 0 } on' "$lint_wf") +check "lint.yml has the lint-eslint job" '[ -n "$eslint_job" ] && grep -q "uses: actions/checkout@" <<< "$eslint_job"' +check "lint-eslint's checkout sets no fetch-depth" '! grep -qE "^ +fetch-depth:" <<< "$eslint_job"' + echo "" if [ "$fails" -gt 0 ]; then echo "fetch-history self-test: $fails check(s) FAILED" diff --git a/scripts/ci/fetch-history.sh b/scripts/ci/fetch-history.sh index 2c0a3ab62ef..bbb028d2610 100644 --- a/scripts/ci/fetch-history.sh +++ b/scripts/ci/fetch-history.sh @@ -27,16 +27,45 @@ # # So the fetch runs with `--progress` into a log, in its own session, and an # attempt that writes nothing for STALL_SECONDS (60) is killed with its whole -# process group (the `git-remote-https` helper included) and retried. A fetch -# that keeps moving is never cut, however slow: a healthy one prints a line at -# least every second (enumerating, counting, compressing, then receiving with -# its byte rate), so 60 s of silence is a hang, not a slow network. The step's -# `timeout-minutes` stays the outer wall, unchanged. +# process group (the `git-remote-https` helper included) and retried. # -# Inputs: PR_BASE_REF (empty on push and merge_group). Test knobs, for the -# self-test only: FETCH_HISTORY_STALL_SECONDS and FETCH_HISTORY_RETRY_SLEEP. +# ⭐ ...AND BY ITS BYTE RATE, BECAUSE A HUNG FETCH CAN KEEP PRINTING (#34994). +# Silence was the wrong signal. A healthy fetch prints at least every second, +# but the converse does not hold. The next 13 step timeouts (2026-11-17, 8-20 +# minutes each) all died in attempt 1 with no `::warning::` and no attempt 2: +# the watchdog loop ran for the whole budget (its `sleep` was among the +# orphans) and never saw 60 s of silence. Each one's orphans were `git`, `git` +# and `git-remote-https`, never `index-pack`, which fetch-pack starts only +# once it reads the pack header. So the server never started the pack, and +# meanwhile its enumerate/count/compress progress (`remote: ...`, carried on +# the sideband) kept the log growing. lint.yml's checkouts and ci.yml's +# depth-1 checkouts stalled the same way, and same-run siblings took 51-65 s. +# +# So every attempt also runs under curl's low-speed abort: a request that +# moves under GIT_HTTP_LOW_SPEED_LIMIT (1000) bytes/s for GIT_HTTP_LOW_SPEED_TIME +# (120) seconds exits 128 ("curl 28 Operation too slow"), the loop below +# retries it, and server progress is far too few bytes to hold it open. Both +# workflows set the same two values for every job, so actions/checkout's own +# retry gets the same bound; this script exports them only when they are +# unset, so a local run is bounded too. Measured on this fetch: the server +# starts the pack after ~15 s and a healthy receive runs at MiB/s, so neither +# number cuts a slow transfer that moves. The silence bound stays as the +# backstop for a request that sends nothing at all. +# +# Each phase is printed as it starts, with the attempt's elapsed seconds, so a +# step that still hits its wall names where it stood. The attempt's own log is +# printed only when it ends, and the step timeout kills this script first. +# The step's `timeout-minutes` stays the outer wall, unchanged. +# +# Inputs: PR_BASE_REF (empty on push and merge_group); GIT_HTTP_LOW_SPEED_LIMIT +# and GIT_HTTP_LOW_SPEED_TIME (the workflows' values; defaults below). Test +# knobs, for the self-test only: FETCH_HISTORY_STALL_SECONDS and +# FETCH_HISTORY_RETRY_SLEEP. set -uo pipefail +export GIT_HTTP_LOW_SPEED_LIMIT="${GIT_HTTP_LOW_SPEED_LIMIT:-1000}" +export GIT_HTTP_LOW_SPEED_TIME="${GIT_HTTP_LOW_SPEED_TIME:-120}" + STALL_SECONDS="${FETCH_HISTORY_STALL_SECONDS:-60}" RETRY_SLEEP="${FETCH_HISTORY_RETRY_SLEEP:-15}" ATTEMPTS=3 @@ -60,6 +89,22 @@ show_log() { END { if (held != "") print held }' } +# The phase the attempt is in now: its last COMPLETE line (a trailing write +# with no carriage return or newline yet is not read as a phase), cut to the +# phase name ("remote: Counting objects", "Receiving objects", ...). +current_phase() { + local partial=0 + case "$(tail -c 1 "$log" | od -An -c | tr -d ' ')" in + '\n' | '\r' | '') ;; + *) partial=1 ;; + esac + tr '\r' '\n' < "$log" | awk -v partial="$partial" ' + NF { line = $0; pre = "" + if (sub(/^remote: /, "", line)) pre = "remote: " + sub(/:.*/, "", line); prev = key; key = pre line } + END { print (partial ? prev : key) }' +} + # One fetch attempt. Returns git's exit status, or 124 when it was killed for # STALL_SECONDS of silence. `setsid` gives git a process group of its own (a # background job of a non-interactive shell is never a group leader, so setsid @@ -67,13 +112,18 @@ show_log() { fetch_once() { : > "$log" setsid git "$@" < /dev/null > "$log" 2>&1 & - local pid=$! size last=-1 quiet=0 rc + local pid=$! size last=-1 quiet=0 rc phase='' now start=$SECONDS while kill -0 "$pid" 2> /dev/null; do sleep 1 size=$(wc -c < "$log") if [ "$size" -ne "$last" ]; then last=$size quiet=0 + now=$(current_phase) + if [ -n "$now" ] && [ "$now" != "$phase" ]; then + phase=$now + echo "fetch-history: +$((SECONDS - start))s ${phase}" + fi else quiet=$((quiet + 1)) fi @@ -93,6 +143,7 @@ fetch_once() { return "$rc" } +echo "Each attempt ends when it moves under $GIT_HTTP_LOW_SPEED_LIMIT bytes/s for ${GIT_HTTP_LOW_SPEED_TIME}s (curl) or writes nothing for ${STALL_SECONDS}s, and is retried." attempt=1 while :; do deepen=()