fix(collector): retry post-upload OSS verify per artifact on transient 404 - #594
Conversation
…t 404 The post-upload verify downloaded a just-PUT object exactly once per artifact and retried only by restarting the whole batch, classifying every failure the same. On this OSS internal endpoint object visibility lags by minutes, so a 404 NoSuchKey right after the PUT failed the verify even though the object was written (production 2026-08-02, all four #313 collection windows). download_remote_artifacts_with now wraps each artifact's runner call in a bounded retry (30 attempts with a fixed 20s delay, aligned with the gate script's ~600s window): non-zero child exits (the shape run_checked gives a 404) are retryable, while configuration-style errors fail immediately. The whole-batch outer loop in verify_remote_artifacts_with is replaced by this per-artifact retry, keeping the injected-runner abstraction and the content-comparison fail-fast semantics unchanged. Verification: cargo test -p hft-collector (367 passed, 0 failed, incl. transient-404, config fail-fast, and bounded-retry counterexamples); cargo fmt --check clean on the touched file; cargo clippy -D warnings clean. Refs #571
📝 WalkthroughWalkthroughChangesOSS verification retry flow
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant RemoteVerification
participant ArtifactDownloader
participant OSSChildProcess
RemoteVerification->>ArtifactDownloader: Download artifacts within shared wall-clock budget
ArtifactDownloader->>OSSChildProcess: Execute artifact download
OSSChildProcess-->>ArtifactDownloader: Return success or non-zero exit
ArtifactDownloader->>ArtifactDownloader: Retry retryable exits up to 30 attempts
ArtifactDownloader-->>RemoteVerification: Return artifacts or verification error
Possibly related issues
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@rust_hft/tools/collector/src/polymarket_upload.rs`:
- Around line 1965-1971: Update the OSS verification retry loop around the
`file_budget` and `runner` flow to check the remaining wall-clock budget before
each attempt and return the unavailable-artifact error immediately when it is
exhausted. Before the retry sleep in the `attempt` handling block, recompute the
remaining budget and cap the sleep duration at that value so verification cannot
continue beyond `OSS_READBACK_MAX_WALL_CLOCK`.
- Around line 1949-1964: The download helper’s retry count must be configurable
so the normal pre-upload existence probe is not retried. Add an explicit
attempt-count parameter or policy to the helper containing the loop over
OSS_VERIFY_DOWNLOAD_ATTEMPTS, pass one attempt from
remote_artifacts_exist_and_match_with, and retain the 30-attempt policy from
verify_remote_artifacts_with. Add a test covering a retryable non-zero probe
exit and assert that upload begins after the single probe.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 84dc7c18-5385-4bfd-8613-46e6ec0795d6
📒 Files selected for processing (1)
rust_hft/tools/collector/src/polymarket_upload.rs
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 615a9f2f48
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Change contract
The uploader's post-upload OSS verify retries each artifact download on explicit transient
NoSuchKey/HTTP 404 failures, with one bounded 30×20s policy (~600s) for post-upload verification and a single-shot pre-upload existence probe. Every attempt and backoff observes the shared wall-clock budget; configuration, spawn, permission, and other non-404 failures fail immediately.Out of scope
Dependency or merge order
Builds on #593 (
24fa4a65). Review follow-up is committed aseba34942.Focused validation
pre_upload_probe_is_single_shot_before_upload: a transient probe miss invokes one probe, then all three uploads start.remote_readback_budget_is_checked_before_attempt: zero remaining budget invokes no child process.remote_readback_non_404_exit_fails_without_retrying: captured permission/configuration output fails after one attempt.only_explicit_not_found_errors_are_retryable: unrelated text containing404is not retryable.remote_readback_retries_transient_404_until_object_is_visible: transient misses recover.remote_readback_retries_are_bounded: persistent misses stop at 30 attempts and retain local artifacts.cargo test -p hft-collector: 275 passed, 2 ignored, 0 failed.cargo clippy -p hft-collector --all-targets -- -D warnings: clean.rustfmt --edition 2021 --check tools/collector/src/polymarket_upload.rs: clean.Rollout/rollback impact
Uploader retry behavior only; no interface change. Rollback = revert
eba34942.Issue relationship
Refs #571