Skip to content

[FLINK-34644][runtime] Fix race condition in RestServerEndpoint shutdown#27878

Open
balassai wants to merge 1 commit intoapache:release-1.20from
balassai:backport-FLINK-34644-release-1.20
Open

[FLINK-34644][runtime] Fix race condition in RestServerEndpoint shutdown#27878
balassai wants to merge 1 commit intoapache:release-1.20from
balassai:backport-FLINK-34644-release-1.20

Conversation

@balassai
Copy link
Copy Markdown
Contributor

@balassai balassai commented Apr 1, 2026

This is a backport of #27708 to release-1.20

@flinkbot
Copy link
Copy Markdown
Collaborator

flinkbot commented Apr 1, 2026

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run azure re-run the last Azure build

@balassai
Copy link
Copy Markdown
Contributor Author

balassai commented Apr 2, 2026

@flinkbot run azure

…own (apache#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.
@balassai balassai force-pushed the backport-FLINK-34644-release-1.20 branch from 850e77d to 66783a8 Compare April 2, 2026 08:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants