Only remove init connections to the database on server shutdown.
ClosedPublic

Authored by pprkut on Sep 17 2017, 9:19 AM.

Details

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

Diff Detail

Repository
R165 Akonadi
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
pprkut created this revision.Sep 17 2017, 9:19 AM
Restricted Application added a project: KDE PIM. · View Herald TranscriptSep 17 2017, 9:19 AM
Restricted Application added a subscriber: KDE PIM. · View Herald Transcript
dvratil requested changes to this revision.Sep 17 2017, 10:28 AM

Thanks a lot, patch looks good, just some minor coding adjustments needed.

You can change "CCBUG" to "BUG" in the commit message so that the bug gets auto-closed once this is committed since the patch actually fixes the issue.

src/server/akonadi.cpp
433

QSqlDatabase::removeDatabase(QStringLiteral("initConnection'));

src/server/storage/dbconfigmysql.cpp
523

QSqlDatabase::removeDatabase(QStringLiteral("initConnection"));

Also please add a comment that we are closing initConnection this late to workaround a QTBUG-63108.

This revision now requires changes to proceed.Sep 17 2017, 10:28 AM
pprkut updated this revision to Diff 19606.Sep 17 2017, 10:53 AM

Coding adjustments and added comments.

dvratil accepted this revision.Sep 17 2017, 11:03 AM
This revision is now accepted and ready to land.Sep 17 2017, 11:03 AM
This revision was automatically updated to reflect the committed changes.