-
Couldn't load subscription status.
- Fork 533
RUBY-3620 - Add Session.escape functionality #2917
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
Conversation
@jamis @comandeo-mongo I've raised 3 semi-related PRs:
- RUBY-3620 - Add Session.escape functionality #2917
- RUBY-3620 - Sessions should ignore "cluster mismatched" validation and execute commands on other clusters #2918
- RUBY-3622 - Use SessionEnded error consistently #2919 (cleanup)
As our app has grown in complexity, it is important to have greater ability to control query execution per session. Can you please review these changes and let me know if the approach is acceptable, or if you envision a different way of addressing the use cases?
Importantly, #2917 and #2918 may appear similar on the surface, but they actually address two different use cases. Our app would benefit from having them both.
Once you have reviewed, I or someone on my team will write the tests.
Uh oh!
There was an error while loading. Please reload this page.
As per RUBY-3620, when using a Session transaction, there is no easy way to "escape" out of that transaction on the thread** and execute a one-off query. This is useful when you have queries that you want to execute regardless of whether the transaction succeeds or fails.
This PR adds
Mongo::Session.escape { }to force executing queries outside the transaction.(**you can spawn a new thread as a hacky workaround, but this comes with a host of it's own problems, such as needing to transfer in thread-specific state such as I18n.locale or Time.zone)