MySQL Forums
Forum List  »  Ruby

Connection errors with repeated use of popen()
Posted by: Grant Birchmeier
Date: October 07, 2009 02:13PM

I've got the weirdest issue, and it's driving me up the wall. Would be grateful if anyone had any ideas.

We have some test automation scripts in Ruby that use popen() to setup some sample database contents between tests. After rebooting the test machine, it works fine for a few rounds, then it starts doing things like this:

ERROR 1146 (42S02) at line 1: Table 'ccx.foo1' doesn't exist
ERROR 1146 (42S02) at line 1: Table 'ccx.foo2' doesn't exist
ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)
ERROR 1146 (42S02) at line 1: Table 'ccx.foo4' doesn't exist
ERROR 1146 (42S02) at line 1: Table 'ccx.foo5' doesn't exist

Now, please note, the "doesn't exist" lines are EXPECTED BEHAVIOR, as the script is dropping a table that doesn't exist. There are other SQL commands happening in there also; the error lines are just the only ones that print.

The PROBLEM is the "Can't connect error". You can see that the DB is running; the other four lines clearly demonstrate that. The call to popen() succeeds in sending drop commands to foos 1,2,4, and 5, but for some reason the drop on foo3 didn't connect. And it's on localhost, so it can't be a connection problem.

And it's never consistent! Sometimes it'll never happen, but when it does happen, it's never the same tables or lines. This time it could be on foo3, next time it could be on foo4 and foo5. It's unpredictable.

I've seen this on the latest MySQL 5.1, and on two versions of 5.0. Ruby version is 1.8.6.

Our script is calling popen() like this:
IO.popen("mysql -u username", "w+") do |dbconn|
charset = "charset utf8"
dbconn.puts charset
dbconn.puts <sql_code>
end

I'm nearly out of ideas. Any suggestions appreciated.

-Grant

Options: ReplyQuote


Subject
Written By
Posted
Connection errors with repeated use of popen()
October 07, 2009 02:13PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.