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.