Skip to content

Optional backoff #251

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

Optional backoff #251

wants to merge 3 commits into from

Conversation

madchicken
Copy link
Collaborator

@madchicken madchicken commented Jul 20, 2025

A PR to make backoff optional (and disable it for routed connections). It introduces a new BackoffConfig structure to provide configurable retry logic for database connections. It replaces the previously hardcoded exponential backoff logic with a more flexible and customizable approach. The changes include updates to configuration structures, builders, and relevant tests, as well as modifications to integrate the new backoff logic into connection management and retry mechanisms.

NOTE: The PR is in DRAFT since it is still untested.

New Backoff Configuration:

  • Added BackoffConfig struct with fields for multiplier, min_delay_ms, max_delay_ms, and total_delay_ms, along with a default implementation. This struct allows customization of backoff behavior. (lib/src/config.rs, lib/src/config.rsR71-R151)
  • Implemented BackoffConfigBuilder to facilitate the construction of BackoffConfig instances with optional parameters. (lib/src/config.rs, lib/src/config.rsR71-R151)

Integration with Configuration:

  • Updated Config and ConfigBuilder to include an optional backoff field, allowing backoff settings to be specified during configuration. (lib/src/config.rs, [1] [2]
  • Adjusted the default ConfigBuilder to include a default BackoffConfig. (lib/src/config.rs, lib/src/config.rsR286)

Connection Management:

  • Modified ConnectionManager to accept an optional BackoffConfig and use it to generate an ExponentialBuilder for retry logic. (lib/src/pool.rs, [1] [2]
  • Updated create_pool to pass the backoff configuration when creating a connection manager. (lib/src/pool.rs, lib/src/pool.rsR59)

Retry Logic Updates:

  • Updated retry logic in Graph and RoutedConnectionManager to use the optional BackoffConfig. If no backoff is provided, retries are skipped. (lib/src/graph.rs, [1] [2] [3]; lib/src/routing/routed_connection_manager.rs, [4] [5]

Tests:

  • Enhanced tests to validate the behavior of BackoffConfig and its integration into Config and ConfigBuilder. Tests now check for proper handling of default and custom backoff configurations. (lib/src/config.rs, [1] [2] [3] [4]
  • Adjusted tests in routing/connection_registry.rs to account for the optional backoff field. (lib/src/routing/connection_registry.rs, [1] [2]

@madchicken madchicken self-assigned this Jul 20, 2025
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.

1 participant