Skip to content

fix(io): use checked_shl and saturating_mul in retry jitter calculation#6949

Merged
colin-ho merged 5 commits into
Eventual-Inc:mainfrom
ARDA7787:patch-1
May 21, 2026
Merged

fix(io): use checked_shl and saturating_mul in retry jitter calculation#6949
colin-ho merged 5 commits into
Eventual-Inc:mainfrom
ARDA7787:patch-1

Conversation

@ARDA7787
Copy link
Copy Markdown
Contributor

fix(io): use saturating_shl to prevent overflow in retry jitter calculation

@ARDA7787 ARDA7787 requested a review from a team as a code owner May 17, 2026 01:31
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 17, 2026

Greptile Summary

This PR fixes a potential integer overflow in the exponential backoff jitter calculation in src/daft-io/src/retry.rs by replacing 1 << attempts with 1u64.saturating_shl(attempts as u32), preventing a panic (debug) or wrap-around (release) when attempts is large.

  • The bit-shift overflow is correctly addressed, but the immediately following multiplication * self.jitter_ms is still a plain * that can itself overflow u64 when attempts is large (≥ 53 with the default jitter_ms = 2500), meaning the fix is incomplete.
  • For the default max_tries = 4, none of these overflow paths are reachable in practice, but non-default configurations with a high max_tries remain vulnerable.

Confidence Score: 3/5

Safe for the default configuration, but the fix is incomplete — a multiplication overflow remains on the same line that was just patched.

The shift overflow is addressed, but the immediately following * self.jitter_ms is still a plain multiply. For any deployment that raises max_tries above ~52, the product overflows u64, producing either a panic (debug) or a corrupted jitter range (release). The default max_tries = 4 is not affected, so production risk is low today, but the fix leaves an identical class of bug one operator away from the line it just corrected.

src/daft-io/src/retry.rs — the jitter range construction on line 63 needs saturating_mul to match the intent of saturating_shl.

Important Files Changed

Filename Overview
src/daft-io/src/retry.rs Replaces 1 << attempts with 1u64.saturating_shl(attempts as u32) to prevent shift overflow; the subsequent multiplication by jitter_ms remains a plain * and can still overflow u64 for large attempts values.

Reviews (1): Last reviewed commit: "Fix jitter calculation in retry logic" | Re-trigger Greptile

Comment thread src/daft-io/src/retry.rs
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 18a78e86c4

ℹ️ 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".

Comment thread src/daft-io/src/retry.rs Outdated
@rchowell
Copy link
Copy Markdown
Contributor

Hi @ARDA7787 we can get this merged if you could please fix the checks. Thank you!

@ARDA7787 ARDA7787 changed the title Fix jitter calculation in retry logic fix(io): use saturating_shl and saturating_mul in retry jitter calculation May 20, 2026
@github-actions github-actions Bot added the fix label May 20, 2026
@ARDA7787 ARDA7787 changed the title fix(io): use saturating_shl and saturating_mul in retry jitter calculation fix(io): use checked_shl and saturating_mul in retry jitter calculation May 21, 2026
@colin-ho colin-ho merged commit 024aad0 into Eventual-Inc:main May 21, 2026
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants