[Interest] Long running application with database connection

Richard Moore rich at kde.org
Wed Oct 9 13:55:23 CEST 2013


On 9 October 2013 11:27, Marc Schmitzer <marc.schmitzer at richard-wolf.com> wrote:
> While this works well most of the time, we occasionally have queries
> fail with "MySQL server has gone away" errors. We know that the mysqld
> process has indeed *not* gone away, and re-opening the connection works.
>
> My theory is that the initial QSqlDatabase::open() creates a connection
> to the SQL server that is kept open permanently by the QSqlDatabase
> instance that Qt keeps internally (in the ConnectionDict) that
> references the same connection. The SQL server eventually closes the
> connection after some timeout, which the application doesn't notice
> until it tries to use the connection again.

I've seen the same behavior from the python mysql drivers, so I think
this is probably the correct explanation. I don't know if the mysql
library offers a way to detect when you get disconnected that could be
used to make the implementation reconnect automatically.

Cheers

Rich.



More information about the Interest mailing list