Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
MySQL reconnect option is not working with upgrade to mysql 8.0.26
We are using Qt 5.12.8 with MySQL database on CentOS 7.
So far we were using mysql 8.0.21 and in the code there is a call to set MYSQL_OPT_RECONNECT=1 before any connection is made which means if client detects connection drop it will attempt to reconnect.
There are multiple threads which have connection open with MySQL database.
It was working as expected until we upgraded to the latest mysql 8.0.26.
After the upgrade we are getting errors: "The client was disconnected by the server because of inactivity. See wait_timeout and interactive_timeout for configuring this behavior."
It is indeed related to the wait_timeout in MySQL as if the wait_timeout reduced the error can be seen after a shorter time.
We are also using QxOrm 1.4.7 but this layer hasn't changed and I believe it is transparently setting reconnect option as requested.
Has anyone else experienced a similar problem?
Any help will be much appreciated.
JonB last edited by
latest mysql 8.0.26.
MYSQL_OPT_RECONNECTis a MySQL option, nothing Qt about it. So is this just an issue in the new MySQL version?
IGIG last edited by IGIG
I am not sure.
Is MYSQL_OPT_RECONNECT=1 option just transferred from Qt sqldriver to MySQL client?
Or is it handled by Qt sqldriver?
It looks like there were some changes in MySQL 8.0.24 relevant to reconnection option: https://dev.mysql.com/doc/relnotes/connector-odbc/en/news-8-0-24.html
mchinand last edited by
Are you setting any of the connection options of your QSqlDatabase instance?
JonB last edited by JonB
I would imagine (absolutely no proof!) Qt knows nothing about it and it's purely handed off to "MySQL client library" as per https://dev.mysql.com/doc/c-api/8.0/en/c-api-auto-reconnect.html. That is why I suspected your MySQL side, not Qt, especially since the former only has changed.
...But now @mchinand has pointed out it's in the Qt documentation, so maybe I'm wrong :) [Nah, I still don't think Qt does anything with them, that's just a suggested list of strings... You're passing it that way already anyway, aren't you?]
See https://code.woboq.org/qt5/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp.html#1433 - nothing Qt can do against.
@mchinand Yes, we do setup MYSQL_OPT_RECONNECT=1 via QxOrm like this:
And this option worked so far well with MySQL 8.0.21 but after update to MySQL 8.0.26 it does not anymore.
@Christian-Ehrlicher Thank you. I've seen that and double checked that MYSQL_VERSION_ID is correct. It appears as 80026 on the latest MySQL 8.0.26.