Skip to content

Misleading error log in pool dialConn if DialerRetryTimeout reached #3593

@Rikkuru

Description

@Rikkuru

Expected Behavior

This message in log should contain real number of dial attempts

 internal.Logger.Printf(ctx, "redis: connection pool: failed to dial after %d attempts: %v", maxRetries, lastErr)

Current Behavior

Error message uses maxRetries instead of real number of attempts made
If dial attempts take too long and DialerRetryTimeout is reached before attempts number reaches DialerRetries error message is wrong.

Possible Solution

  • move loop variable attempt outside os loop and use in in error log

Steps to Reproduce

will provide on a weekend if it is needed

Context (Environment)

This is log from my service is development environment. Dial timeout was too high so only one dial attemt was made.
Before I enabled debug log I was a little worried that service really spent 5 seconds in dialConn

2025-11-10T17:09:06.728221+00:00 qa myservice[48031]: 17:09:06.728154 debug: redis: dial <ip1>:6379(tcp) in 1.001085613s with dial tcp <ip1>:6379: i/o timeout
2025-11-10T17:09:06.728247+00:00 qa myservice[48031]: 17:09:06.728189 redis: connection pool: failed to dial after 5 attempts: dial tcp <ip1>:6379: i/o timeout

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions