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
Return proper exit code for TERM signal, JRuby #1558
Comments
Thanks for reporting this and the cc. I am also able to reproduce the issue with an external (systemd oriented) test harness, on branch and the versions in the Gemfile.lock shown: https://github.com/dekellum/lionfish/blob/puma-jruby/Gemfile.lock The issue anecdotally seems more common on jruby-9.1.16, but at least with my test harness, the problem is intermittent: only sometimes do I see the same stack trace and the error code 1 (which in my case, gets logged as a failure in systemd.) I can reproduce the issue on jruby 9.1.14 and 9.1.12 as well (though it seems less frequent). My test harness is with puma 3.10.0, so this isn't a very recent puma regression. I'm not sure how or if I missed this issue in my prior testing around #1337. I guess another possible change is JDK version? I see you are using Java 9. I'm now testing on a recent version of Open JDK 8:
If you want to pursue this, I would suggest attempting to reduce it to a simple non-puma test ruby script that exits by explicitly raised SignalException: raise SignalException, "SIGTERM" If you can get that to fail in the same way on jruby, then you could report the issue there. |
Sadly, proper exit code isn't tested on jruby, presumably due to lack of fork support. Couldn't this be done instead with a thread in the jruby case? cc: @shayonj |
That's actually exactly what I'm seeing as well - intermittent CI failures in my specs! Interesting. With the
Actually, as mentioned above, I did test it with both OpenJDK 8 and 9. The "five times" mentioned now is with Java 8.
Interestingly enough, it does indeed fail for me consistently. Even with a 1.7 JRuby, it does. If you manage to add tests for it here, that's great - I think I'll file a JRuby issue about this as well, since it does indeed seem to be an upstream issue. Thanks for your feedback thus far! |
@perlun Am I correct in understanding that this was fixed by jruby/jruby#5134? |
@nateberkopec Thanks for asking. I think it might not be, since I've unfortunately still have seen intermittent CI failures. Will try to revisit this next week to see how it behaves w/ latest JRuby and keep you posted. |
@perlun - Do we have any plan to fix this in near future ? |
@anup1710 No longer using JRuby or Puma unfortunately (switched jobs) so for me personally, don't know of any plans to fix this. Is the issue causing problems for you currently? |
Yes, I saw this in jruby 9.2.6 with puma 3.12.0 in Windows machine. |
@nateberkopec See above - the issue still seems to remain, unfortunately. |
I think this is failing on CI here: https://travis-ci.org/puma/puma/jobs/584683964#L808 Local output for me:
|
A clue - that double-log at the end. It looks like something is calling stop_blocked twice. However, when I add a
A race condition somewhere changes, and the shutdown text prints once and the correct exit code (143) is returned. |
I'm guessing that the server status gets set to :stop, and the server run thread and the sigterm handler race each other. |
Actually, I think there's a problem with the test that's unrelated, but it passes, and yet Jruby is actually exiting with status 0 for me locally. |
OK, I fixed + discovered some unrelated JRuby stuff along the way, but I also discovered a 0 exit code from SIGTERM is the JVM's fault, not ours or JRuby's. See jruby/jruby#5224. Closing as invalid/wontfix. |
With #1337 merged and running a recent version of JRuby, I'm seeing rather strange behavior re. the process exit codes. All of the examples below are running on macOS.
I am using a trivial
config.ru
to illustrate the problem (curl http://localhost:9292
will trigger the termination):Ruby 2.5.1 (correct behavior)
On MRI (2.5.1), it works fine:
143 = 128 + 15, which is the correct value.
JRuby 9.1.16.0 (incorrect behavior)
However, unlike what @dekellum was experiencing in #1337, I am seeing incorrect behavior on JRuby:
Exit code 1 indicates "failure", and does not seem right in this case.
It's the same on Java 9:
Am I doing something wrong, and if so, what? 😄 Also, if you feel this is a JRuby/JVM issue let me know, but it's strange since it seemed like we had things working at around the time #1337 was merged...
The text was updated successfully, but these errors were encountered: