Skip to content

Add jitter to database retry backoff - #263

Open
asimawdah wants to merge 4 commits into
replit:masterfrom
asimawdah:fix/249-retry-backoff-jitter
Open

asimawdah wants to merge 4 commits into
replit:masterfrom
asimawdah:fix/249-retry-backoff-jitter

Conversation

@asimawdah

@asimawdah asimawdah commented Oct 25, 2026 •

Copy link
Copy Markdown

Summary

  • Add bounded random jitter to sync and async database exponential retry delays to spread retries during upstream 5xx bursts.
  • Add deterministic tests for both retry policies.

Fixes #249.

Testing

  • python3 -m compileall -q src/replit/database/database.py tests/test_database_retry.py — passed.
  • git diff --check — passed.

Spread sync and async database retries across clients during upstream error bursts. Add deterministic tests for jittered backoff and caps.
@asimawdah
asimawdah requested a review from a team as a code owner October 25, 2026 14:54
@asimawdah
asimawdah requested review from jckr and removed request for a team October 25, 2026 14:54
Bandit flags pseudo-random timing jitter as security-sensitive. Document that retry jitter only spreads request timing and suppress B311 at the two call sites.
Use SystemRandom for retry jitter so Bandit does not flag the timing distribution as cryptographically weak. Keep tests deterministic by patching the generator.
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.

SEV-lite: retry-induced tail amplification during upstream 5xx burst

1 participant