fix(prover): make shard and reduce tasks idempotent under re-delivery#2848
Merged
Conversation
Contributor
|
Contributor
|
I see the need for the fix but the implementation seems a bit messy. Maybe there is a cleaner way to do this with some sort of method on the raw proof requests that checks that outputs exist? |
tamirhemo
reviewed
Jun 18, 2026
| deferred_upload_handle.await.map_err(|e| TaskError::Fatal(e.into()))??; | ||
| } | ||
|
|
||
| // Reclaim the input record only after every output (`output` and the |
tamirhemo
approved these changes
Jun 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The cluster delivers tasks at-least-once — the same
task_idcan run again via dead-worker requeue (30s heartbeat timeout) or fair-share preemption requeue. But a prover task deletes its input artifact on success ("no longer needed"). So a re-run downloads an input a prior run already deleted →NotFound→TaskError::Fatal→fail_proof→ the whole request goes Unfulfillable, even though a valid proof already exists.Observed on mainnet: a ProveShard uploaded its proof; fair-share preemption requeued the same task a few ms later; the re-run on another worker 404'd on the deleted input and failed the proof. The duplicate-delivery path produced the same failure repeatedly.
Fix
Two parts, so re-execution is harmless and prompt reclamation is kept:
Idempotent consumers. On an input-download failure, if the input is gone and the task's output already exists, a prior run already did the work — report success instead of failing. Applied to ProveShard (
prover/core.rs) and recursion reduce (node/full/init.rs, withReduceTaskRequest::already_reduced/RangeProofs::any_proof_missing).Delete inputs last. A consumer deletes its input only after every output is durable. ProveShard produces two outputs (
output+deferred_output); the input delete was moved after the deferred upload completes, so "input gone" means the task is fully done — not partway. (This also fixes a latent bug: a deferred-upload failure previously returned an error after the input was already deleted, so the retry 404'd.)The eager delete stays (prompt reclamation — important on memory-bounded stores); (1) and (2) make it safe.