Mysql2::Error: This connection is still waiting for a result, try again once you have the result

Rails-talk,

Last night I got a slew (around 2000) of these exceptions raised in my
production app between 4:03 AM and 7:30 AM (eastern time).

They all had the same pattern:

ActiveRecord::StatementInvalid: Mysql2::Error: This connection is still
waiting for a result, try again once you have the result: SELECT
spree_buckets.* FROM spree_buckets WHERE spree_buckets.slug =
‘gallery’ LIMIT 1
(The SQL query was different for many, but the Mysql2::Error: This
connection is still waiting for a result, try again once you have the
result part was the same)

I called Amazon RDS support and they said the underlying database looked
fine, we are well below our IOPS threshold, and our queue depth looks
healthy.

I think perhaps just 1 Unicorn worker choked up with a single MySQL
call, resulting in all subsequent calls from that Unicorn worker to
produce this error (for 3 hours!)

Does anyone else have any best practice advice for this error? Should I
simply catch for this exception and close & reconnect any active MySQL
connections ? Can someone share some examples of how to do that as
cleanly as possible?

Thanks,
Jason


Jason Fleetwood-Boldt
[email protected]

We encountered this exactly same problem this night. We’ve also called
AWS
and they gave us the same answer: everything looks fine on your
instance.

We have several applications using this same database, they all worked
fined except one. So It really looks like a problem in either mysql2 or
unicorn.

Did you manage to find an explanation? And maybe a solution? For the
moment
we have just restarted the application and everything is back to normal.

Thanks,
Kevin

Le jeudi 20 novembre 2014 15:56:59 UTC, Jason Fleetwood-Boldt a écrit :