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

RUBY-3620 - Add Session.escape functionality #2917

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

johnnyshields
Copy link
Contributor

@johnnyshields johnnyshields commented Feb 10, 2025

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)

@johnnyshields johnnyshields changed the title Add session escape functionality RUBY-3620 - Add session escape functionality Feb 11, 2025
@johnnyshields johnnyshields changed the title RUBY-3620 - Add session escape functionality RUBY-3620 - Add Session.escape functionality Feb 11, 2025
@johnnyshields
Copy link
Contributor Author

johnnyshields commented Feb 11, 2025

@jamis @comandeo-mongo I've raised 3 semi-related PRs:

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.

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.

1 participant