-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
HystrixMetricsStreamServlet.destroy() not invoked until container timeout #346
Comments
What is your suggested solution? I personally have not used a deployment model in a very long time that depends on graceful shutdown. We always kill the entire container/app and restart cleanly. This is a good example of why. |
Lucky you ;-) Unfortunately we have to work with WAS, which runs several other applications so shutting down the server for each deployment is not a possibility. I have been thinking about it but cannot come up with a solution, Just was wondering if anyone could suggest a workaround... |
I hit the same issue with WebSphere. I meant to submit as a pull request but welcome review here. I added a static shutdown() method to HystrixMetricsStreamServlet and call it from one of my other servlets that only implements init() and destroy(). Also note the extra check required after the flush to detect when a polling client has disconnected. WebSphere buffers the response and from what I saw, the servlet never stops writing to the output stream even 20 minutes after the client disconnected.
|
@jboyd01 I just tested it and works like a charm, thanks for sharing. I'll wait for your pull request to get it integrated into hystrix. |
@jboyd01 I don't have a great way of testing this, as I'm not familiar with Websphere or WAS. Are you (or anyone else) still interested in submitting a pull request? |
Moving this out of RC6. I'm happy to merge in a PR from someone who experiences this issue, but don't have enough context to work on it myself. |
@mattrjacobs I could (and will) submit jboyd01's solution as a PR. We are planning to implement Hystrix-enabled services in the next months and will definitely need that workaround. |
Great, thanks @codependent! |
We also just hit this issue running the metrics stream servlet from within embedded Jetty. |
…ed client (issue Netflix#346) WebSphere won't shutdown a servlet until after a 60 second timeout if there is an instance of the servlet executing a request. Add a shutdown method to enable a hook to notify Hystrix to shutdown. You must invoke this method at app server shutdown, perhaps from another servlet's destroy() method. Also added explicit checkError() in poller loop to check for disconnected client.
@codependent / @lasselasse I just merged this into master. Are you able to test @jboyd01 's solution currently or do you need an official RC release? |
@mattrjacobs I don't really need a RC thanks. I'll test it tomorrow (out of the office right now) and let you know if it's OK. |
Great, thanks @codependent |
@mattrjacobs I just tested it, and it works OK. Thanks to @jboyd01 for this workaround. |
@mattrjacobs tested the patch and it works great, thanks! May I suggest the doGet method to be modified as follows so the servlet will directly reject requests once it has been shutdown? (At the moment it would still start a new HystrixMetricsPoller only to shut it down again.)
|
I'd like to point out one important thing: jboyd01 suggested using another servlet's destroy() to invoke The reason is that WS doesn't invoke any servlet.destroy() until all requests have finished. And yet, it does destroy JSPs (which, like everybody knows, are a kind of servlet, WTH?). The only way I found to invoke
|
Since we run a Spring application I'm triggering the shutdown from a ContextClosedEvent-listener which is invoked before the embedded Jetty is shutdown.
|
@codependent I'm late replying, but wanted to note that I'm successfully exercising the shutdown of the stream servlet from a 2nd servlet under WebSphere 8.5.5.2 ND. I have a HystrixControl servlet with just two methods: public void destroy() {
HystrixMetricsStreamServlet.shutdown();
Hystrix.reset();
}
public void init(){
// invoke code to set configuration source & register concurrency strategy
} and its registered via web.xml: <servlet>
<servlet-name>HystrixControl</servlet-name>
<servlet-class>
com.acme.projectx.init.HystrixControl
</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet> I exercise my application, then hit the hystrix.stream with curl and let it stream away. When I stop the application via admin console I get immediate shutdown - - the streaming stops and WebSphere reports the app as stopped in the logs within seconds of the stop attempt. I do like the options of doing this via an EJB and ContextClosedEvent listener. I think it may be wise to start a doc page that details App Server specific implementation details. |
@jboyd01 thanks for the feedback :-) Right now it doesn't work for us but it must be something related to the container so I'll take it into account when we move from 8.0.x.x to 8.5. |
@codependent I'm inclined to close this issue and let you open a new issue with details specific to your case. Does that sound OK to you? |
@mattrjacobs It's alright to me. |
#530 does not seem to have fixed the client disconnect detection on WebSphere |
Scenario:
The servlet's destroy() method is not called, thus isDestroyed is not modified until timeout. This makes sense since, according to the servlet spec: void destroy() - Called by [...] This method is only called once all threads within the servlet's service method have exited or after a timeout period has passed.
The problem is that since there is a running request, whenever we want to republish/stop our application, we have to wait 60 seconds until our container (Websphere Application Server 8) forces the destruction of the servlet.
The text was updated successfully, but these errors were encountered: