Skip to content

Commands out of sync #728

@markkuit

Description

@markkuit

I'm having issues with mysql2 gem when issuing queries in a rapid succession. Basically, I'm initializing Mysql2::Client and issuing a bunch (up to hundreds) of SELECT and INSERT low-complexity .query()s one after the other on a prepare-execute basis, always saving the .execute result in a var even though not always reading its value.

Every once in a while, the execution stops and I get a 'commands out of sync' error..

/var/lib/gems/1.9.1/gems/mysql2-0.4.2/lib/mysql2/statement.rb:14:in _execute': Commands out of sync; you can't run this command now (Mysql2::Error) from /var/lib/gems/1.9.1/gems/mysql2-0.4.2/lib/mysql2/statement.rb:14:inexecute'

..almost as if the previous query hasn't been executed yet or w/e. I'm not using MULTI_STATEMENTS nor have set any options in particular. Simply starting the script again may result in it going all the way through without any issue or randomly stop once again at one of the queries. I tried waiting for !.more_results? but that didn't achieve anything. Using short sleep()s in between the queries seems to help, making me think once again it's a matter of queries still waiting to be executed, yet I couldn't find anything that could let me choose to wait for the query to be executed before proceeding.

mysql2 (0.4.2)
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]

Any help is greatly appreciated.

EDIT: Little note, using mysql gem (the outdated one) goes flawless, although outdated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions