In atk4/data php data framework we run unit tests with limited number of max. connections - https://github.com/atk4/data/blob/2c501c78f7e839ab2d55176d59ab258000ee1a76/.github/workflows/test-unit.yml#L156
When we limited it strictly to 1, we have observed random CI failures with MySQL and MariaDB databases.
Initially I thought this is issue in PHP mysqlnd and I opened https://github.com/php/php-src/issues/9151 where I described the issue exhaustively. Please see the php-src ticket for code to reproduce. I was able to reproduce it also using in lua.
Currently, it seems the MariaDB release the client connection too early and does not synchronously wait until the connection is fully released from the database and decremented from the active connections counters.
This behaviour can be seen with MySQL and MariaDB only. I tested also Microsoft SQL Server and PostgreSQL and these databases release the connection socket synchronously with the counters.