Skip to content
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

fix(fork-tracker): Only patch fork if it's supported #37385

Merged
merged 1 commit into from
Oct 6, 2019

Conversation

dr-itz
Copy link
Contributor

@dr-itz dr-itz commented Oct 6, 2019

Summary

Some tests are currently wrapped with if Process.respond_to?(:fork)
but they're still executed on JRuby. The problem is that ForkTracker
unconditionally patches #fork so Process does indeed
respond_to? :fork.

Fix it by installing the patch conditionally with the same check.

Some tests are currently wrapped with
  `if Process.respond_to?(:fork)`
but they're still executed on JRuby. The problem is that ForkTracker
unconditionally patches `#fork` so `Process` does indeed
`respond_to? :fork`.

Fix it by installing the patch conditionally with the same check.
::Kernel.prepend(CoreExtPrivate)
::Kernel.singleton_class.prepend(CoreExt)
::Process.singleton_class.prepend(CoreExt)
if Process.respond_to?(:fork)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the take away here is that if the process doesn't respond to fork then there's no need for the checker? Then how do we ensure we claim/reap the connections? cc @casperisfine

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup. When there's no fork available, there's no need to check and no need to claim/reap connections. E.g. on JRuby fork will always throw a "not implemented", so we're never in a situation that requires cleaning up connections

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, TIL!

@kaspth kaspth merged commit 5f43f57 into rails:master Oct 6, 2019
@kaspth
Copy link
Contributor

kaspth commented Oct 6, 2019

Thanks!

@dr-itz
Copy link
Contributor Author

dr-itz commented Oct 6, 2019

Thanks for the quick merge!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants