-
Notifications
You must be signed in to change notification settings - Fork 21.8k
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
Always discard mysql multi-statement results #52402
Conversation
So that makes sense however:
This makes me think we should instead pass some sort of parameter to |
Ah, yeah, it looks I "handled" this for mysql2 by just wrapping everything and grabbing the connection ahead of schedule: rails/activerecord/lib/active_record/connection_adapters/mysql2/database_statements.rb Lines 10 to 17 in a17aa63
... which may or may not have its own async worries, and surely has other disadvantages like missing the
Hmmm... is there actually any time we wouldn't want to drain |
Indeed ec7f5a1 (although GitHub-specific at least at the time) |
I can't find any, so let's try that as that solves both this and the two existing issues Jean points out. |
Previously we were trying to clear the extra results in a with_raw_connection block, which caused some issues. We never want to connect or reconnect here, we just need to drop any results from a multi-statement query and that only makes sense to do on the same connection we'd already used for the query. Previously when a query was run which hit the query cache on a fresh, non-sticky connection, the connection would perform its `verfiy!` before calling next_result, resulting in a network round trip.
Same as Trilogy, using abandon_results! needs to be done on the same original connection, and the best way to do that is inside raw_execute.
0364a7b
to
4ff28e8
Compare
Use raw connection for Trilogy more_results
Backported to 7-2-stable as 229308d |
We never want to connect or reconnect here, we just need to drop any results from a multi-statement query and that only makes sense to do on the same connection we'd already used for the query.
Previously when a query was run which hit the query cache on a fresh, non-sticky connection, the connection would perform its
verfiy!
before calling next_result, resulting in a network round trip.https://gist.github.com/jhawthorn/a7210ff40d947b5f6c776045a2a8c59c
cc @byroot @matthewd