do_query implements its own read timeout using rb_wait_for_single_fd,
but blocking operations, like mysql_ping, will still block until the
tcp connection expires if there is a problem (multiple minutes
ActiveRecord's connection pool makes liberal use of ping, so an
unresponsive mysql server can cause rails apps to hang even if
read_timeout has been configured.
We fix this by using the mysql library's own MYSQL_OPT_READ_TIMEOUT
option. It fixes mysql_ping and seems not to interfere with with
I don't think writing a test case for this is practical - it requires
dropping packets to/from the mysql server after establishing the
connection. I've tested it like this manually though and it makes all
your fast fail dreams come true.