-
Notifications
You must be signed in to change notification settings - Fork 1.4k
MONGOID-5882 Isolation state #6009
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
base: master
Are you sure you want to change the base?
Conversation
Does |
It shouldn't. That's what most of the tests in this PR are designed to ensure: that nested fibers inherit state from their parent fiber. The entire point of this PR is to make sure Mongoid can be compatible with fiber-based libraries like Falcon. |
Cool. 2 more:
|
Awesome, thanks @jamis! Only one comment from me, does it make sense to default the value of P.S. Falcon also assumes this is the standard entry point to make such decisions: https://github.com/socketry/falcon/blob/main/lib/falcon/railtie.rb |
@travisbell -- great suggestion. I'll look into it. It's a bit complicated by the fact that we still support Rails 6.x, and the |
It's worth considering. Again, "aside from not being on the latest Ruby" is the sticking point. As long as we support Ruby prior to 3.2, we really can't make |
Some applications will use threads for concurrency. Others will use fibers. Prior to this PR, Mongoid worked fine with threads, but it's internal state could get into odd states when run under fibers.
This PR allows applications to indicate which isolation level they wish to use, and Mongoid's state will be isolated to that scope.
When using the
:fiber
isolation level, Mongoid's internal state will be inherited from any parent fiber. If you want to make sure a fiber begins with a clean slate, you can wipe the isolation state withMongoid::Threaded.reset!
.