Rebase of PR 807: non-blocking behavior for next_result - #962
Open
sodabrew wants to merge 5 commits into
Open
Conversation
when actually preforming a multi-statement select with any non-trivial components, the `next_result` call will block the ruby interpreter. We fix this in two ways: First, we wrap up the actual mysql_next_result call in a "no-gvl" call so that the interpreter can do other work while next_result is happening. Second, we borrow a method from do_query and spin in a select() loop on the mysql socket until the query is ready. A quick source dive into the underlying mysql source shows that next_result() falls into the same path as mysql_real_query (cli_read_query_result), so this should be a safe method.
Rather than including violite.h to be able to look into the net.vio structure to call its has_data function pointer, we borrow the definitions of just two functions that understand this structure. The underlying client library may have pre-read the results from the next query, so wait_for_fd would not be triggered. Instead we will ask whether the net.vio structure has additional data that hasn't been parsed. Hack: use knowledge of whether the connecti is SSL or not to call the appropriate has_data function and pass net.vio as an opaque structure. Definitions are from vio_priv.h
Collaborator
Author
|
There are actually more possible states than my implementation accounts for. I'm not sure if there's a clean way to do this without the underlying methods exposed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rebase of #807
/cc @osheroff