Exceeds max allowed packet for MySQL
This Knowledge Base article was written specifically for the Atlassian Server platform. Due to the Restricted functions in Atlassian Cloud apps, the contents of this article cannot be applied to Atlassian Cloud applications.
One or more of the following is observed:
- Cannot install or upgrade a plugin
- Cannot upgrade the Universal Plugin Manager
- Cannot save large pages
- Cannot upload attachments (when attachments are stored in the database)
The following errors may appear in the
ERROR [pool-6-thread-3] [sf.hibernate.util.JDBCExceptionReporter] logExceptions Packet for query is too large (1889999 > 1048576). You can change this value on the server by setting the max_allowed_packet' variable.
Cause: java.lang.RuntimeException: There was a problem evicting or flushing a PluginData object at com.atlassian.confluence.plugin.persistence.hibernate.HibernatePluginDataDao.saveOrUpdate(HibernatePluginDataDao.java:65) caused by: net.sf.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update at net.sf.hibernate.exception.ErrorCodeConverter.handledNonSpecificException(ErrorCodeConverter.java:90) caused by: java.sql.BatchUpdateException: Packet for query is too large (1238730 > 1048576). You can change this value on the server by setting the max_allowed_packet' variable. at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:1213)
The MySQL packet size setting by default is not big enough to allow most add-on's to install in the Confluence database. Plugin data, attachments, and large page bodies can often exceed the default limit of 1 Mb. For more information see here:
Set the MySQL packet size to a larger value (256MB) and restart MySQL Server. 256MB should be large enough to cover most cases.
shell> mysqld --max_allowed_packet=256M
Alternatively, you can do this on your MySQL server's settings by editing MySQL's
my.cnf file (often named
my.ini on Windows operating systems). Locate the
[mysqld]section in the file, and add/modify the following parameters:
[mysqld] ... max_allowed_packet = 256M ...
(i) Remember to restart MySQL services in order for the changes above to take effect. For more information, please refer to MySQL manual: http://dev.mysql.com/doc/refman/5.0/en/packet-too-large.html.
If you are unable to stop your database, you can alternatively set the value of the max allowed packet parameter dynamically. To do so:
- Log in as a root user.
- You'll need to set the value as an integer, rather than '256M'. 256M is equivalent to 256*1024*1024, or 268435456.
mysql> SET GLOBAL max_allowed_packet=268435456;
To check that this has been applied:
Relogin to your mysql client.
mysql> SELECT @@max_allowed_packet;
- Restart your Confluence instance.
You will still need to update your /etc/my.cnf file as described in the method above to make the change persistent.