Exceeds max allowed packet for MySQL

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.

Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Problem

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 atlassian-confluence.log:

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)

Cause

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:

http://dev.mysql.com/doc/refman/5.6/en/packet-too-large.html

Resolution

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.

Note:

If you are unable to stop your database, you can alternatively set the value of the max allowed packet parameter dynamically. To do so:

  1. Log in as a root user.
  2. You'll need to set the value as an integer, rather than '256M'. 256M is equivalent to 256*1024*1024, or 268435456.
  3. mysql> SET GLOBAL max_allowed_packet=268435456;
  4. To check that this has been applied:
    1. Relogin to your mysql client.
    2. mysql> SELECT @@max_allowed_packet;
  5. 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.

Last modified on Feb 26, 2016

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.