Skip to content

Do not return early from ThreadService#terminate#7633

Merged
headius merged 1 commit intojruby:jruby-9.3from
justinstoller:fix_return_in_terminate_thread_service
Feb 9, 2023
Merged

Do not return early from ThreadService#terminate#7633
headius merged 1 commit intojruby:jruby-9.3from
justinstoller:fix_return_in_terminate_thread_service

Conversation

@justinstoller
Copy link
Contributor

@justinstoller justinstoller commented Feb 8, 2023

Previously, if we encounter an adopted thread when terminating the ThreadService we return early and fail to finish killing threads we spawned.

This changes the return to continue which I believe was always the intent.

@justinstoller
Copy link
Contributor Author

Originally, I thought this was a continued problem with the Timeout module but I think it simply has the privileged distinction of being the only library thread we use that doesn't clean up after itself before termination.

@kares
Copy link
Member

kares commented Feb 8, 2023

Hey Justin, this small change indeed makes sense.
Did you consider targeting the jruby-9.3 branch, so it gets to next 9.3 (as well as 9.4) ?

Previously, if we encounter an adopted thread when terminating the
ThreadService we will return early and fail to finish killing threads
we spawned.

This changes the `return` to `continue` which I believe was always the
intent.
@justinstoller justinstoller force-pushed the fix_return_in_terminate_thread_service branch from 93809c6 to 5638b76 Compare February 8, 2023 16:12
@justinstoller justinstoller changed the base branch from master to jruby-9.3 February 8, 2023 16:12
@justinstoller
Copy link
Contributor Author

Sure thing @kares , I just wanted to get it up and see what folks thought before doing any more with it.

Retargeted, let me know if you'd like me to do anything else!

@justinstoller
Copy link
Contributor Author

Also, is there an ETA on a version of 9.4 with this fix?

Knowing a rough estimate would help judge if we should start internally testing with 9.4 now and be able to upgrade to a version with this fix before we release, or if we'd be stuck having to back it out.

@kares
Copy link
Member

kares commented Feb 9, 2023

Also, is there an ETA on a version of 9.4 with this fix?

Since, 9.4.1 was just released 9.4.2 (and 9.3.11) might be several weeks away.
There were more than 2 months between 9.4.0 and 9.4.1, but with holidays period, so <8 weeks might be a good guess.
Guess it depends on the severity of user reports coming in, which might move the release to a sooner date...

Would a (nightly) snapshot build, with this fix included, be usable for you?

@headius
Copy link
Member

headius commented Feb 9, 2023

It won't be 8 weeks, but it will be more than two. Depends on how critical and how many issues we get in the next week or two.

Looking at this now.

@headius
Copy link
Member

headius commented Feb 9, 2023

Yeah this is the right fix. Old code, but I'm surprised this hasn't been reported previously.

I will merge this into 9.3 and forward to master and it will be in snapshots soon and releases a little less soon.

@headius headius merged commit 345e892 into jruby:jruby-9.3 Feb 9, 2023
@justinstoller
Copy link
Contributor Author

justinstoller commented Feb 9, 2023

Thanks! No need on the nightly build.

FWIW, we certainly have a fairly unique use case with Puppet Server. We also are still carrying a work around for #6127, the removal of which caused us to find this.

@justinstoller justinstoller deleted the fix_return_in_terminate_thread_service branch February 9, 2023 18:10
justinstoller added a commit to justinstoller/puppetserver that referenced this pull request Feb 14, 2023
JRuby's terminate function will premeturely stop shutting down threads
if it comes across an adopted thread. This will cause threads not
properly shutdown by the time a JRuby instance terminates to be leaked.

This may happen with code in the wild. Within Puppet Server it only
happens with the Timeout module which is poorly behaved in this regard.
This update should allow us to begin testing JRuby 9.4.x and Ruby 3.x
compatability in Puppet Enterprise now, but we should not Puppet Server
with this change. We must either take up the fix to this thread leakage,
merged in jruby/jruby#7633 slated to be released
in JRuby 9.4.1.1 or 9.4.2.0 depending on the number and severity of
additional bugs reported, or revert this update.

Note: the JRuby team estimates 2 - 8 weeks between when the above PR was
merged and a new release containing it, which would be sometime between
late February to early April 2023.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants