Bug #74977 Cryptic error when failing to unload a dynamic library
Submitted: 24 Nov 2014 10:56 Modified: 21 Mar 2016 16:23
Reporter: Martin Hansson Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: C API (client library) Severity:S3 (Non-critical)
Version: OS:Any
Assigned to: CPU Architecture:Any

[24 Nov 2014 10:56] Martin Hansson
Description:
If the server fails to unload a plugin's dynamic library you get a very cryptic error if you try to install the plugin again.

ERROR 1126 (HY000) at line 30: Can't open shared library '...' (errno: 0 service <first service the plugin is using> interface version mismatch)

How to repeat:
- Create a plugin with a UDF in the same dynamic library that is also using a plugin service. The Rewriter plugin is a good example.
- Install the plugin.
- Define the UDF.
- Uninstall the plugin.
- Install the plugin again.

The reference to the UDF symbols will cause the OS not to unload the library.

Suggested fix:
It should either be possible to install a plugin even though the dynamic library is already loaded, or there should be an error in this case. The error should be raised when either:

- The user tries to uninstall the plugin and this does not result in the library being unloaded by the OS.
- When reinstalling the plugin.

The reason a plugin can't be reloaded is because the library's memory is overwritten by the plugin loading code. The version number is overwritten by a function pointer to the plugin's entry point. The next time someone tries to install the plugin, this function pointer is interpreted as the version number, which is usually too high.
[21 Mar 2016 16:23] Paul Dubois
Posted by developer:
 
Noted in 5.6.31, 5.7.13, 5.8.0 changelogs.

Failure of UNINSTALL PLUGIN could lead to inaccurate or confusing
errors for subsequent INSTALL PLUGIN operations.
[31 Mar 2016 5:16] Erlend Dahl
Bug#80544 QUERY REWRITE: UNINSTALL + INSTALL FAILS WITH \'INTERFACE VERSION MISMATCH\'

was marked as a duplicate.