Skip to content

add dial retry backoff function.#3706

Merged
ndyakov merged 6 commits into
redis:masterfrom
mwhooker:backoff-function
Mar 19, 2026
Merged

add dial retry backoff function.#3706
ndyakov merged 6 commits into
redis:masterfrom
mwhooker:backoff-function

Conversation

@mwhooker

@mwhooker mwhooker commented Feb 10, 2026

Copy link
Copy Markdown
Contributor

We need a finer-grained ability to control backoff during dial. This lets us control the precise wait duration using a function we can pass in which takes an attempt number and returns a duration.


Note

Medium Risk
Changes connection establishment retry timing by introducing a pluggable backoff function, which can affect reconnect behavior under network failures. Scope is contained to dialing/retry configuration and defaults remain constant if unset.

Overview
Adds a new DialerRetryBackoff option (plumbed through Options, cluster/ring/sentinel/failover configs, and internal/pool.Options) to let callers customize the delay between failed dial attempts.

Updates the connection pool dial retry loop to compute per-attempt sleep via ConnPool.dialRetryBackoff, including clamping negative durations to 0, while preserving the prior constant-delay default based on DialerRetryTimeout.

Introduces helper constructors DialRetryBackoffConstant and DialRetryBackoffExponential (exponential + jitter + cap), adds a unit test for default/custom behavior, and documents the new retry/backoff knobs in README.md.

Written by Cursor Bugbot for commit 5d95b2e. This will update automatically on new commits. Configure here.

@ndyakov

ndyakov commented Feb 10, 2026

Copy link
Copy Markdown
Member

Hello @mwhooker , would you please add the backoff to the wordlist? I will review and test the changes with our internal e2e tests around end of week.

Comment thread dial_retry_backoff.go
@mwhooker

Copy link
Copy Markdown
Contributor Author

FYI we were able to resolve our issue this PR was designed to address. I still feel like this is a good change, but won't be sad if you close it.

@ndyakov

ndyakov commented Feb 20, 2026

Copy link
Copy Markdown
Member

@mwhooker I do think this additional is worth it, it can help people implement Exponential backoff as described in the documentation. Let's fix the comments, do run golangci fmt and we can proceed with merging this. Thank you.

ndyakov
ndyakov previously approved these changes Feb 26, 2026

@ndyakov ndyakov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you @mwhooker!

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Comment thread osscluster.go
ClusterOptions.clientOptions() was not propagating DialerRetryBackoff,
causing the backoff function to be silently ignored when set on a cluster
client.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@ndyakov ndyakov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

looks good, thank you once again @mwhooker

@ndyakov ndyakov merged commit 7c6b09e into redis:master Mar 19, 2026
33 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