Commit 66783a8
[FLINK-34644][runtime] Fix race condition in RestServerEndpoint shutdown (#27708)
* [FLINK-34644][runtime] Fix race condition in RestServerEndpoint shutdown causing flaky test
Change thenAccept to thenCompose in AbstractRestHandler.respondToRequest()
so that the returned future only completes after the HTTP response is fully
flushed to the network. Previously, the future returned by
HandlerUtils.sendResponse() was silently discarded, allowing
InFlightRequestTracker.deregisterRequest() to fire before the response
write completed. Under load this let shutDownInternal() tear down the
Netty event loops while response bytes were still in flight, causing
ConnectionClosedException on the client side.
* [FLINK-34644][sql-gateway] Apply same thenAccept to thenCompose fix in AbstractSqlGatewayRestHandler
Apply the same fix as AbstractRestHandler: change thenAccept to
thenCompose in respondToRequest() so the returned future only completes
after the HTTP response is fully flushed. This prevents the same race
condition where in-flight request deregistration could fire before the
response write completes.1 parent cd0d323 commit 66783a8
2 files changed
Lines changed: 2 additions & 2 deletions
File tree
- flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler
- flink-table/flink-sql-gateway/src/main/java/org/apache/flink/table/gateway/rest/handler
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
88 | | - | |
| 88 | + | |
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
91 | | - | |
| 91 | + | |
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
| |||
0 commit comments