amphp / mysql

An async MySQL client for PHP, optimizing database interactions with efficient non-blocking capabilities. Perfect for responsive, high-performance applications.
Other
358 stars 63 forks source link

Randomly "Connection closed unexpectedly" Exception #102

Closed xpader closed 3 years ago

xpader commented 3 years ago

The mysql client randomly throw " Amp\Sql\ConnectionException: Connection closed unexpectedly",my MySQL Server is very stable when using mysqlnd or connect with Java, The exception throw from couple minutes or about half hours.

MySQL timeout settings:

Variable_name Value
connect_timeout 10
delayed_insert_timeout 300
innodb_lock_wait_timeout 60
innodb_rollback_on_timeout OFF
interactive_timeout 60
lock_wait_timeout 31536000
net_read_timeout 30
net_write_timeout 60
slave_net_timeout 3600
wait_timeout 60

amphp/mysql pool max idle time I have tried: 10, 30, 60, 120, all have this problem..

radixo commented 3 years ago

Same problem here... =[

kelunik commented 3 years ago

Could you please write a simple script reproducing the issue?

xpader commented 3 years ago

It's just normal use, and the issue only happens probabilistically. I used in my framework: https://github.com/xpader/workerman-amphp-framework/blob/master/src/framework/Db/Connection.php like fetchOne() and fetchAll() And any query may have this problem..

xpader commented 3 years ago

There's an interest thing today. One of our MySQL server is slow respond and almost gone, the simple primary key query running about 300 seconds and more, and there's lots of table lock on very simple query.. The MySQL server has running about ten years, and we restart it.. After that, "Connection closed unexpectedly" is never show so far..

So, I think the problem is not amphp/mysql, it's out server's problem..