Use proper executor for failing requests when connection closes#109236
Conversation
Now use the executor declared by the handler rather than generic, since using generic is trappy wrt. deadlocks. Closes elastic#109225
|
Hi @henningandersen, I've created a changelog YAML for you. |
|
Opening as draft to see what CI and devs thinks before adding more tests. |
|
ci/part-2 failure is #109237 |
|
This is now ready for reviews. |
|
Pinging @elastic/es-distributed (Team:Distributed) |
DaveCTurner
left a comment
There was a problem hiding this comment.
Overall approach looks good, I left a handful of smaller comments.
| if (enableStackOverflowAvoidance == false) { | ||
| handler.handleException(exception); | ||
| } else { | ||
| threadPool.generic().submit(new AbstractRunnable() { |
There was a problem hiding this comment.
I think I'd rather we used a ForkingResponseHandlerRunnable on both branches here, even though ofc GENERIC doesn't reject anything today so it doesn't really matter.
There was a problem hiding this comment.
It is slightly annoying in that it asserts that the handler is not using direct executor, hence i did this route. I can make it work ofc, let me give it a shot.
There was a problem hiding this comment.
Yeah sure I meant not for the direct case, just if enableStackOverflowAvoidance
There was a problem hiding this comment.
Yeah, absolutely, the handler verification is still annoying, but made it slightly more optional when fixing this here:
| })), unusedReader(), executor) | ||
| ); | ||
| nodeA.transportService.onConnectionClosed(connection); | ||
| expectThrows(ExecutionException.class, NodeDisconnectedException.class, () -> future.get(10, TimeUnit.SECONDS)); |
There was a problem hiding this comment.
Suggest using an org.elasticsearch.action.support.ActionTestUtils#assertNoSuccessListener and one of the safeAwait or safeGet methods.
server/src/test/java/org/elasticsearch/transport/TransportServiceLifecycleTests.java
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/transport/TransportService.java
Outdated
Show resolved
Hide resolved
| @Nullable TransportException transportException, | ||
| Executor executorUsed | ||
| ) { | ||
| assert executorUsed != EsExecutors.DIRECT_EXECUTOR_SERVICE : "forking handler required, but got " + handler; |
server/src/test/java/org/elasticsearch/transport/TransportServiceLifecycleTests.java
Show resolved
Hide resolved
|
Thanks David! |
When TransportService fails to send a transport action, it can complete the listener's `onFailure` with the `generic` executor. If the listener is a `PlainActionFuture` and also waits to be completed with a `generic` thread, it will trip the `assertCompleteAllowed` assertion. https://github.com/elastic/elasticsearch/blob/fb482f863d5430702b19bd3dd23e9d8652f12ddd/server/src/main/java/org/elasticsearch/transport/TransportService.java#L1062-L1064 With this PR, we no longer fork to the generic thread pool and instead just handle the exeption inline with the current thread. The expectation is that the downstream handler should take care potential stack overflow issues. This is similar to what is done in #109236
…#114375) When TransportService fails to send a transport action, it can complete the listener's `onFailure` with the `generic` executor. If the listener is a `PlainActionFuture` and also waits to be completed with a `generic` thread, it will trip the `assertCompleteAllowed` assertion. https://github.com/elastic/elasticsearch/blob/fb482f863d5430702b19bd3dd23e9d8652f12ddd/server/src/main/java/org/elasticsearch/transport/TransportService.java#L1062-L1064 With this PR, we no longer fork to the generic thread pool and instead just handle the exeption inline with the current thread. The expectation is that the downstream handler should take care potential stack overflow issues. This is similar to what is done in elastic#109236
#114493) When TransportService fails to send a transport action, it can complete the listener's `onFailure` with the `generic` executor. If the listener is a `PlainActionFuture` and also waits to be completed with a `generic` thread, it will trip the `assertCompleteAllowed` assertion. https://github.com/elastic/elasticsearch/blob/fb482f863d5430702b19bd3dd23e9d8652f12ddd/server/src/main/java/org/elasticsearch/transport/TransportService.java#L1062-L1064 With this PR, we no longer fork to the generic thread pool and instead just handle the exeption inline with the current thread. The expectation is that the downstream handler should take care potential stack overflow issues. This is similar to what is done in #109236
…#114375) When TransportService fails to send a transport action, it can complete the listener's `onFailure` with the `generic` executor. If the listener is a `PlainActionFuture` and also waits to be completed with a `generic` thread, it will trip the `assertCompleteAllowed` assertion. https://github.com/elastic/elasticsearch/blob/fb482f863d5430702b19bd3dd23e9d8652f12ddd/server/src/main/java/org/elasticsearch/transport/TransportService.java#L1062-L1064 With this PR, we no longer fork to the generic thread pool and instead just handle the exeption inline with the current thread. The expectation is that the downstream handler should take care potential stack overflow issues. This is similar to what is done in elastic#109236
…#114375) When TransportService fails to send a transport action, it can complete the listener's `onFailure` with the `generic` executor. If the listener is a `PlainActionFuture` and also waits to be completed with a `generic` thread, it will trip the `assertCompleteAllowed` assertion. https://github.com/elastic/elasticsearch/blob/fb482f863d5430702b19bd3dd23e9d8652f12ddd/server/src/main/java/org/elasticsearch/transport/TransportService.java#L1062-L1064 With this PR, we no longer fork to the generic thread pool and instead just handle the exeption inline with the current thread. The expectation is that the downstream handler should take care potential stack overflow issues. This is similar to what is done in elastic#109236
…warning This setting is not getting removed in ES 9.0, so its usage should not generate a critical deprecation warning. `TransportServiceLifecycleTests` already uses `assertWarnings` instead of `assertCriticalWarnings` and we don't distinguish between warning levels in assertions (See elastic#80304) See elastic#109236 See ES-11224
…warning (#124788) This setting is not getting removed in ES 9.0, so its usage should not generate a critical deprecation warning. `TransportServiceLifecycleTests` already uses `assertWarnings` instead of `assertCriticalWarnings` and we don't distinguish between warning levels in assertions (See #80304) See #109236 See ES-11224
This setting was supposed to be removed in 9.0, but turned to be non-critical. We should remove it in ES 10.0 See #109236 See ES-11224
Now use the executor declared by the handler rather than generic, since using generic is trappy wrt. deadlocks.
Closes #109225