I have a lot of transactions in my code, and if an error occurs in executing in one of these transactions that doesn't trigger commit or rollback, then the database is locked and any subsequent attempts to access the database results in this:
production.ERROR: PDOException: SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transaction in /home/forge/default/vendor/laravel/framework/src/Illuminate/Database/Connection.php:390
In the Controller:
DB::beginTransaction();
try {
//Code that uses exec() to process some images. <-- If code breaks here, then the above error appears on subsequent requests.
//Code that accesses the database
}
catch(\Exception $e){
DB::rollback();
throw $e;
}
DB::commit();
So even php artisan migrate:refresh or php artisan migrate:reset stops working as well. How should I go about fixing this?
tearDown()
method where I wasn't callingparent::tearDown()
. Basically, if you don't callparent::tearDown()
then the transaction was still open and a rollback/disconnect never occurred. – Scare