Skip to content

fix: lake: retry transient artifact transfer failures - #14725

Open
marcelolynch wants to merge 1 commit into
leanprover:masterfrom
marcelolynch:lake-transfer-retry
Open

fix: lake: retry transient artifact transfer failures#14725
marcelolynch wants to merge 1 commit into
leanprover:masterfrom
marcelolynch:lake-transfer-retry

Conversation

@marcelolynch

@marcelolynch marcelolynch commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

This PR makes lake cache get and lake cache put retry the transfers in a batch that fail in a transient way, instead of failing the whole batch after one attempt. Lake attempts a batch up to 3 times; the LAKE_CACHE_TRANSFER_ATTEMPTS environment variable overrides this limit. A retry covers a connection that drops mid-transfer, a download whose bytes do not match the expected content hash, and the transient HTTP status codes (408, 429, 500, 502, 503, 504). A failure that a retry cannot fix, such as a 404, still fails the batch immediately.

One dropped connection could previously fail a batch of thousands of transfers. A mathlib CI run showed this: 2 of 8309 downloads hit a dropped HTTP/2 stream, and the whole lake cache get failed (log). curl --retry does not cover these failures on its own: it retries only timeouts and a fixed set of response codes. It does not retry a connection that drops mid-body. It also cannot detect a corrupted body: without a Content-Length, a stream that ends early looks like a complete transfer, and only Lake's hash check catches it.

The console output stays quiet: each retry attempt logs one warning line, and the detail of a failure that will be retried goes to the verbose log. The final attempt logs the same errors as before. For the tests, the mock cache server gains two stateful fault modes: flaky drops the first request for each object, and flakycorrupt corrupts the first response for each object. New tests cover download and upload retries, the attempt limit, a retry of only part of a batch, a batch that has both a permanent and a transient failure, and that a 404 is not retried.

Closes #14739

🤖 Generated with Claude Code

@github-actions github-actions Bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label Aug 10, 2026
@mathlib-lean-pr-testing

mathlib-lean-pr-testing Bot commented Aug 10, 2026

Copy link
Copy Markdown

Mathlib CI status (docs):

  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 7c90644a5f2a8a62e0cfc1dcf7a19c0d6c70c6ce --onto b1cd183c9978c3bedddc33baf7c9599baaeca046. You can force Mathlib CI using the force-mathlib-ci label. (2026-08-10 01:44:35)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 7c90644a5f2a8a62e0cfc1dcf7a19c0d6c70c6ce --onto 3fc29d37a70f8fd904ebab848557c12383543008. You can force Mathlib CI using the force-mathlib-ci label. (2026-08-10 15:30:21)

@leanprover-bot

Copy link
Copy Markdown
Collaborator

Reference manual CI status:

  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase 7c90644a5f2a8a62e0cfc1dcf7a19c0d6c70c6ce --onto b1cd183c9978c3bedddc33baf7c9599baaeca046. You can force reference manual CI using the force-manual-ci label. (2026-08-10 01:44:37)

@marcelolynch
marcelolynch force-pushed the lake-transfer-retry branch 3 times, most recently from 3b9af12 to 4f39097 Compare August 10, 2026 16:30
This PR makes `lake cache get` and `lake cache put` retry the transfers in a batch that fail in a transient way, instead of failing the whole batch after one attempt.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@marcelolynch
marcelolynch marked this pull request as ready for review August 10, 2026 17:43
@marcelolynch
marcelolynch requested a review from tydeu as a code owner August 10, 2026 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN

Projects

None yet

Development

Successfully merging this pull request may close these issues.

lake cache get fails a whole batch after one transient network failure

2 participants