Skip to content
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

'mysqlplus' blocks the entire Ruby process when connecting to DB #3

Open
ibc opened this issue Dec 28, 2009 · 3 comments
Open

'mysqlplus' blocks the entire Ruby process when connecting to DB #3

ibc opened this issue Dec 28, 2009 · 3 comments

Comments

@ibc
Copy link

ibc commented Dec 28, 2009

Hi, "mysqlplus" (and of course also "mysql") driver blocks totally the Ruby process when it's trying to connect to a MySQL server. In case the server doesn't respond then we get our Tuby application stopped forever.

Please check the following code which shows the issue:
http://gist.github.com/264866

Is it possible to make MySQL connection non-blocking?

Regards.

@ibc
Copy link
Author

ibc commented Dec 28, 2009

I've reported same bug for 'pg' driver and it's fixed now (it already implemented non-blocking connection):

http://bitbucket.org/ged/ruby-pg/issue/14/pgconnconnect-blocks-forever-if-the-db-host-is#comment-100487
http://bitbucket.org/ged/ruby-pg/changeset/f5af71167dea/

@skiz
Copy link

skiz commented Feb 17, 2010

To create a non-blocking connection you need to provide a timeout (works in all mysql libs) as by default there is no connect timeout defined.
con = Mysql.init
con.options(Mysql::OPT_CONNECT_TIMEOUT, 5) # 5 second timeout

@ibc
Copy link
Author

ibc commented Feb 18, 2010

Great, I didn't know such option. I will report to Sequel developer to include it.
Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants