Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

GracefulTermination does not take response entity streams into account #3209

Open
jrudolph opened this issue Jun 3, 2020 · 2 comments
Open
Labels
1 - triaged Tickets that are safe to pick up for contributing in terms of likeliness of being accepted bug t:core Issues related to the akka-http-core module t:server Issues related to the HTTP server

Comments

@jrudolph
Copy link
Contributor

jrudolph commented Jun 3, 2020

As observed in #3139 (comment), graceful termination does not take response entity streams into account. I.e. those streams could still be running when the deadline triggers. What currently happens is that due to

, the top of the server stack is immediately completed on graceful termination (i.e. even before the deadline). However, the controller prevents that this completion is propagated to the connection. Instead, after some time (related to server.stream-cancellation-delay) also cancellation arrives at the controller stage in which case the rest of the stack is completed. There are a few issues with that:

  • The stack should fail (where it just regularly completes currently), so that the connection is abandoned and the peer knows that something bad happened. Especially, for CloseDelimited entities, the stream will otherwise be silently truncated.
  • The stack should be completed only after the deadline and regardless of the stream-cancellation-delay or lingerTimeout.
  • (incidentally) the controller should be reviewed, why it closes the connection regularly after it has received cancellation from the user side
@jrudolph jrudolph added bug 1 - triaged Tickets that are safe to pick up for contributing in terms of likeliness of being accepted t:server Issues related to the HTTP server t:core Issues related to the akka-http-core module labels Jun 3, 2020
@jrudolph jrudolph added this to the 10.2.1 milestone Sep 1, 2020
@jrudolph jrudolph modified the milestones: 10.2.1, 10.2.2 Sep 30, 2020
@raboof raboof modified the milestones: 10.2.2, 10.2.3 Dec 8, 2020
@johanandren johanandren modified the milestones: 10.2.3, 10.2.4 Jan 18, 2021
@johanandren
Copy link
Member

Guessing there is something left here given that it was pushed across previous milestones

@johanandren johanandren modified the milestones: 10.2.4, 10.2.5 Feb 23, 2021
@jrudolph jrudolph modified the milestones: 10.2.5, 10.2.6 Jul 26, 2021
@jrudolph jrudolph modified the milestones: 10.2.6, 10.2.7 Aug 5, 2021
@zvuki
Copy link

zvuki commented Oct 23, 2021

Hi all, I am trying to take advantage of graceful shutdown using the code from the docs https://doc.akka.io/docs/akka-http/current/server-side/graceful-termination.html

val bindingFuture = Http().newServerAt("localhost", 8080).bind(routes)
  .map(_.addToCoordinatedShutdown(hardTerminationDeadline = 10.seconds))

I can't make it work though, it seems the connections are being dropped right away, no matter what deadline I set:

Oct 15, 2021 @ 16:18:34.106 -05:00    Aborting tcp connection to /127.0.0.1:41870 because of upstream failure: akka.http.impl.engine.server.ServerTerminationDeadlineReached: 
Server termination deadline reached, shutting down all connections and terminating server...
akka.http.impl.engine.server.GracefulTerminatorStage$$anon$1.installTerminationHandlers(ServerTerminator.scala:265)
akka.http.impl.engine.server.GracefulTerminatorStage$$anon$1.$anonfun$preStart$1(ServerTerminator.scala:211)
akka.http.impl.engine.server.GracefulTerminatorStage$$anon$1.$anonfun$preStart$1$adapted(ServerTerminator.scala:209)

Oct 15, 2021 @ 16:18:34.105 -05:00    [terminator] Initializing termination of server, deadline: 10.00 s

I can confirm that I have ~5 in-flight requests when it happens.

@jrudolph jrudolph modified the milestones: 10.2.7, 10.2.8 Nov 2, 2021
@jrudolph jrudolph modified the milestones: 10.2.8, 10.2.9 Feb 10, 2022
@jrudolph jrudolph modified the milestones: 10.2.9, 10.2.10 Mar 3, 2022
@johanandren johanandren modified the milestones: 10.2.10, 10.2.11 Sep 1, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
1 - triaged Tickets that are safe to pick up for contributing in terms of likeliness of being accepted bug t:core Issues related to the akka-http-core module t:server Issues related to the HTTP server
Projects
None yet
Development

No branches or pull requests

4 participants