Open
Conversation
Collaborator
|
I already have something like this included in #3582 if you'd like to take a look. |
Author
I checked but still don't see any timeout around ping(). The code I modify seem unchanged. So pings can hang indefinitely, which can affect return_to_pool and test_before_acquire? |
Collaborator
|
sqlx/sqlx-core/src/pool/connection.rs Line 154 in 5d4a5dc This covers both the On the acquire side, the entire call to sqlx/sqlx-core/src/pool/inner.rs Line 177 in 5d4a5dc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.