I'm developing a Symfony 3.1 application which basically puts jobs messages in RabbitMQ queue and with supervisors, I spawn some processes that consume RabbitMQ messages and do the job which is managed in Symfony. The consumer's job is to decode the message and create a new Symfony\Bundle\FrameworkBundle\Console\Application injecting the same kernel and executing a Symfony command which has database operations both read/write.
Here begins the problem. Usually, at the same time, I usually leave spawned 4 worker processes to consume the messages. At the same time, all the consumers do the same database operations just with different data so basically all the processes execute the same Symfony RabbitMQ consumer. Sometimes it works all fine no problem whatsoever, but sometimes MySQL returns the error "MySQL server has gone away", and usually to fix this I have to restart supervisor service so the worker processes are killed and spawned again. Usually after restarting it works fine for a few hours but its really unpredictable pattern.
It's not a MySQL connection timeout since I'm sure they are small operations and I've increased the connect_timeout of MySQL. I've also increased the wait_timeout to 2 days so basically, this doesn't solve the problem.