Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Does your PR solve an issue?
The PR adds a optional and configurable ping timeout. Without ping timeout, some connections can get stuck indefinitely in rare circumstances, where a TCP connection is blackholed. I don't a reliable repro, but this is a clearly a problem that can happen, especially in cloud environments with live VM migrations, etc. This can affect the connection pool in two ways:
test_before_acquireis set to true. Unlike return_to_pool, the duration of this is bounded by the acquire timeout. However, if we trigger the acquire connection timeout, the caller will observe an error. However, if we configure a tighter ping timeout, the caller will be able to establish a new connection within the acquire timeout.To add this, add a configurable and optional ping timeout.
Is this a breaking change?
No. The default ping timeout is None, which means no timeout. I would personally set this to tens of seconds or less in a production environment, but kept the default to None so the change is opt-in.
Testing
Added tests that exercise the success and error (timeout) on acquire and return_to_pool. Duration::ZERO always results in timeout to facilitate making the tests non-flaky and deterministic.