Skip to content

[UNDERTOW-1880] Graceful shutdown of HTTP/2 server using GOAWAY#1906

Open
fl4via wants to merge 6 commits intoundertow-io:mainfrom
fl4via:UNDERTOW-1880
Open

[UNDERTOW-1880] Graceful shutdown of HTTP/2 server using GOAWAY#1906
fl4via wants to merge 6 commits intoundertow-io:mainfrom
fl4via:UNDERTOW-1880

Conversation

@fl4via
Copy link
Copy Markdown
Member

@fl4via fl4via commented Feb 18, 2026

Jira:
https://issues.redhat.com/browse/UNDERTOW-1880

Follows up #1140 and #1905, for investigation of broken test

…SinkChannel

When a channel is flushed a frame can decide that it's the final frame,
triggering the channel to be closed. Previously all GOAWAY frames were
final frames, but during a graceful shutdown there is a need to be able
to send multiple GOAWAY frames without closing the channel.

Signed-off-by: Björn Svensson <bjorn.a.svensson@est.tech>
Signed-off-by: Flavia Rainone <frainone@redhat.com>
Signed-off-by: Björn Svensson <bjorn.a.svensson@est.tech>
Signed-off-by: Flavia Rainone <frainone@redhat.com>
… GOAWAY

Signed-off-by: Björn Svensson <bjorn.a.svensson@est.tech>
Signed-off-by: Flavia Rainone <frainone@redhat.com>
Use tracked HTTP/2 channels in GracefulShutdownHandler to
initate a graceful shutdown using GOAWAY according to RFC7540 6.8.
- Send initial GOAWAY with last stream id set to 2^31-1
- Send an updated GOAWAY with updated last stream id after 1 sec
- Force close if client has not already disconnected after 3 sec

Http/2 requests will be handled during the graceful shutdown,
but http/1 will be rejected with `503 Service Unavailable`

awaitShutdown() waits for both ongoing requests to finish and
for active HTTP/2 connections to be closed by the client.

Signed-off-by: Björn Svensson <bjorn.a.svensson@est.tech>
Signed-off-by: Flavia Rainone <frainone@redhat.com>
In addition to `suspend/resume of accepting new clients` its now also possible
to stop listening for new clients, i.e the listening socket will be closed.
This is needed when performing a graceful shutdown to avoid that clients just
reconnects via a new socket.

A code example of a graceful shutdown:

  // Stop listening for new client connections
  List<ListenerInfo> listeners = server.getListenerInfo();
  for (ListenerInfo listener : listeners) {
      listener.stop();
  }

  // Trigger a graceful shutdown of existing connections
  shutdownHandler.shutdown();

  // Wait for the graceful shutdown to finish
  shutdownHandler.awaitShutdown(6000);

  // Forceful shutdown of server
  server.stop();

Signed-off-by: Flavia Rainone <frainone@redhat.com>
Signed-off-by: Björn Svensson <bjorn.a.svensson@est.tech>
Signed-off-by: Flavia Rainone <frainone@redhat.com>
@fl4via fl4via added failed CI Introduced new regession(s) during CI check new feature / API change New feature to be introduced or a change to the API (non suitable to minor releases) labels Feb 18, 2026
@fl4via
Copy link
Copy Markdown
Member Author

fl4via commented Feb 18, 2026

@bjosv , to not let your code be forgotten, I created a new PR. And we will be doing a PR burn down right after Beta1 is released, for Beta2.
Feel free to create your own PR or to submit work on top of my PR (just open a PR against my branch in this case). If I find a free time slot, I will also try to investigate why is the test broken. Thanks!

@bjosv
Copy link
Copy Markdown
Contributor

bjosv commented Mar 27, 2026

@bjosv , to not let your code be forgotten, I created a new PR. And we will be doing a PR burn down right after Beta1 is released, for Beta2. Feel free to create your own PR or to submit work on top of my PR (just open a PR against my branch in this case). If I find a free time slot, I will also try to investigate why is the test broken. Thanks!

@fl4via I had some time to investigate it now and created fl4via#2 on to your branch. All tests seems to pass now when running mvn test -pl core.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

failed CI Introduced new regession(s) during CI check new feature / API change New feature to be introduced or a change to the API (non suitable to minor releases)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants