🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.git
Article #2016

[PATCH 0/4] http: exponential backoff, configurable status codes, and post_rpc() retries

#2016
From: "Ravi Mistry via GitGitGadget"
Date: Sat, 31 Oct 2026 15:57
78 lines
14557 bytes
Commit 640657ffd0 (http: add support for HTTP 429 rate limit retries,
2026-03-17) added HTTP 429 retry support using http.maxRetries,
http.retryAfter, and http.maxRetryTime.

In practice, when running Git against hosting backends and reverse proxies
under high concurrency, four gaps remain:

 1. Off-by-one retry count and Retry-After Trace2 timing: Because
    http_request_recoverable() pre-decrements the retry counter
    (--rate_limit_retries) in its loop condition, setting http.maxRetries=1
    performs 0 retries (and N configured retries performs N-1 retries). In
    addition, the Retry-After header is extracted after Trace2 logging has
    already run, so the http/429-retry-after Trace2 event always logs -1.

 2. No exponential backoff when Retry-After is absent: When a server does
    not send a Retry-After header, Git waits the same fixed http.retryAfter
    delay on every retry. If that delay is short (e.g., 1s), Git burns
    through all of its retries in just a few seconds before a busy server
    can recover. If that delay is long, even a brief glitch has to wait a
    long time on the first retry. Doubling the delay on each attempt (1s,
    2s, 4s, ...) keeps the first retry fast while giving the server more
    time to recover on later attempts, matching curl's own --retry behavior.

 3. Transient 5xx errors cannot be retried: Reverse proxies, load balancers,
    and Git backends frequently surface transient overload or connection
    resets as 502 Bad Gateway, 503 Service Unavailable, or 504 Gateway
    Timeout. Because 5xx errors are not universally transient across all
    environments, 429 should remain the default, with an opt-in config to
    specify additional status codes.

 4. HTTP POST requests are not retried: Git's existing 429 retry logic only
    covers HTTP GET requests (such as the initial /info/refs handshake).
    However, the actual data transfer during fetch and clone, as well as
    on-demand blob downloads in partial clones (during checkout, diff, or
    blame), are sent as HTTP POST requests (/git-upload-pack) via
    post_rpc(), which only retries authentication and immediately aborts on
    429 or 5xx.

This 4-patch series addresses all four gaps:

 * Patch 1/4 fixes the off-by-one retry count bug and extracts Retry-After
   in finish_active_slot() before Trace2 logging runs.
 * Patch 2/4 doubles http.retryAfter on each subsequent retry attempt (1s,
   2s, 4s, capped at http.maxRetryTime) when Retry-After is absent.
 * Patch 3/4 adds http.retryStatusCodes (and GIT_HTTP_RETRY_STATUS_CODES),
   defaulting to "429", so environments can opt into retrying codes like
   "429,502,503,504".
 * Patch 4/4 extracts a shared http_retry_wait() helper and extends retry
   support to HTTP POST requests in probe_rpc() and post_rpc() (while fixing
   a missing Content-Encoding: gzip header on retry).

Prior discussions:

 * https://lore.kernel.org/git/20201012184806.166251-3-smcallis@google.com/
 * https://lore.kernel.org/git/pull.2008.v6.git.1773752435.gitgitgadget@gmail.com/

Ravi Mistry (4):
  http: fix retry count and Retry-After timing
  http: add exponential backoff without Retry-After
  http: add http.retryStatusCodes config option
  remote-curl: retry transient HTTP errors in post_rpc()

 Documentation/config/http.adoc |  42 ++++++---
 http.c                         | 122 ++++++++++++++++++--------
 http.h                         |  12 ++-
 remote-curl.c                  |  75 ++++++++--------
 t/lib-httpd/http-429.sh        |  63 ++++++++++++--
 t/t5584-http-429-retry.sh      | 155 +++++++++++++++++++++++++++++++++
 6 files changed, 373 insertions(+), 96 deletions(-)


