Skip to content

fix(object_store): refund unstarted attempt credits and gate hedge outcomes - #240

Merged
shikhar merged 1 commit into
mainfrom
fix/refund-unstarted-attempt-credits
Dec 5, 2026
Merged

shikhar merged 1 commit into
mainfrom
fix/refund-unstarted-attempt-credits

Conversation

@shikhar

@shikhar shikhar commented Dec 5, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Track whether a HedgePermit or new RetryPermit (AttemptBudget::try_retry() -> Option<RetryPermit>) started its attempt via start(), refunding ATTEMPT_COST (capped at MAX_CREDITS) on Drop when unstarted. RetryPermit::drop skips locking once started.
  • Represent per-attempt budget permits with AttemptCredit::{Hedge(HedgePhase, HedgePermit), Retry(RetryPermit)} inside AttemptPermits, making hedge/retry mutual exclusion and pre-acquired admission explicit in the type system, and activate permits inside ReplicaRequest::attempt's fetch closure so copies dropped before starting refund their credits.
  • Replace eager launched_hedge recording with ReplicaRequest::started_hedge set inside the fetch closure so unstarted hedges never report DownloadOutput.hedge or emit phantom cachey_hedges_total{outcome="lost"} increments.
  • Update docs/replica-reads.md to reflect unstarted credit refunds and started-hedge metric semantics.

Verification

  • cargo +nightly fmt
  • cargo clippy --locked --all-features --all-targets -- -D warnings --allow deprecated
  • cargo deny check
  • cargo nextest run --locked (unit test catching both missing refunds and missing MAX_CREDITS capping, plus deterministic paused-time tests verifying credit spend and refund for unpolled peer hedges, unpolled same-bucket hedges dropped by active.retain, and unpolled overload rescues)

Closes #238

@greptile-apps

greptile-apps Bot commented Dec 5, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5RetriggerView in Greptile

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

The PR refunds credits when a hedge or retry is dropped before its fetch starts. It also records hedge outcomes only after the hedge starts.

  • Replica downloads count hedges and retries only when their fetch starts.

Reviews (1) · Last reviewed commit: "fix(object_store): refund unstarted atte..." · Reviewed by Greptile

@shikhar
shikhar force-pushed the fix/refund-unstarted-attempt-credits branch from fff0e78 to 9587c11 Compare December 5, 2026 17:44
@shikhar
shikhar force-pushed the fix/refund-unstarted-attempt-credits branch from 9587c11 to fa340e5 Compare December 5, 2026 19:41
@shikhar
shikhar merged commit 0f32285 into main Dec 5, 2026
7 checks passed
@shikhar
shikhar deleted the fix/refund-unstarted-attempt-credits branch December 5, 2026 19:49
@github-actions github-actions Bot mentioned this pull request Dec 5, 2026
shikhar pushed a commit that referenced this pull request Dec 5, 2026
## 🤖 New release

* `cachey`: 0.13.7 -> 0.13.8

<details><summary><i><b>Changelog</b></i></summary><p>

<blockquote>

##
[0.13.8](0.13.7...0.13.8)
- 2026-12-05

### Fixed

- *(service)* record single-chunk egress only when response body is
polled ([#241](#241))
- *(object_store)* refund unstarted attempt credits and gate hedge
outcomes ([#240](#240))

### Other

- *(deps)* upgrade dependencies
([#242](#242))
- drop nightly Cargo cooldown requirement and soften Cargo.lock guidance
([#237](#237))
- pin rust-dependency-cooldown workflow to commit SHA
([#236](#236))
- use shared rust-dependency-cooldown workflow
([#234](#234))
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Detail Bug] Downloader budgets lose hedge/retry credits when follow-up attempt is dropped before first poll

1 participant