Laravel with MariaDB and GitLab CI/CD: Illuminate\Database\QueryException: SQLSTATE[HY000] [2006] MySQL server has gone away

When running many tests involving the database one might encounter the following issue: Illuminate\Database\QueryException: SQLSTATE[HY000] [2006] MySQL server has gone away The issue occurred reliably and always at the same test. Temporarily deleting test classes just made another test triggering the issue. When debugging locally it turns out that the maximum connection limit of MariaDB is the root cause. By default MariaDB comes with a connection limit of 100 connections. Laravel however does not use persistent connections by default and therefore consumes a lot of connections when running tests....

January 9, 2022