summaryrefslogtreecommitdiffstats
path: root/source/l/akonadi/akonadi-mariadb-10.2.patch
blob: 99b096fb3d08d25a2c82fb0a68e5f9c5dd0748d7 (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
commit 22c53fa2aa97c7f0b5d7a1947821c5b3aef9de0f
Author: Heinz Wiesinger <pprkut@liwjatan.at>
Date:   Sun Sep 17 15:55:48 2017 +0200

    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
    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

diff --git a/server/src/akonadi.cpp b/server/src/akonadi.cpp
index 5369320c8..6d31f6ff4 100644
--- a/server/src/akonadi.cpp
+++ b/server/src/akonadi.cpp
@@ -370,12 +370,13 @@ void AkonadiServer::createDatabase()
             db.close();
         }
     }
-    QSqlDatabase::removeDatabase( initCon );
 }
 
 void AkonadiServer::stopDatabaseProcess()
 {
     if ( !DbConfig::configuredDatabase()->useInternalServer() ) {
+        // closing initConnection this late to work around QTBUG-63108
+        QSqlDatabase::removeDatabase(QLatin1String("initConnection"));
         return;
     }
 
diff --git a/server/src/storage/dbconfigmysql.cpp b/server/src/storage/dbconfigmysql.cpp
index 10f99db70..36f1f3a42 100644
--- a/server/src/storage/dbconfigmysql.cpp
+++ b/server/src/storage/dbconfigmysql.cpp
@@ -395,8 +395,6 @@ void DbConfigMysql::startInternalServer()
       db.close();
     }
   }
-
-  QSqlDatabase::removeDatabase( initCon );
 }
 
 void DbConfigMysql::stopInternalServer()
@@ -405,6 +403,9 @@ void DbConfigMysql::stopInternalServer()
     return;
   }
 
+  // closing initConnection this late to work around QTBUG-63108
+  QSqlDatabase::removeDatabase(QLatin1String("initConnection"));
+
   // first, try the nicest approach
   if ( !mCleanServerShutdownCommand.isEmpty() ) {
     QProcess::execute( mCleanServerShutdownCommand );