Answer the question
In order to leave comments, you need to log in
ruby-mysql2: MySQL server has gone away
There is a daemon written in ruby using the mysql2 gem, which sometimes receives a message from AMQP and writes to the database.
When idle for a long time, MySQL closes the connection by timeout and when you try to execute the query, the exception 'MySQL server has gone away' is thrown. Google issues a solution for ActiveRecord, nothing about mysql2. I did not find anything suitable in the methods of the Mysql2::Client class, the :reconnect => true option does not help.
How to check the connection before executing the request and if it is closed, then raise it again?
Answer the question
In order to leave comments, you need to log in
I don't know shit, but in mysql connectors you can usually check with the Ping function.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question