Lost connection to database
Posted: 17.08.2023, 19:53
Hi, I have had some problems related to losing connection with the database, I ended up doing a simple test with the MySQL crash and I noticed that when there is a loss of connection Zeos version 8.0 it automatically tries to reconnect to the database, as soon as the service stabilizes, I noticed that zeos opens several connections in sequence with the database, I managed to analyze about 2 thousand connections in 1 second when reconnecting to the database.
Checking the code in the ZDbcMySql unit, in the TZMySQLConnection class in the HandleErrorOrWarning procedure, I found the following code:
if AExceptionClass = EZSQLConnectionLost then
if Sender <> nil
then Sender.ReleaseImmediat(Sender, EZSQLConnectionLost(Error))
else ReleaseImmediat(Sender, EZSQLConnectionLost(Error))
every time there is a connection loss it goes into recursion in this piece of code thus generating N connections with the database, as I work with Web Servers, and a client with a bad connection ends up losing the connection when reconnecting it ends up generating many new connections and all with different ports for the same IP (the ports are usually sequential), and with that my MySQL ended up completely crashing and consequently crashing my entire WEB server.
Is there anything I can do to fix this? Is there any setting I can tweak so this doesn't happen?
Checking the code in the ZDbcMySql unit, in the TZMySQLConnection class in the HandleErrorOrWarning procedure, I found the following code:
if AExceptionClass = EZSQLConnectionLost then
if Sender <> nil
then Sender.ReleaseImmediat(Sender, EZSQLConnectionLost(Error))
else ReleaseImmediat(Sender, EZSQLConnectionLost(Error))
every time there is a connection loss it goes into recursion in this piece of code thus generating N connections with the database, as I work with Web Servers, and a client with a bad connection ends up losing the connection when reconnecting it ends up generating many new connections and all with different ports for the same IP (the ports are usually sequential), and with that my MySQL ended up completely crashing and consequently crashing my entire WEB server.
Is there anything I can do to fix this? Is there any setting I can tweak so this doesn't happen?