Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit b145f47f authored by Heinz Wiesinger's avatar Heinz Wiesinger

Only remove init connections to the database on server shutdown.

Summary:
With MariaDB 10.2 libmysqlclient was replaced with libmariadb that
changed how establishing database connections behaves. The MySQL
QSQL driver calls mysql_server_end() on QSqlDatabase::removeDatabase()
if the overall connection count dropped to 0 (which it does when
the init connection is removed).
A future QSqlDatabase:addDatabase() would call mysql_server_init()
again, but this no longer works with libmariadb as that one only
allows calling mysql_server_init() once. Future calls are simply
ignored.

In order to prevent this from happening we have to keep the
init connection open until the server shuts down, so the connection
count only drops to 0 at shutdown and mysql_server_end() isn't
called before.

This is a workaround for QTBUG-63108

CCBUG: 383991

Reviewers: dvratil, mlaurent

Reviewed By: dvratil

Subscribers: #kde_pim

Tags: #kde_pim

Differential Revision: https://phabricator.kde.org/D7858
parent 97a191a5
......@@ -423,13 +423,14 @@ bool AkonadiServer::createDatabase()
success = false;
}
}
QSqlDatabase::removeDatabase(initCon);
return success;
}
void AkonadiServer::stopDatabaseProcess()
{
if (!DbConfig::configuredDatabase()->useInternalServer()) {
// closing initConnection this late to work around QTBUG-63108
QSqlDatabase::removeDatabase(QStringLiteral("initConnection"));
return;
}
......
......@@ -492,7 +492,6 @@ bool DbConfigMysql::startInternalServer()
}
}
QSqlDatabase::removeDatabase(initCon);
return success;
}
......@@ -520,6 +519,9 @@ void DbConfigMysql::stopInternalServer()
return;
}
// closing initConnection this late to work around QTBUG-63108
QSqlDatabase::removeDatabase(QStringLiteral("initConnection"));
disconnect(mDatabaseProcess, static_cast<void(QProcess::*)(int,QProcess::ExitStatus)>(&QProcess::finished),
this, &DbConfigMysql::processFinished);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment