-
-
Notifications
You must be signed in to change notification settings - Fork 925
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
thread.object_id with fibers (due AR's connection pooling) #1717
Comments
Honestly, the MRI behavior just looks completely broken to me. Thread.current supposedly returns the same object, but Thread.current[:something] is per-Fiber. But I know this has been argued to death and it isn't going to change. I have been reluctant to make thread-local data pretend to be like MRI. It ends up getting very messy internally since we still need to model fibers as threads. We also use Thread.current to get the thread object associated with the running fiber...not the parent thread, but the actual Ruby thread that the fiber creates. If we were to start mucking around with Thread.current, that logic would have to know about it. I made a previous attempt and ended up breaking fibers badly. So I'm not sure what to do here. We could ship a JRuby with thread_variable_get exposed in all modes; it would be exposing a 2.x feature in pre-2.x mode, but I'm guessing the Rails logic would just start working. That seems better to me than trying to fake out Thread.current, which has a lot of nasty implications. |
@headius implementing |
This bug is still causing some headaches. See issue 2 in |
Same issue as #1806. Root issue is that Thread.current in a Fiber is not really the parent thread but the Fiber's thread. Many synchronization mechanisms depend on these being the same, so simply changing it is not easy. |
MRI (in 2.x) does return the same
object_id
forThread.current
inside aFiber
... this is not how JRuby behaves (even on master). it's quite important esp. due the fact that Rails usesThread.current.object_id
as it's key to store/resolve DB connections thread-locally using a pool ... they seem to not be doing anything about it - thus decided to re-report the issue here rails/rails#7746Rails might switch to using
thread_variable_xxx
but this is also not currently available on JRuby (2.x mode) - which might be another approach to handle this right for structures such as thread mapped connection pools. MRI 2.1 samples :The text was updated successfully, but these errors were encountered: