Be smarter about connection health checks#5795
Merged
swankjesse merged 1 commit intomasterfrom Feb 17, 2020
Merged
Conversation
yschimke
reviewed
Feb 17, 2020
| companion object { | ||
| private const val NPE_THROW_WITH_NULL = "throw with null exception" | ||
| private const val MAX_TUNNEL_ATTEMPTS = 21 | ||
| private const val IDLE_CONNECTION_HEALTHY_NS = 1_000_000_000 // 10 seconds. |
Collaborator
Author
There was a problem hiding this comment.
Endless screaming.
It is. I wanted to use const which took away TimeUnit.toNanos().
yschimke
reviewed
Feb 17, 2020
| "Too many tunnel connections attempted: $MAX_TUNNEL_ATTEMPTS")) | ||
| } | ||
|
|
||
| idleAtNs = System.nanoTime() |
Collaborator
There was a problem hiding this comment.
Assume this triggers the behaviour change.
yschimke
approved these changes
Feb 17, 2020
d5967d4 to
d8aa784
Compare
Previously we didn't do any health checks at all until a connection completed a single exchange. This was awkward for HTTP/2, which could have multiple exchanges in-flight before any were health checked. We were also doing the awkward and expensive read timeout check on all non-GET requests on pooled connections. Now we only perform these checks if the connection was idle for 10 seconds or more. Closes: #5547
d8aa784 to
19cb19a
Compare
swankjesse
commented
Feb 17, 2020
| assertThat(server.takeRequest().getSequenceNumber()).isEqualTo(0); | ||
| } | ||
|
|
||
| @Test public void staleConnectionNotReusedForNonIdempotentRequest() throws Exception { |
Collaborator
Author
There was a problem hiding this comment.
I moved this test to Kotlin so that I could manipulate idleAtNs.
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.
Previously we didn't do any health checks at all until a
connection completed a single exchange. This was awkward
for HTTP/2, which could have multiple exchanges in-flight
before any were health checked.
We were also doing the awkward and expensive read timeout
check on all non-GET requests on pooled connections. Now
we only perform these checks if the connection was idle
for 10 seconds or more.
Closes: #5547