-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Be smarter about connection health checks #5795
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this one second?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Endless screaming.
It is. I wanted to use const which took away TimeUnit.toNanos().
| "Too many tunnel connections attempted: $MAX_TUNNEL_ATTEMPTS")) | ||
| } | ||
|
|
||
| idleAtNs = System.nanoTime() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assume this triggers the behaviour change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep.
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
| assertThat(server.takeRequest().getSequenceNumber()).isEqualTo(0); | ||
| } | ||
|
|
||
| @Test public void staleConnectionNotReusedForNonIdempotentRequest() throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved this test to Kotlin so that I could manipulate idleAtNs.
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