-
-
Notifications
You must be signed in to change notification settings - Fork 82
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
Add more docs re: Rails #220
Add more docs re: Rails #220
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also mention that per thread connections should not use transactions without also using with_connection or similar mechanism.
Gotcha. I updated with a bit more detail and added an example about the Please let me know if you'd like me to squash these into a single commit or make any other tweaks. I'm not sure I'm following your comment about transactions specifically, so please elaborate if you wanted more detail added about that. My understanding is that you're advised to wrap any AR calls in a |
This is looking better and better. However, I think we should be explicit with the downside using |
Hmm, I'm not clear on the issue w.r.t transactions being shared across requests (sounds bad!) so perhaps you want to add to this, or merge and adjust/expand as you'd like? |
Perhaps we can close socketry/falcon-rails-example#2 once we get this documented? Also, somewhat related to this and rails/rails#50917, see also socketry/falcon-rails-example#1 -- let me know if you'd like me to work on more documentation or a generator or something. I'd be happy to pitch in here if helpful! |
Just to report back after a Rails 7.0.8 -> 7.1.3 upgrade today, I had some unexpected errors in production when running in I checked with a Rails Slack group I'm in and heard that this has come up before, and that it seems to be related to multiple fibers sharing an Active Record connection. So, I implemented the So, I wonder if we should remove the |
That makes total sense to me - if you want to cut another PR to update the documentation that would be awesome! |
Updated here! #221 Please let me know how that looks and/or if you'd like any tweaks. Thanks again for your patience here, but I'm glad to share my experience in practice here and I hope it'll help others! |
Add a bit more documentation around the
isolation_level
change from #219, including an example to retain the default behavior in Rails.My concern is that with Rails <= 7.1.3 database connections are checked out until the response is sent back to the client. So, if you have a limited connection pool (as you might on Heroku etc) you might exhaust your limit unexpectedly if you have long-running fibers. In the future, Rails is likely to improve connection pool handling so this shouldn't be an issue in practice for long, but for now it seems prudent to document.
See #219 and #218 for more context, note links to other issues with other potential workarounds such as wrapping database queries in a
with_connection
block.Types of Changes
Contribution