Skip to content

feat(restore): add retry with exponential backoff for restore operations#1042

Open
benbjohnson wants to merge 1 commit intomainfrom
feat/retry-replica-client
Open

feat(restore): add retry with exponential backoff for restore operations#1042
benbjohnson wants to merge 1 commit intomainfrom
feat/retry-replica-client

Conversation

@benbjohnson
Copy link
Copy Markdown
Owner

@benbjohnson benbjohnson commented Jan 26, 2026

Summary

  • Add RetryReplicaClient wrapper that retries LTXFiles() and OpenLTXFile() on transient errors
  • Does NOT retry on os.ErrNotExist (legitimate "not found" response) or context errors
  • Uses configurable exponential backoff (delay doubles each retry, capped at MaxDelay)
  • Integrates with litestream restore command via new flags

New Flags

Flag Default Description
-retry-delay 1s Initial delay between retries
-retry-max-delay 30s Maximum delay (exponential backoff cap)
-retry-max-retries 5 Max retry attempts (0 to disable)

Usage

# Restore with default retry settings (enabled by default)
litestream restore -o /tmp/db s3://bucket/db

# Disable retries
litestream restore -retry-max-retries 0 -o /tmp/db s3://bucket/db

# Custom retry config
litestream restore -retry-delay 2s -retry-max-delay 60s -retry-max-retries 10 -o /tmp/db s3://bucket/db

Test plan

  • Unit tests for RetryReplicaClient (14 test cases)
  • Manual test with S3 backend
  • Verify no retry on missing files

Closes #1041

🤖 Generated with Claude Code

Add RetryReplicaClient wrapper that retries LTXFiles() and OpenLTXFile()
on transient errors with configurable exponential backoff. Does NOT retry
on os.ErrNotExist (legitimate "not found" response).

New restore command flags:
- -retry-delay: initial delay between retries (default: 1s)
- -retry-max-delay: maximum delay cap (default: 30s)
- -retry-max-retries: max retry attempts (default: 5, 0 to disable)

Closes #1041

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@benbjohnson benbjohnson marked this pull request as ready for review January 26, 2026 17:58
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.

Add RetryReplicaClient for restore command

1 participant