[CONC-277] "Plugin pvio_socket could not be loaded: not initialized" error when starting akonadi Created: 2017-08-31 Updated: 2018-05-29 |
|
| Status: | Open |
| Project: | MariaDB Connector/C |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Heinz Wiesinger | Assignee: | Georg Richter |
| Resolution: | Unresolved | Votes: | 2 |
| Labels: | None | ||
| Environment: |
mariadb 10.2.8 |
||
| Description |
|
When starting akonadi against a mariadb 10.2 database, the startup fails.
The odd thing here is that this does not happen on the first connection. Checking debugging output from akonadi one can clearly see that:
Also notable is that if one prevents akonadi from closing the initial connection (by commenting the appropriate line in the code), future "worker" connection attempts succeed. This behavior is the same with the Qt4 and Qt5 versions of akonadi. Considering this I'm rather tempted to see a bug in the connector rather than akonadi or Qt, especially since none of this happens with libmysqlclient. |
| Comments |
| Comment by Georg Richter [ 2017-09-03 ] | ||
|
Hi Heinz, thank you for your bug report! "not initialized" in subsequent connection means, that the plugin system was not initialized via mysql_server_init before. Hard to analyze without code, but this can happen under the following conditions: a) Threaded application. Main thread is opening first connection, closes it and calls mysql_server_end (which deinitializes the plugin system). Other threads are not able anymore to load a plugin, since the plugin system was deinitialized. b) The MySQL structure wasn't allocated or initialized by mysql_init() call c) (very unlikely) the global variable which indicates if the plugin system was initialized was overwritten. If you can tell me where I can find the relevant code (or even better would be remote access for debugging) I will do some more investigations. | ||
| Comment by Heinz Wiesinger [ 2017-09-03 ] | ||
|
Hi Georg, Thank you for the pointers! Akonadi is essentially a desktop application, shouldn't be too hard for you to get a local version to test against. All you need is a KDE environment. The problem is caused by akonadi calling QSqlDatabase::removeDatabase, or at least not calling it works around it. This delete s the driver instance. My C++ is unfortunately rather basic, so I'm not entirely sure what this calls, but if this triggers the destructor of QMYSQLDriver, and the connection count drops to 0, it would call qLibraryEnd. MYSQL_VERSION_ID for MariaDB 10.2.8 should be 100208 if I understood correctly. That should make it call mysql_library_end(), rather than mysql_server_end(). | ||
| Comment by Georg Richter [ 2017-09-03 ] | ||
|
Hi, that makes no difference, since mysql_library_end is just a define:
However calling any api function after mysql_library_end/mysql_server_end may end up in an error or an unexpected result, since all subsystems are deinitialized and freed (prepared statement subsystem, client plugin handler, sigpipe handler, tls/ssl driver, etc.). The problem is that every close of a connection calls mysql_library_end instead of doing that if the application terminates. This works in libmysql, since rather calls to mysql_init will initialize the subsystems again (which is a waste of resources) - unfortunately not in MariaDB Connector/C, which uses pthread_once for library initialization, so further calls to mysql_init or mysql_server_start have no effect. | ||
| Comment by Paul McCullagh [ 2017-11-21 ] | ||
|
Hi Georg, In older versions of the library calling mysql_library_init() after calling mysql_library_end() would re-initialise the library. This behaviour is very useful because it enables you to create a dynamically "unload/reloadable" library or extension that includes the MariaDB library. If I create an extension that includes the MariaDB library, and the extension is unloaded and reloaded, then I have no idea what will happen if I cannot cleanup the MariaDB library resources, and then re-initialise them when the extension is loaded again. It also enables you to create a library that does not necessarily get a shutdown call when the application shuts down. Sometimes you have to write to an extension API which does not provide such a call. Of course, the easy way to get around this is to just not call mysql_library_end() at all. But why proved the mysql_library_end() function if there is no need to call it? Anyway, bottom line is, I believe it should be possible to shutdown, and startup the MariaDB library multiple times, as it was in earlier versions. |