Yii2 MySQL server is gone
I am developing a Yii2 application. There is a console script that takes quite a long time to execute and it fails with the error: the MySQL server is gone .
According to the logs, it throws an exception after 6-7 seconds with no connection to the database (it does some work and has to update the table if necessary).
I added PDO timeout to db config:
'attributes' => [
PDO::ATTR_TIMEOUT => 600,
],
Also I checked the MySQL timeout variables, but they seem to be good:
mysql> show variables like '%timeout%';
+----------------------------+--------+
| Variable_name | Value |
+----------------------------+--------+
| connect_timeout | 10 |
| delayed_insert_timeout | 300 |
| innodb_lock_wait_timeout | 50 |
| innodb_rollback_on_timeout | OFF |
| interactive_timeout | 259200 |
| net_read_timeout | 30 |
| net_write_timeout | 60 |
| slave_net_timeout | 3600 |
| table_lock_wait_timeout | 50 |
| wait_timeout | 259200 |
+----------------------------+--------+
10 rows in set (0.00 sec)
I tried to connect to the controller like this:
Yii::$app->db->close(); Yii::$app->db->open();
But it did not help. Do you have any ideas what I am doing wrong?
thank
+3
source to share