Bug 383991

Summary: Akonadi 17.08.0 / 5.6.0 with MariaDB 10.2.8 - Plugin pvio_socket could not be loaded: not initialized
Product: [Frameworks and Libraries] Akonadi Reporter: Dennis Schridde <dschridde+kde>
Component: serverAssignee: kdepim bugs <kdepim-bugs>
Severity: normal CC: dennis.lissov, heiko.becker, hiwatari.seiji, iivanich, kevin.kofler, nucleo, pprkut, rdieter
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
See Also: https://jira.mariadb.org/browse/CONC-277
Latest Commit: Version Fixed In:

Description Dennis Schridde 2017-08-25 07:07:37 UTC
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

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
Comment 1 Heinz Wiesinger 2017-09-09 10:17:40 UTC
For reference:

MariaDB bug report: https://jira.mariadb.org/browse/CONC-277
Qt bug report: https://bugreports.qt.io/browse/QTBUG-63108
Comment 2 Dennis Schridde 2017-09-09 20:42:18 UTC
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
Comment 3 Dennis Schridde 2017-09-09 20:43:41 UTC
P.S. Thanks, Heinz, for digging further into this!
Comment 4 Heinz Wiesinger 2017-09-17 15:23:15 UTC
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.

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

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

Comment 5 Kevin Kofler 2017-09-25 10:50:12 UTC
How about fixing the issue in Qt instead, where it actually lies?
Comment 6 Kevin Kofler 2017-09-25 10:51:36 UTC
Ah, looks like Daniel Vrátil already did that: