Solve `MySQL server has gone away` issue

When validating or uploading a large data set, you may encounter the following error:

This means that you need to modify the database timeout configuration so that the maximum allowed packet is increased, but this is done at the DBMS level.

:woman_mechanic: Resolving this issue requires an IT adminsitrator. It is due to the current server configuration.

You can resolve this by increasing the max_allowed_packet for the server by modifying the my.cnf file and/or increasing it globally:

  • In mariadb, the following command sets the max_allowed_packet limit to 1024M globally temporarily (no restart required)–

    SET GLOBAL max_allowed_packet=1024M;
    
  • For a permanent solution, modify your my.cnf file where you can set it below the [mysql] or [mariadb] heading:

    [mysql]
    max_allowed_packet = 1024M
    

You should now be able to validate/upload your large data sets in the WorkBench without any problems!

Let us know if you need any help with this process!


If these solutions do not solve your issue, we reccomend looking at Stack Overflow or other sites which may have useful instructions to resolve this problem.

1 Like

Hello, How can I apply a permanent fix for this issue in my dockerized MariaDB?

In my docker-compose file do I just replace… –max_allowed_packet=1073741824 with –max_allowed_packet=1024M

Thus, this…

  mariadb:
    restart: unless-stopped
    image: mariadb:10.11
    command: --max_allowed_packet=1073741824
    volumes:
      - "database:/var/lib/mysql"
      - "./seed-database:/docker-entrypoint-initdb.d"
    environment:
      - MYSQL_ROOT_PASSWORD=root
      - MYSQL_DATABASE=specify
      - MYSQL_USER=master
      - MYSQL_PASSWORD=master

is replaced by…

  mariadb:
    restart: unless-stopped
    image: mariadb:10.11
    command: --max_allowed_packet=1024M
    volumes:
      - "database:/var/lib/mysql"
      - "./seed-database:/docker-entrypoint-initdb.d"
    environment:
      - MYSQL_ROOT_PASSWORD=root
      - MYSQL_DATABASE=specify
      - MYSQL_USER=master
      - MYSQL_PASSWORD=master

If so, if I just stop and delete my DB container… but keep the DB container volume, I imagine my packet modifications will be applied and I will not loose my data once I redeploy my DB container?

Thanks

For security reasons I have to use Podman instead of Docker to deploy SP-7. I’ve had issues with using docker-compose files with Podman… so I’m manually starting each container.

I was able to successfully configure the DB –max_allowed_packet parameter at the command line. Here is an example:

podman run --detach --pod sp7_pod --name sp7_mariadb -v /apps/data/lfc/containers/volumes/specify-db:/var/lib/mysql:Z -v /apps/applications/podman/lfc/sp7dev/seed-database:/docker-entrypoint-initdb.d:Z --env-file='/apps/applications/podman/lfc/sp7dev/mysql.env' mariadb:10.11 --max-allowed-packet=1024M

1 Like

I imagine my packet modifications will be applied and I will not loose my data once I redeploy my DB container?

Correct. No data loss will happen.

You could make mysql.conf file (which contains changes described here) and mount it at /etc/conf.d/mysql.conf in podman/docker volume