Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-41483

MySql: my_thread_global_end(): XX threads didn't exit

    XMLWordPrintable

Details

    • Bug
    • Resolution: Cannot Reproduce
    • Not Evaluated
    • None
    • 4.8.6
    • SQL Support
    • None
    • Ubuntu

    Description

      In a multithreaded application when removing a MySql connection the error occurs:

      mushroom@ubuntu:~/projects/mysqltest/mysqlthread/debug$ ./mysqlthread
      Error in my_thread_global_end(): 51 threads didn't exit
      Error in my_thread_global_end(): 65 threads didn't exit

      Here is the code to demonstrate the issue:

      mysqlthread.cpp
      #include <QtCore>
      #include <QtSql>
      
      class Client: public QRunnable
      {
      public:
          virtual void run();
      };
      
      void Client::run()
      {
          {
              QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL", QString::number((unsigned long long)QThread::currentThreadId()));
      
              db.setHostName("localhost");
              db.setDatabaseName("test");
              db.setUserName("me");
              db.setPassword("mypass");
      
              db.open();
              
              db.close();
          }
      
          QSqlDatabase::removeDatabase(QString::number((unsigned long long)QThread::currentThreadId()));
      
      }
      
      int main(int argc, char *argv[])
      {
          QCoreApplication a(argc, argv);
      
          QThreadPool pool;
          pool.setMaxThreadCount(100);
      
          for (int i = 0; i < 100; ++i)
          {
              Client *client = new Client;
              bool started = pool.tryStart(client);
              Q_ASSERT(started);
          }
      
          pool.waitForDone();
      
          //return a.exec();
          return 0;
      }
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            mabrand Mark Brand
            mentalmushroom Pugach Yaroslav
            Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes