summaryrefslogtreecommitdiffstats
path: root/kde/patch/akonadi/akonadi_mariadb_qtsql.patch
blob: 7ec6d7ccf394628868500ff21afaa1af33219610 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
Patch taken from https://cgit.kde.org/akonadi.git/patch/?id=b145f47f000978b9d39edc1882849ec7f6b3ef79

Upstream bug reports:
https://bugs.kde.org/show_bug.cgi?id=383991
https://bugreports.qt.io/browse/QTBUG-63108

From b145f47f000978b9d39edc1882849ec7f6b3ef79 Mon Sep 17 00:00:00 2001
From: Heinz Wiesinger <pprkut@liwjatan.at>
Date: Sun, 17 Sep 2017 10:56:44 +0200
Subject: 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
---
 src/server/akonadi.cpp               | 3 ++-
 src/server/storage/dbconfigmysql.cpp | 4 +++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/server/akonadi.cpp b/src/server/akonadi.cpp
index 4364e63..bcb7e88 100644
--- a/src/server/akonadi.cpp
+++ b/src/server/akonadi.cpp
@@ -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;
     }
 
diff --git a/src/server/storage/dbconfigmysql.cpp b/src/server/storage/dbconfigmysql.cpp
index 2bd231d..d565706 100644
--- a/src/server/storage/dbconfigmysql.cpp
+++ b/src/server/storage/dbconfigmysql.cpp
@@ -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);
 
-- 
cgit v0.11.2