SQLSTATE[HY000]: General error: 11 database disk image is malformed
matthew-gill opened this issue · 2 comments
Q | A |
---|---|
ParaTest version | 7 |
PHPUnit version | 10.4.1 |
PHP version | 8.2 |
Summary
I'm using paratest for Symfony integration tests.
However, I seem to consistently getting the message SQLSTATE[HY000]: General error: 11 database disk image is malformed
for some of my tests.
I've checked that the database is being set up correctly, and the tests pass locally using phpunit.
I'm struggling on how to debug this behaviour. I've been playing whack-a-mole to get paratest working and these are the last 6 tests until we're fully parallel!
I'm not necessarily asking for specific help on my test code, but any experience anybody has had with this error before, how did you debug it etc?
Current behavior
Some tests exit with SQLSTATE[HY000]: General error: 11 database disk image is malformed
How to reproduce: command, code and error stack trace
Expected behavior
The tests pass!
The issue is that you're using your database in parallel from multiple tests, and somehow it's getting mangled. Are you using SQLite by any chance?
In any case, you need something to parallelize the database use too. You either create N parallel databases using the test token, or you can leverage some additional library like the DoctrineTestBundle (if you use Doctrine), which wraps every test in a transaction that gets rollbacked at the end, regardless of the test outcome.
PS: @Slamdunk would you be ok with moving these kind of questions to Discussions?