[MDEV-19174] server_audit plugin locks mutex for every event when server_audit_logging=OFF Created: 2019-04-04  Updated: 2020-08-25  Resolved: 2019-06-15

Status: Closed
Project: MariaDB Server
Component/s: Locking, Plugin - Audit
Affects Version/s: 10.4.3, 10.1.38, 10.2.23, 10.3.14
Fix Version/s: 10.2.26, 10.1.41, 10.3.17

Type: Bug Priority: Major
Reporter: Geoff Montee (Inactive) Assignee: Alexey Botchkov
Resolution: Fixed Votes: 1
Labels: None

Issue Links:
PartOf
is part of MDEV-18661 loading the audit plugin causes perfo... Closed
Problem/Incident
is caused by MDEV-19291 server_audit plugin mutex causes stal... Closed
Relates
relates to MDEV-20236 Add audit plugin API functions to dis... Closed

 Description   

The server_audit plugin uses the lock_operations mutex to perform various operations in a mutually exclusive manner:

https://github.com/MariaDB/server/blob/mariadb-10.3.7/plugin/server_audit/server_audit.c#L544

As far as I can tell, this mutex is locked for every audit event, even when server_audit_logging=OFF is set. We can see that the mutex is locked here:

https://github.com/MariaDB/server/blob/mariadb-10.3.7/plugin/server_audit/server_audit.c#L1989

And the code doesn't check whether logging is enabled until a few lines later:

https://github.com/MariaDB/server/blob/mariadb-10.3.7/plugin/server_audit/server_audit.c#L2021

Is it absolutely necessary to do it this way? It seems as though users would pay a performance penalty to have the audit plugin installed if they have a lot of concurrent connections, even if server_audit_logging=OFF is set.

It looks like the only way to prevent the mutex from being locked for every audit event is to uninstall the plugin with UNINSTALL PLUGIN / UNINSTALL SONAME:

https://mariadb.com/kb/en/library/uninstall-plugin/

https://mariadb.com/kb/en/library/uninstall-soname/



 Comments   
Comment by Alexey Botchkov [ 2019-04-08 ]

This is a bigger issue.
I've already refactored the Audit Plugin to lock the mutex less, and also refactored the server to reduce locks there. Now wait for the customer to see the performance changes.

Generated at Thu Feb 08 08:49:36 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.