Bug #83865 multiple plugin_dir options
Submitted: 17 Nov 2016 11:53 Modified: 8 Feb 2017 17:10
Reporter: Vlad Lesin Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Tests Severity:S3 (Non-critical)
Version:5.6, 5.7, 5.7.16 OS:Any
Assigned to: CPU Architecture:Any

[17 Nov 2016 11:53] Vlad Lesin
Description:
mysqld does not support multiple plugin directories. When multiple --plugin-dir options are used only the last one has effect.
This does not allow to launch mtr tests which use plugins from different directories from build directory.

How to repeat:
For 5.7:

In source tree:

1) Create empty test file mysql-test/t/mpd.test

2) Create options file for the above test file mysql-test/t/mpd.opt with the following content:
$EXAMPLE_PLUGIN_OPT $EXAMPLE_PLUGIN_LOAD_ADD $PLUGIN_AUTH_OPT $PLUGIN_AUTH_LOAD_ADD

This options file tries to load two plugins described in mysql-test/include/plugin.defs:
auth_test_plugin   plugin/auth        PLUGIN_AUTH      test_plugin_server,cleartext_plugin_server
ha_example         storage/example    EXAMPLE_PLUGIN         EXAMPLE

As we can see auth_test_plugin is located in plugin/auth directory while ha_example plugin is in storage/example directory both in source tree and in build tree.

3) Let our source tree is in "mysql-source" directory and our build tree is in "mysql-build" directory. Then:

cd mysql-build
cmake ../mysql-source
make -j`grep -c "processor" /proc/cpuinfo`

4) Try to start our empty test:

cd mysql-test
./mtr mpd

the test will fail with the following error in server's error log:
[ERROR] Can't open shared library 'mysql-build/plugin/auth/ha_example.so' (errno: 2 mysql-build/plugin/auth/ha_example.so: cannot open shared object file: No such file or direct)

If we look in the options file from step 2 we will see the last two options are $PLUGIN_AUTH_OPT and $PLUGIN_AUTH_LOAD_ADD.
$PLUGIN_AUTH_OPT contains --plugin-dir option for "auth_test_plugin"(see comments at the beginning of mysql-test/include/plugin.defs and "--echo $PLUGIN_AUT_OPT" output in any mtr test)
This $PLUGIN_AUTH_OPT overrides $EXAMPLE_PLUGIN_OPT(see step 2) as there are two --plugin-dir options, the first one is for "example" plugin, the second one is for "auth_test_plugin", and the last --plugin-dir overrides the previous ones, and this is the reason why server looks for ha_example.so in "mysql-build/plugin/auth" directory instead of
"mysql-build/storage/example".

So if we want to create mtr test which would use plugins from several plugin directories in source tree and launch such test in build directory we will fail.
The workaround is to launch such tests from install directory after 'make install" because all plugins are installed in the same directory.
[18 Nov 2016 5:45] MySQL Verification Team
Hello Vlad,

Thank you for the report.
Observed this with 5.7.16 source build.

Thanks,
Umesh
[8 Feb 2017 17:10] Paul DuBois
Posted by developer:
 
Fixed in 8.0.1.

Work was done for test suite. No changelog entry needed.
[9 Feb 2017 8:02] Erlend Dahl
Note: MTR was unable to run tests which required plugins from different build directories. 

The original bug report asked for multiple --plugin-dir options for the server.

Instead we set target PROPERTIES LIBRARY_OUTPUT_DIRECTORY to the same directory for all plugins. This enables MTR to load any number of plugins in the same test.