Love Fuel?
Donate
About
Forums
Discussions
Login
FuelPHP Forums
Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
General
Shutdown event issue
Syntaxlb
November 2017
Hi,
Since some days, i see often mysql error like that :
21/11/2017 14:51stderr2017-11-21T13:51:10.077302Z 58182 [Note] Aborted connection 58182 to db: 'xsc_prod' user: 'xsc_prod' host: 'XXXX' (Got timeout reading communication packets)
21/11/2017 14:52stderr2017-11-21T13:52:38.305168Z 58591 [Note] Aborted connection 58591 to db: 'xsc_prod' user: 'xsc_prod' host: 'XXXX' (Got timeout reading communication packets)
And i need to reboot the mysql server.
After several searches, it would be because the application does not close the mysql connections.
So I decided to put a log in the "connect" and "disconnect" method of the "Database_PDO_Connection" class.
After tests, I see the log of the "connect()" method, but no trace of the disconnect() method.
So I tried to put this line in bootstrap.php:
\Event::register('shutdown', 'Database_Connection::disconnect');
But still no sign of disconnect().
Do you have any advice?
Syntaxlb
November 2017
Finally, my fix :
$mysqlDisconnectEvent = function() {
if (isset(\Database_Connection::$instances['default']))
{
\Database_Connection::$instances['default']->disconnect();
}
\Profiler::console('SHUTDOWN EVENT');
};
\Event::register('shutdown', $mysqlDisconnectEvent);
It's good ?
Harro
November 2017
Should work.
But I doubt if it makes any difference, PHP closes all connections automatically on shutdown, The PDO object has a destructor that closes the connection if not already closed.
There are a lot of possible causes for this warning. I find that
https://www.percona.com/blog/2016/05/16/mysql-got-an-error-reading-communication-packet-errors/
gives a pretty accurate list.
Add a Comment
Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In
Apply for Membership
Categories
All Discussions
5,089
General
↳ General
3,364
↳ Job Board
13
↳ Installation & Setup
214
Packages
↳ Oil
213
↳ Orm
700
↳ Auth
261
Development
↳ Tips and Tutorials
126
↳ Code share
145
↳ Applications
52
In this Discussion
Harro
November 2017
Syntaxlb
November 2017