-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Support http read timeouts for transport-nio #41466
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
Pinging @elastic/es-distributed |
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.
2 nits and a suggested simplification :)
plugins/transport-nio/src/main/java/org/elasticsearch/http/nio/HttpReadWriteHandler.java
Show resolved
Hide resolved
plugins/transport-nio/src/test/java/org/elasticsearch/http/nio/NioHttpServerTransportTests.java
Outdated
Show resolved
Hide resolved
plugins/transport-nio/src/main/java/org/elasticsearch/http/nio/HttpReadWriteHandler.java
Outdated
Show resolved
Hide resolved
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.
lefts some comments
plugins/transport-nio/src/main/java/org/elasticsearch/http/nio/HttpReadWriteHandler.java
Show resolved
Hide resolved
plugins/transport-nio/src/main/java/org/elasticsearch/http/nio/HttpReadWriteHandler.java
Outdated
Show resolved
Hide resolved
plugins/transport-nio/src/main/java/org/elasticsearch/http/nio/NioHttpServerTransport.java
Outdated
Show resolved
Hide resolved
@s1monw @original-brownbear - I made your changes. Thanks. |
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.
Changes look good except for the added method on ThreadPool
, let me know what you think there.
* timestamp, see {@link #absoluteTimeInMillis()}. | ||
*/ | ||
public long relativeTimeInNanos() { | ||
return TimeValue.msecToNSec(cachedTimeThread.relativeTimeInMillis()); |
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.
@tbrooks8 I'm not sure we should add this. The underlying logic as it is coded up now isn't nano second precise.
We could adjust CachedTimeThread
to return nano second precision times and only add the rounding to ms
in the existing relativeTimeInMillis
method?
But then again, maybe we don't need ns
for the http timeout in the first place and can just work with ms
precision and not add more complication to the ThreadPool
class?
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.
We could adjust CachedTimeThread to return nano second precision times and only add the rounding to ms in the existing relativeTimeInMillis method?
I think this is the correct approach, but I hesitated to change it in this PR as the behavior of the timer tick thread might be of concern to other people. Anyway, I will make that change and we can discuss.
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.
Anyway, I made this change.
- We need nanoseconds.
TaskScheduler
deals in nanoseconds. - If we do the conversion outside of the
ThreadPool
we depend on the fact thatThreadPool
will always return a relative millis value that can be successfully converted to nanoseconds. Obviously this is the case as the value originates from nanotime, but I prefer to not depend on that fact. Which is why I prefer thatThreadPool
returns nanotime (similar to the fact that most Java relative time calculations are made using nanotime). - The cost of the change is division every time you want millis. I assume this is fine, but obviously the entire point of this tick thread is to replace a
System.nanotime
call with a volatile read at the cost of resolution. So maybe there is some objection. We could also store a precalculated version in millis.
thanks @tbrooks8 LGTM now |
/cc @andrershov that we can as part of the netty vs nio benchmarking check whether enabling http read timeouts have any effect either way. |
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.
With my limited understanding of this, I mainly looked at it to learn a few things about the NIO implementation.
plugins/transport-nio/src/test/java/org/elasticsearch/http/nio/HttpReadWriteHandlerTests.java
Outdated
Show resolved
Hide resolved
.../transport-netty4/src/main/java/org/elasticsearch/http/netty4/Netty4HttpServerTransport.java
Show resolved
Hide resolved
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.
LGTM
server/src/main/java/org/elasticsearch/threadpool/ThreadPool.java
Outdated
Show resolved
Hide resolved
@elasticmachine run elasticsearch-ci/1 |
@elasticmachine run elasticsearch-ci/2 |
This is related to elastic#27260. Currently there is a setting http.read_timeout that allows users to define a read timeout for the http transport. This commit implements support for this functionality with the transport-nio plugin. The behavior here is that a repeating task will be scheduled for the interval defined. If there have been no requests received since the last run and there are no inflight requests, the channel will be closed.
This is related to elastic#27260. Currently there is a setting http.read_timeout that allows users to define a read timeout for the http transport. This commit implements support for this functionality with the transport-nio plugin. The behavior here is that a repeating task will be scheduled for the interval defined. If there have been no requests received since the last run and there are no inflight requests, the channel will be closed.
This is related to #27260. Currently there is a setting http.read_timeout that allows users to define a read timeout for the http transport. This commit implements support for this functionality with the transport-nio plugin. The behavior here is that a repeating task will be scheduled for the interval defined. If there have been no requests received since the last run and there are no inflight requests, the channel will be closed.
This is related to elastic#27260. Currently there is a setting http.read_timeout that allows users to define a read timeout for the http transport. This commit implements support for this functionality with the transport-nio plugin. The behavior here is that a repeating task will be scheduled for the interval defined. If there have been no requests received since the last run and there are no inflight requests, the channel will be closed.
This is related to #27260. Currently there is a setting
http.read_timeout
that allows users to define a read timeout for thehttp transport. This commit implements support for this functionality
with the transport-nio plugin. The behavior here is that a repeating
task will be scheduled for the interval defined. If there have been
no requests received since the last run and there are no inflight
requests, the channel will be closed.