If you’re a fond MySQL and/or MariaDB user you most certainly experienced at least one of these common errors:
MySQL server has gone away
Error reading result set’s header
Error executing query
MySQL server has gone away for query
2006, MySQL server has gone away
Packets out of order. Expected X received Y. Packet size=Z
… and so on. You can find these warnings basically anywhere, as they are usually written in the log files of the applications, tools and services that try to connect to your database and fail: however, in most scenarios, they are firstly noticed by the zealous System Administrator inspecting the PHP error log file (or the Joomla or WordPress counterpart) while trying to understand why his beloved web site or service isn’t working like it should.
That said, let’s try to understand the underlying cause and see what we can do to overcome them.