Drupal on AWS with RDS - PDOException
I am running a Drupal 7 site on AWS with an EC2 micro instance and RDS on Ubuntu 12.04. When I navigated to the URL patterns for Pathauto
admin/config/search/path/patterns I was getting a nasty white screen with an error along the lines of
PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away. As it turns out, this is not the fault of Pathauto. The solution to this problem was to increase the
max_allowed_packet value in the mysql server configuration. The rest of this post explains how I did it.
- First, I needed to add another DB parameter group in my RDS setup. I accomplished that by clicking the button that says "Create DB Parameter Group." When the group is created it pulls in all the information from the default group.
- After creating a custom parameter group, I needed to edit the parameters in that custom group. According to the MySQL documentation the default value is 1M. So, I increased the size to 50M. The parameter requires a value in bytes, though. To calculate the number of bytes I used the formula 50 * 1024 * 1024. This is because 1M = 1024 KB and 1KB = 1024 bytes. [Note that I needed to page forward to get to the desired parameter.]
- Once the custom parameter group contained the new value I needed to modify the DB instance to use the new parameter group.
- The last thing I needed to do was to reboot the DB instance.
I don't know if I really needed to set the max allowed packet size to 50M; something smaller may have worked. In fact, I think that I did get it to work when I set the value to 10240000 bytes, which is about 9.8M. I had decided to see if 50M worked after having read a suggestion in the Pathauto issue queue.
The default value of the MySQL client max allowed packet is 16M. In Ubuntu 12.04 that configuration file is located at
/etc/mysql/my.cnf. I supposed it would be fine if I set the server to also use 16M. But, at this point if it ain't broke . . .