base-commit: 8d1b215c01512b9658d4525c54ff9b9245f9a7e8
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2287%2Frmistry%2Fhttp-exponential-retries-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2287/rmistry/http-exponential-retries-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/2287
-- 
gitgitgadget
Technical Details
Message-ID: <pull.2287.git.1793462224.gitgitgadget@gmail.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-74014-linux-kernel-git=dewy.ru

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-74014-linux-kernel-git=dewy.ru
From: gitgitgadget@gmail.com ("Ravi Mistry via GitGitGadget")
Newsgroups: linux.kernel.git
Subject: [PATCH 0/4] http: exponential backoff, configurable status codes, and post_rpc() retries
Date: Sat, 31 Oct 2026 15:57:00 +0000
Organization: Usenet Network
Message-ID: <pull.2287.git.1793462224.gitgitgadget@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2491805"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:0EIrjdnuBszYt3njnBQLtzQDgDY= sha256:7pApYacpocWnXC1B4SdhRijZz7mSW2TfAQuPFaQ+uZY=
	sha1:djASBzlDQo7IcZYKnO5MsvhY1ag= sha256:cGWMmSAFHPDVx23pC97HOtDBzagUha2eywFC5RLEePo=
List-ID: <git.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 42612125CB9; Sat, 31 Oct 2026 18:57:28 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.048
X-Spam-Status: No, score=-3.048 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
	FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=gmail.com
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id pDjraOHjqqJF;
	Sat, 31 Oct 2026 18:57:26 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=git+bounces-74014-linux-kernel-git=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 8C11B125CB7; Sat, 31 Oct 2026 18:57:15 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 1391028DE5; Sat, 31 Oct 2026 15:57:08 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1793462227;
	b=WDZJV9yxp1AFAhf7vfwliQarAv8bin7oih1lMYLEHCmwzc+FWRU2/TnnBFGQdx52Y5l0
	 IW20hZ4o2iC41adW9+VksiNSk0ewaK1PGgD+KM4S4p2aHD9lxdKO86JYJjSKCKWJ02zWP
	 cjWSQC3YOi+dcz4cb8ivDaYhaZxagNDU4TPZwDVS9UM9qVeJuXHl70XNtGGWEL+PWO5qg
	 LOEgx6NLYQn4+QKWtkGlPHdssleVkxw8Q4jCcBwy6jxlrC9OL83FKYwez4A9ugo8vBYH3
	 1Eg6suMpgEiKNXcabRSD0mmLXMhDL9bFBXK4/H3ofH5+KgSmBybRNdtsl5C6NqfAA/g==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793462227;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
	 X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
	 Received:Message-Id:From:Date:Subject:Fcc:Content-Type:
	 Content-Transfer-Encoding:X-Mailing-List:List-Id:List-Post:List-Help:
	 List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version:To:
	 Cc;
	bh=VyLkubNtJGswnwHRGo9CKS5HE1tXcY3u84rdqVUtnkc=;
	b=jrAcu1LgakPql6RtO6AJMxpCwgonOfMd6QXMHqywQ0t6c2LCqigSANapbDkigT03wMgD
	 c1HIQLf3hFjJPnC40BQd344cmIReGco7AlgbsmAHyK+jRfmncXMVYv+pKL3Tyq8XHWaRZ
	 i2KrZ/rZbHT5xyGGaxUdJRck9ShoYn/kblqqEcum1HkI0goGcMBdM2be4YNUkiNwE7eAl
	 MIJ/9SKXLCbUN6gFfqM4H2fdQ6OxYB2jso8bFIO8UxjOAKbnV9+7ePtdr1H5c6AXsYGeN
	 kbpqBXyovcwSvzKDByz3IPOHeSFuJNJmksyev1dbzxoLpkpTXUMXIyOzTrxayJAFbbA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=cPPzkico;
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 99423606A322;
	Sat, 31 Oct 2026 15:57:07 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=cPPzkico
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.160.175
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1793462226;
	b=NLdxumFIMbRmmSrl7xinn4736CiXdla054C1p69z3kstaY30h6/x7miGNuz6GyP7TT64
	 mZYDqEGhfu3x1mAwHJ3nkWlcY4GXy5gCiYrk6XC/qg5yNuLwkQXeX/6WlNDFz5tqZrOf0
	 FT1aZRJqUFMQP/m/q6ESYmH2EOGrx4GjKjeS7GNiBo2d+zpUZsJauHpvAu5i3je8mvFF0
	 mUbnr8xlHTF1TDJE0swns+xGoBCYklUI8/DOqf47HKcWXHIJXHtxYIUBqKeX5ls5Tt9Vr
	 a8qSxXyDD919bo9+FH8wDIMDnHyebkQgAPm9bGglFDc1dsGUpmPEGdaULa8d4FUA57w==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793462226;
	h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
	 X-Gm-Message-State:X-Gm-Gg:X-Received:Received:Message-Id:From:Date:
	 Subject:Fcc:Content-Type:Content-Transfer-Encoding:MIME-Version:To:
	 Cc;
	bh=VyLkubNtJGswnwHRGo9CKS5HE1tXcY3u84rdqVUtnkc=;
	b=NYEm/Ukh3vbfjXvpiYgsrfBqZk+hQjXjo94r/8wn+ROlRaGfZdyOHWpQiETulGKXyRb+
	 6RWZdd25MAv8db0GEq132N3FsJTaZdd/pmucrvLrOWiNYYAN0IJc7RScbhh4ebIJyX3yP
	 sUcRoEv8P5JP6AAZpVbGygy7lM7sKP62osjYLKAl/I1nhxROXMLCUFgsHky2E7xi1+VxX
	 2gRMTKtD4eVyQ/KnrO5YygpmPZkDm+vv0cRH34F0TTbOFFbPEa1pq7qQhWHq6j2+m2rZ2
	 hURIwmXB8OcZh/35c1Q9Q1Tul6RlP9T1G3SfWqLX1Lbl1bGPmCbN0Kzl8VALEVh9Vkg==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=cPPzkico;
	arc=none smtp.remote-ip=209.85.160.175
