FINAL UPDATE: We solved this problem by finding a way to achieve our goals without branching. But the cause of the problem was branching.
--- Original Post ---
I use ruby ββin the rails stack, our mysql server is separate but hosted on the same site as our application servers. (We tried replacing it with another double-spec MySQL server, but there was no improvement.
during business hours we receive several such requests without any specific request.
ActiveRecord::StatementInvalid: Mysql2::Error: Lost connection to MySQL server during query
most failed requests are really simple, and there seems to be no pattern between one request and another. It all started when I upgraded Rails 4.1 to 4.2.
I am at a loss as to what to try. Our database server takes up less than 5% of CPU time during the day. I get error reports from users who have random interaction because of this, so these are not requests that have been running for several hours or something like that, of course, when they repeat the same work, it works .
Our servers are configured on cloud66.
So, in short: our MySQL server is leaving for some reason, but not due to lack of resources, it is also a completely new server when we migrated from another server, when this problem occurred.
this also happens to me on a local host when developing features, so I don't believe this is a boot problem.
We run the following:
- ruby 2.2.5
- rails 4.2.6
- mysql2 0.4.8
UPDATE: according to the first answer below, I increased our max_connections variable to 500 last night, and confirmed the increase with show global variables like 'max_connections';
My connection is still reset, the first one was reset just a few minutes ago today .... ActiveRecord::StatementInvalid: Mysql2::Error: Lost connection to MySQL server during query
I ran the command select * from information_schema.processlist; and I got 36 lines back. Does this mean that there were 36 connections on my application servers at that moment? or can a process be multiple connections?
UPDATE: I just set net_read_timeout = 60 (that was 30 before), I will see if this helps
UPDATE: This did not help, I'm still looking for a solution ...
Here is my Database.yml with remote credentials.
production: adapter: mysql2 encoding: utf8 host: localhost database: username: password: port: 3306 reconnect: true