Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

If you try to insert big data chunks to the MySQL server, you might run into the following issue:

Code Block
(500, '(pymysql.err.OperationalError) (2006, "MySQL server has gone away (BrokenPipeError(32, \'Broken pipe\'))")\n(Background on this error at: http://sqlalche.me/e/e3q8)')

It may be caused by too small value in the max_allowed_packet option in the MySQL server.

Info

The issue can be faced especially with the old version of MariaDB server. The default value for the max_allowed_packet option differs depending on the MariaDB version:

  • 16777216 (16M) >= MariaDB 10.2.4

  • 4194304 (4M) >= MariaDB 10.1.7

  • 1048576 (1M) < MariaDB 10.1.7

Check the current max_allowed_packet value

To check the current value for the max_allowed_packet use the following command:

Code Block
echo "SHOW VARIABLES LIKE 'max_allowed_packet'" | mysql

The returned value specifies what is the maximum size of package that MySQL server can receive.

Code Block
Variable_name	Value
max_allowed_packet	1048576

If the size of data sending to MySQL server is bigger than the max_allowed_packet the server throws error and close the connection.

Increase the new max_allowed_packet value

To increase the value, add the following lines to the MySQL server configuration file (the configuration file by default is located in the /etc/my.cnf path).

Code Block
[mysqld]
max_allowed_packet=16M

Then restart MySQL server.

...

This page can now be found at Inserting Big Data into the MySQL Server on the Squirro Docs site.