[MDEV-19918] Server hangs or crashes while trying to lock mutex when the mutex was already locked upon startup with server_audit and orphan records in mysql.plugin Created: 2019-07-01 Updated: 2021-09-30 Resolved: 2020-07-26 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Plugin - Audit, Plugins |
| Affects Version/s: | 10.4.7, 10.4.8, 10.4.11, 10.4 |
| Fix Version/s: | 10.4.14, 10.5.5 |
| Type: | Bug | Priority: | Critical |
| Reporter: | Elena Stepanova | Assignee: | Alexey Botchkov |
| Resolution: | Fixed | Votes: | 3 |
| Labels: | None | ||
| Issue Links: |
|
||||||||||||||||||||||||||||||||
| Description |
|
When the server is started with --plugin-load-add=server_audit and it has records in mysql.plugin referring non-existent libraries, it hangs on a release build or crashes on a debug build.
The test case below is artificial, but there is a quite real-life scenario which represents the problem.
Run the test case below with --plugin-load-add=server_audit
Couldn't reproduce on 10.2-10.3. |
| Comments |
| Comment by Valerii Kravchuk [ 2019-08-10 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
There is another, more "natural" way to reproduce similar hang. 1. INSTALL audit plugin "manually":
2. Restart server adding plugin_,load-add to my.cnf or command line:
So, it hangs. 3. Attach gdb and see this:
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2019-09-25 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
No, https://github.com/mariadb/server/commit/4c63b87036da79e7f416a94f4dc2240fd5139ee4 is a quite a dirty hack, please don't push that. In fact, there is already one fix for crashes like that, in sql_plugin.cc:
(which is a hack too, as the comment admits). But it only works if there's a current THD. So one possible fix for this MDEV would be to create a dummy THD for the initial loading of plugins. In fact, there is such a dummy THD, created in plugin_load(). Just making use of it to preacquire audit plugins should fix this crash. But a much better and only slightly more complex (if at all) solution would be to get rid of LOCK_plugin completely and to switch to RCU approach for plugin data structures. It means something like
this should fix all current and future concurrency problems with LOCK_plugin, and will allow to remove this hack, quoted above, and another one, in plugin_foreach_with_mask(), simplifying all plugin handling code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Roel Van de Paar [ 2020-03-06 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Is | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Nick (Inactive) [ 2020-03-26 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
From my understanding, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Volker Klasen [ 2020-03-31 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I've got the same issue, but not with audit plugin. I installed auth_pam first using "INSTALL SONAME 'auth_pam';" and then by adding "plugin_load_add = auth_pam" to my.cnf and restarting the server. Strace shows the following:
If I start the server without plugin_load_add, then I can execute "UNINSTALL SONAME 'auth_pam';" and restart the server with plugin_load_add again. Cheers, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Dan Livingston [ 2020-04-06 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I am seeing this behavior on 10.4.12-6 as well. In my case I see it on first startup (before adding any other plugins) when I fail to not comment out the plugin% parameters in mariadb-enterprise.cnf. I see the same sort of output as above:
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Nilnandan Joshi [ 2020-07-21 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Agree with last comment, its happening with 10.4.12-6. In my case, it was with unix_socket plugin. In MariaDB 10.4.3 and later, the unix_socket authentication plugin is installed by default. But if you are upgrading server from 10.3, the entry for that plugin will be in mysql.plugin table.
If we'll try to start 10.4 with audit_plugin and above entry , it will be getting hanged at
But if we remove that unix_socket entry from mysql.plugin and then restart the server, its working. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Alexey Botchkov [ 2020-07-26 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
https://github.com/MariaDB/server/commit/4968fdbcef1c2d62ed525dffac153cf9f8eb1913 |