Since putting our application into production, I’ve been seeing random
lost connections to our MySQL server, always when the application is
accessing the session store, and at no other time. Apparently
randomly, I get the error:
Mysql::Error: Lost connection to MySQL server during query: SELECT *
FROM sessions WHERE (session_id = ‘xxxxxxxx’) LIMIT 1
I’ve spent quite a bit of time googling around and searching
appropriate forums, without finding a definitive answer to tackling
I’ve found several posts that indicate moving to AR session store
starts this problem.
I’ve investigated the possibility of packet size causing problems, but
sessions are typically averaging around 300 bytes, and one error that
I was able to track down specifically only had a session store of 322
I’ve seen many suggestions to use the mysql gem driver to fix the
problem, however, we’re already using it, so that isn’t the problem.
Setting the Interactive timeout was another common suggestion, but the
AR verification timeout is set to 1/2 of the interactive timeout set
I’m tempted to just set the max_allowed_packet to maybe double the
size of the current 16MB and see what happens, but I don’t see how
that would help because the session stores seem so small, even with
overhead, I don’t see how a session store of 300-400 bytes could add
up to a packet that is over 16MB. Further, I’m unsure if all I have to
do is set max_allowed_packet in MySQL and be done, or if there is some
further configuration in Rails that has to be done . Some googling
suggest that it is automatically calculated from the server setting,
but I’m unsure of that.
I’m wondering whether I should just ditch AR session store and go with
It seems like a lot of people have run into this, but aside from the
standard answers that I’ve already checked, except for the packet
size, there doesn’t seem to be a lot of other answers out there.
Has anyone else run into this? Can anyone tell me anything else to
check? How about the mem-cache option, any thought there?
Thanks for any help in this regard