When starting Akonadi 5.6.0 / 17.08.0 on a system with MariaDB 10.2.8, I see the following in ~/.local/share/akonadi/akonadiserver.error.old: ``` Database error: Cannot open database. Last driver error: "QMYSQL: Unable to connect" Last database error: "Plugin pvio_socket could not be loaded: not initialized" QSqlQuery::exec: database not open Database error: Cannot open database. Last driver error: "QMYSQL: Unable to connect" Last database error: "Plugin pvio_socket could not be loaded: not initialized" QSqlQuery::exec: database not open Unable to open database "Plugin pvio_socket could not be loaded: not initialized QMYSQL: Unable to connect" ``` (Newlines inserted by me.) This issue was also reported with Akonadi 17.04.3 and MariaDB 10.2.7 [1,2]. We are using QtSQL 5.7.1. Upgrading the database does not fix this error. It persists after the following commands: ``` /usr/sbin/mysqld --defaults-file=$HOME/.local/share/akonadi/mysql.conf --datadir=$HOME/.local/share/akonadi/db_data/ --socket=/tmp/akonadi-mysql.socket mysql_upgrade --socket=/tmp/akonadi-mysql.socket kill $MYSQL_PID ``` Downgrading MariaDB to 10.1.25 prevents this error from happening [3]. The issue seems to be related calls to QSqlDatabase::removeDatabase() and QSqlDatabase::addDatabase() in akonadi-17.04.3/src/server/storage/dbconfigmysql.cpp:492 [4]. For more information, please also see the full report in the Gentoo bug tracker [5]. [1]: https://bugs.gentoo.org/show_bug.cgi?id=626464#c0 [2]: https://bugs.gentoo.org/show_bug.cgi?id=626464#c3 [3]: https://bugs.gentoo.org/show_bug.cgi?id=626464#c21 [4]: https://bugs.gentoo.org/show_bug.cgi?id=626464#c29 [5]: https://bugs.gentoo.org/show_bug.cgi?id=626464
For reference: MariaDB bug report: https://jira.mariadb.org/browse/CONC-277 Qt bug report: https://bugreports.qt.io/browse/QTBUG-63108
According to the MariaDB bugreport [1] this is a bug in QtSQL [2]. [1]: https://jira.mariadb.org/browse/CONC-277 [2]: https://bugreports.qt.io/browse/QTBUG-63108
P.S. Thanks, Heinz, for digging further into this!
Git commit b145f47f000978b9d39edc1882849ec7f6b3ef79 by Heinz Wiesinger. Committed on 17/09/2017 at 15:21. Pushed by wiesinger into branch 'Applications/17.08'. 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 Reviewers: dvratil, mlaurent Reviewed By: dvratil Subscribers: #kde_pim Tags: #kde_pim Differential Revision: https://phabricator.kde.org/D7858 M +2 -1 src/server/akonadi.cpp M +3 -1 src/server/storage/dbconfigmysql.cpp https://commits.kde.org/akonadi/b145f47f000978b9d39edc1882849ec7f6b3ef79
How about fixing the issue in Qt instead, where it actually lies?
Ah, looks like Daniel Vrátil already did that: https://codereview.qt-project.org/#/c/205874/