Problem storing large amounts of data in a MySQL database
MySQL isn’t a database server that we use an awful lot at Arctus, but because it is so hugely popular it must be our number 1 priority when it comes to supporting it for our Rails applications.
We were concerned when two of our current applications, a web mail client and a document management system, sometimes failed to save data to the database for no apparent reason. We suspected that it was caused by too much data (because shorter messages/documents worked), but the error message we were getting gave absolutely no clues – “MySQL server has gone away” is all it offered.
We first suspected that our TEXT field wasn’t able to hold the amount of data we were passing in, but LONGTEXT didn’t work either. We quickly tracked the problem down to a run-time setting called max_allowed_packet. This is an absolute limit on any individual command’s length, and we had exceeded the build in default.
We located my.ini, added max_allowed_packed=16M and restarted the server. Now everything is working fine.
We know that this is quite a trivial problem to overcome, but we are documenting it here because the current top few Google hits aren’t as useful as they might be for that particular error.
See http://dev.mysql.com/doc/refman/5.0/en/packet-too-large.html for more details.
