Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. MySQL reconnect option is not working with upgrade to mysql 8.0.26
Forum Update on Monday, May 27th 2025

MySQL reconnect option is not working with upgrade to mysql 8.0.26

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 4 Posters 1.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    IGIG
    wrote on last edited by
    #1

    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.

    JonBJ 1 Reply Last reply
    0
    • I IGIG

      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.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @IGIG said in MySQL reconnect option is not working with upgrade to mysql 8.0.26:

      latest mysql 8.0.26.

      MYSQL_OPT_RECONNECT is a MySQL option, nothing Qt about it. So is this just an issue in the new MySQL version?

      1 Reply Last reply
      0
      • I Offline
        I Offline
        IGIG
        wrote on last edited by IGIG
        #3

        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

        JonBJ 1 Reply Last reply
        0
        • M Offline
          M Offline
          mchinand
          wrote on last edited by
          #4

          Are you setting any of the connection options of your QSqlDatabase instance?

          I 1 Reply Last reply
          1
          • I 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

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by JonB
            #5

            @IGIG
            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?]

            1 Reply Last reply
            1
            • Christian EhrlicherC Offline
              Christian EhrlicherC Offline
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on last edited by
              #6

              See https://code.woboq.org/qt5/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp.html#1433 - nothing Qt can do against.

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              I 1 Reply Last reply
              1
              • M mchinand

                Are you setting any of the connection options of your QSqlDatabase instance?

                I Offline
                I Offline
                IGIG
                wrote on last edited by
                #7

                @mchinand Yes, we do setup MYSQL_OPT_RECONNECT=1 via QxOrm like this:
                qx::QxSqlDatabase::getSingleton()->setConnectOptions("MYSQL_OPT_RECONNECT=1")
                And this option worked so far well with MySQL 8.0.21 but after update to MySQL 8.0.26 it does not anymore.

                1 Reply Last reply
                0
                • Christian EhrlicherC Christian Ehrlicher

                  See https://code.woboq.org/qt5/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp.html#1433 - nothing Qt can do against.

                  I Offline
                  I Offline
                  IGIG
                  wrote on last edited by
                  #8

                  @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.

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved