Bug #76509 use atomics to avoid MUTEX CONTENTION ON LOCK_PLUGIN DUE TO QUERY REWRITE FRAMEW
Submitted: 27 Mar 2015 14:45 Modified: 30 Mar 2015 13:18
Reporter: Tor Didriksen Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Parser Severity:S3 (Non-critical)
Version:5.7 OS:Any
Assigned to: CPU Architecture:Any

[27 Mar 2015 14:45] Tor Didriksen
Description:
The query rewrite framework needs to examine the list of installed plugins
three times during parsing:

- To know if a plugin needs a statement digest.
- To call pre-parse rewrite plugins.
- To call post-parse rewrite plugins.

All of these calls are needed even if there is no such plugin installed.
Performance degradation happens because each thread needs to take a global
mutex on the plugin list.

How to repeat:
Run sysbench with many threads, and --db-ps-mode=disable option

Suggested fix:
Use atomic counters when loading/unloading pre/post parse plugins.
Check counters in mysql_parse.

See also Bug#20784914
[30 Mar 2015 13:18] Paul Dubois
Noted in 5.7.7, 5.8.0 changelogs.

The query rewrite framework introduced in MySQL 5.7.6 produced
excesssive mutex acquisition that caused performance degradation under
some conditions.