Noticed there is auto retry on database queries when connection lost, but not in beginTransaction(). Any reason for this discrepancy?
I am getting PDO::beginTransaction(): MySQL server has gone away error frequently in my application, so I wish it has the auto retry too.
Please advice if it is possible. Thanks.
This should already be happening in L5.1.
Can the fixes apply to L4.2 too? I am using L4.2. Thanks.
@sookteng No, 4.2 is not supported anymore.
Noted. Thanks to all the prompt replies.
I have tried in L5.1 with few lines of code below:
DB::connection('db');
sleep(20); //MySQL idle timeout after 10s
DB::connection('db')->beginTransaction();
It still throw the same error like L4.2:
ERROR: exception 'ErrorException' with message 'PDO::beginTransaction(): MySQL server has gone away' in ...\vendor\laravel\framework\src\Illuminate\Database\Connection.php:491
Please advice. Thanks.
Most helpful comment
I have tried in L5.1 with few lines of code below:
It still throw the same error like L4.2:
ERROR: exception 'ErrorException' with message 'PDO::beginTransaction(): MySQL server has gone away' in ...\vendor\laravel\framework\src\Illuminate\Database\Connection.php:491Please advice. Thanks.