X-Received: from mail-qt1-f175.google.com (mail-qt1-f175.google.com [209.85.160.175])
	(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 53D93606A31A
	for <git@vger.kernel.org>; Sat, 31 Oct 2026 15:57:06 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 53D93606A31A
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-qt1-f175.google.com with SMTP id d75a77b69052e-533778ab0bdso23241591cf.3
        for <git@vger.kernel.org>; Sat, 31 Oct 2026 08:57:06 -0700 (PDT)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20260707; t=1793462225; x=1794067025; darn=vger.kernel.org;
        h=cc:to:mime-version:content-transfer-encoding:content-type:fcc
         :subject:date:from:message-id:from:to:cc:subject:date:message-id
         :reply-to:content-type;
        bh=VyLkubNtJGswnwHRGo9CKS5HE1tXcY3u84rdqVUtnkc=;
        b=cPPzkicoggn2mGQzUkU2NoJe8vZSkVfKvqkIMSfOmKrIFlM6LN/XGBKWZRRzGm7vOl
         8qw23fN/enQuHWTx9bjS1oqRnH0mhQnxpueKoZXqb0ql0Sr6GLMzSGkKRB/Sr9ocMmrP
         3iLM4XmcW0jZBxFoSiYWg2WJxiMoNom3J14MgSRBk2HfcGkwhMLYOSWeSttq1JWC64Ub
         DiVBjIUSduv6V8AhRpwqmNk+f1CMTWnz+rIZTLEVq90nm7K2GElxDDnDgUe6GFf6mMC8
         OgkF4CREBoELjIiWLPVnoPxMcWwmiBnsZkxyZ7bRJyRubrDFQGQeo4uWNKidfYQ415df
         gCqQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1793462225; x=1794067025;
        h=cc:to:mime-version:content-transfer-encoding:content-type:fcc
         :subject:date:from:message-id:x-gm-gg:x-gm-message-state:from:to:cc
         :subject:date:message-id:reply-to:content-type;
        bh=VyLkubNtJGswnwHRGo9CKS5HE1tXcY3u84rdqVUtnkc=;
        b=HhlUZeH+mry3R4sxVh5G5H11Di8yRIMFXdhQu4ebifuRL+ZKE8IkpNJide+5zFLitO
         jWXSCquAXVU3bVbfY16vXoGmnw1SJBO75E+Hu/mY/uYoaMXIfYF2NNaLtZQLyq3luUyc
         yC3oGSIdEHw5rf6vV3WiWnvbxfd0SVQtYla8wttkH78A/zRF1Q4vdEjS0HKLF8OVjh7+
         0LzjGg0oEQNZ8cdHJTorEDREpVi4k6VC/mcSEmFWoPZYCFrthRmXhnzOLnyhlB9VItGI
         zpFwa6TSfEHZzTLwQxEtkKffo2AE6gtqkDoNxMm4hhj0AQZaKlOlUdFchs7nHuwICCmE
         RnAw==
X-Gm-Message-State: AFq9FYKM+X080cCW1m6BnmN/7/ne6YaWKOyn9XQnDZe7HvZ40DE32Kja
	CtizJd3ymtCDMFYHRPfefqRKL7l1MESebU24fL5UAtzfF5rkaOD1wHolXMiNFcq7
X-Gm-Gg: AYBFou2IgjMnbxhf7OSVTzkCNLGfWMM+WikH3bhyNFXDeFXp7Svq66VceVSm+0JiSkm
	FDq2PcMy0ZX2VYzZiC1U0B8wNVK9l0+LQ6U3PnVbcBWVQRd734nSc5S+HMMhbBruQI0biMczNOh
	11YLRuv3Q+iyEEb2TnA2pmcullB5NRWy2lJ69FkHIqYYBQgJ8rKwOGs80PZGmNRBEss6k/0qErC
	ZnH9F+dvVWAZ/x8veIvXzrA0cbv+Fn+ZEgz3GSPVFDrBdSv2/UiWgoZ4wKu57PwSRxltYiiiteH
	fjM9fnBmLSr34iURQDBbVWkLL825vftYGnGhGfXfvJ1gN9FNKyHKhlANy6Yw9iynskHHGCmis5y
	pC4rvbST5UYhZGLsT1bnWvcFh33hYaAFv8FaFn/aa0uqhoGQumFZ7HAm5TxvqKZL9QZGn7TLkfU
	418cRKviJ5JQ6OdujnVXTZ/BA7l9w7g+38NleEaKMKdhf75rgRBpp8fVqB7KBhx6fyrIFXO2Eqe
	fUXS40nqidIrrR4pGV7YFB4dHwoyLrzKBhme+u1ScpVVVsn/3TBaOOF3sUV0pATKNn2kuR//149
	/gJlHktZGMOKE+3OH1Ebgj47bL83gtxPMco=
X-Received: by 2002:a05:622a:2515:b0:537:5488:ac63 with SMTP id d75a77b69052e-542b6e55bdfmr90010961cf.34.1793462225291;
        Sat, 31 Oct 2026 08:57:05 -0700 (PDT)
X-Received: from [127.0.0.1] ([172.174.126.192])
        by smtp.gmail.com with ESMTPSA id d75a77b69052e-5431246c7casm41691181cf.19.2026.10.31.08.57.04
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Sat, 31 Oct 2026 08:57:04 -0700 (PDT)
X-Fcc: Sent
X-Mailing-List: git@vger.kernel.org
X-List-Post: <mailto:git@vger.kernel.org>
X-List-Help: <mailto:git+help@vger.kernel.org>
X-List-Subscribe: <mailto:git+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:git+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:git+owner@vger.kernel.org>
X-Precedence: list
X-Cc: Vaidas Pilkauskas <vaidas.pilkauskas@shopify.com>,
    Patrick Steinhardt <ps@pks.im>,
    "brian m. carlson" <sandals@crustytoothpaste.net>,
    Ravi Mistry <rmistry@google.com>