If you try to insert big data chunks to the MySQL server, you might run into the following issue:
(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.
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.44194304
(4M) >= MariaDB 10.1.71048576
(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:
echo "SHOW VARIABLES LIKE 'max_allowed_packet'" | mysql
The returned value specifies what is the maximum size of package that MySQL server can receive.
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).
[mysqld] max_allowed_packet=16M
Then restart MySQL server.
systemctl restart mysql