-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Review Graceful shutdown in jetty-10 #4321
Comments
@sbordet @janbartel @joakime @lachlan-roberts @olamy have a think about this one.... I'm going to ask for some design review before I commit too much code. Feel free to riff your thoughts here. |
My current thoughts are that we should:
To gracefully shutdown a content:
To coordinate the shutdown of a server it is a little more complex:
|
The issue with the above is that the QTP graceful shutdown should not be done until everything else is shutdown, as threads may be needed to do graceful closing handshakes etc. I think the solution is to separate out the |
Do we want to tackle HttpClient as well? (Issue #1445) |
Signed-off-by: Greg Wilkins <gregw@webtide.com>
removed stopTimeout from all abstractLifeCycles. It is on Graceful.LifeCycle, which is only implemented by components that can start a graceful shutdown (eg Server, ContextHandler and QueuedThreadPool) Signed-off-by: Greg Wilkins <gregw@webtide.com>
cleanup after review Signed-off-by: Greg Wilkins <gregw@webtide.com>
reinstate other stop tests (more work to do). Signed-off-by: Greg Wilkins <gregw@webtide.com>
Fixes for stop test by improving LocalConnector shutdown handling Signed-off-by: Greg Wilkins <gregw@webtide.com>
Removed broken test on LocalConnector that is already tested in GracefulStopTest Signed-off-by: Greg Wilkins <gregw@webtide.com>
Fixed all stop tests Signed-off-by: Greg Wilkins <gregw@webtide.com>
fixed checkstyle Signed-off-by: Greg Wilkins <gregw@webtide.com>
No stopTimeout JMX attribute Signed-off-by: Greg Wilkins <gregw@webtide.com>
Dump stopTimeout test with default stopTimeout Signed-off-by: Greg Wilkins <gregw@webtide.com>
USe sendError for 503 Signed-off-by: Greg Wilkins <gregw@webtide.com>
minor cleanups Signed-off-by: Greg Wilkins <gregw@webtide.com>
Simplifications after review Signed-off-by: Greg Wilkins <gregw@webtide.com>
after review Signed-off-by: Greg Wilkins <gregw@webtide.com>
after review Signed-off-by: Greg Wilkins <gregw@webtide.com>
* Issue #4321 Refactored Graceful shutdown removed stopTimeout from all abstractLifeCycles. It is on Graceful.LifeCycle, which is only implemented by components that can start a graceful shutdown (eg Server, ContextHandler and QueuedThreadPool) Signed-off-by: Greg Wilkins <gregw@webtide.com> * Issue #4321 Refactored Graceful shutdown cleanup after review Signed-off-by: Greg Wilkins <gregw@webtide.com> * Issue #4321 Refactored Graceful shutdown reinstate other stop tests (more work to do). Signed-off-by: Greg Wilkins <gregw@webtide.com> * Issue #4321 Refactored Graceful shutdown Fixes for stop test by improving LocalConnector shutdown handling Signed-off-by: Greg Wilkins <gregw@webtide.com> * Issue #4321 Refactored Graceful shutdown Removed broken test on LocalConnector that is already tested in GracefulStopTest Signed-off-by: Greg Wilkins <gregw@webtide.com> * Issue #4321 Refactored Graceful shutdown Fixed all stop tests Signed-off-by: Greg Wilkins <gregw@webtide.com> * Issue #4321 Refactored Graceful shutdown fixed checkstyle Signed-off-by: Greg Wilkins <gregw@webtide.com> * Issue #4321 Refactored Graceful shutdown No stopTimeout JMX attribute Signed-off-by: Greg Wilkins <gregw@webtide.com> * Issue #4321 Refactored Graceful shutdown Dump stopTimeout test with default stopTimeout Signed-off-by: Greg Wilkins <gregw@webtide.com> * Issue #4321 Refactored Graceful shutdown USe sendError for 503 Signed-off-by: Greg Wilkins <gregw@webtide.com> * Issue #4321 Refactored Graceful shutdown minor cleanups Signed-off-by: Greg Wilkins <gregw@webtide.com> * Issue #4321 Refactored Graceful shutdown Simplifications after review Signed-off-by: Greg Wilkins <gregw@webtide.com> * Issue #4321 Refactored Graceful shutdown after review Signed-off-by: Greg Wilkins <gregw@webtide.com> * Issue #4321 Refactored Graceful shutdown after review Signed-off-by: Greg Wilkins <gregw@webtide.com>
Currently jetty-9 has a number of features associated with stopping and graceful shutdown that are somewhat duplicated/orthogonal/confused:
LifeCycle
objects have thestop()
method, butAbstractLifeCycle
objects have asetStopTimeout
that imposes a maximum time thatstop()
can execute for, however this is not a cumulative time for aggregated LifeCycles!Graceful
interface that has aFuture<Void> shutdown()
API that allows for cumulative timeout handling. It is implemented byConnector
s,ContextHandler
and theStatisticsHandler
ContextHandler
has an availability mechanism that includes the states:UNAVAILABLE
,STARTING
,AVAILABLE
,SHUTDOWN
. This mechanism is tied to both theLifeCycle
stop/start and theGraceful
API.NetworkConnector
interface hasopen()
andclose()
methods that can be invoked independently ofstart()
andstop()
to affect availability of the listening port.AbstractConnector
class has thesetAccepting(boolean)
method that affects the availability of the connector to accept new connections.All these mechanisms need to be rationalised into a single mechanism. To consider what design that mechanism needs, we need to consider the following active participants in the stop/start/graceful/available conversation:
QueuedThreadPool
has an atomic mechanism to stop accepting new jobs and adoStop()
implementation that waits half a stop timeout for jobs to stop naturally before interrupting remaining threads and waiting another half stop timeout for them to stop. Any jobs left in the queue that areCloseable
are closed... which can also be an operation that takes time and could potentially even block.AbstractConnector.setAccepting(boolean)
mechanism use a lock condition to hold up the acceptors to prevent them accepting new connections when not accepting.AbstractNetworkConnector.shutdown()
does not use thesetAccepting(boolean) mechanism, but does a more permanent
close()` before declaring shutdown complete.StatisticHandler.shutdown()
method is implemented to return aFuture
that is completed once the active request count goes to zero. The handler does not prevent new requests from being dispatched.ContextHandler.shutdown()
method is implemented using it's availability state, which stops new requests from being accepted by the context by sending a 503 response (which can be redispatched in a ERROR dispatch... but that will then also get a sendError... so perhaps some refinement needed on that response)ManagedSelector.doStop()
currently does an unbounded wait for connections to be closed, followed by an unbounded wait for the selectors to be stopped. Both of those probably should be time limited if possible.The text was updated successfully, but these errors were encountered: