pest
pest copied to clipboard
[Bug]: Running tests in parallel causes SQLSTATE[HY000] [2006] MySQL server has gone away
What Happened
When I run tests in parallel by using vendor/bin/pest --parallel
, it fails most about 75% of the tests with SQLSTATE[HY000] [2006] MySQL server has gone away
.
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
FAILED Tests\Feature\REDACTED > REDACTED QueryException
SQLSTATE[HY000] [2006] MySQL server has gone away (Connection: mysql, SQL: drop database if exists `REDACTED`)
at vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:65
61▕ * @return \PDO
62▕ */
63▕ protected function createPdoConnection($dsn, $username, $password, $options)
64▕ {
➜ 65▕ return new PDO($dsn, $username, $password, $options);
66▕ }
67▕
68▕ /**
69▕ * Handle an exception that occurred during connect execution.
How to Reproduce
In a repository with multiple tests that access the database, run vendor/bin/pest --parallel
.
Sample Repository
No response
Pest Version
2.34.7
PHP Version
8.3.7 and 8.2.19 through Valet
Operation System
macOS
Notes
Running the tests consecutively has never given me any issues.
I am using mysqld
5.7.44 through Homebrew
I have tried configuring /opt/homebrew/etc/my.cnf
by adding the following:
[mysqld]
max_allowed_packet=100M
connect_timeout=600
These are commonly suggested configurations when encountering this specific error.
I have also tried both using a socket connection and connecting to 127.0.0.1
and localhost
.
The reason I'm posting this as an issue in this repo is that I think Pest should manage the connection correctly.