[MDEV-31400] Introduce plugin startup dependency Created: 2023-06-05  Updated: 2023-09-12  Resolved: 2023-07-25

Status: Closed
Project: MariaDB Server
Component/s: Plugins
Fix Version/s: 10.10.1, 10.4.31, 10.5.22, 10.6.15, 10.9.8, 10.11.5, 11.0.3, 11.1.2, 11.2.1

Type: Task Priority: Critical
Reporter: Yuchen Pei Assignee: Yuchen Pei
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Blocks
blocks MDEV-22979 "mysqld --bootstrap" / mysql_install_... Closed

 Description   

The initialisation of a plugin could depend on that of another. An example is spider: its initialisation requires Aria to create its system tables. When a plugin with such dependencies gets loaded with plugin_load_add, the order of initialisation becomes crucial.



 Comments   
Comment by Yuchen Pei [ 2023-06-05 ]

Setting the fix version to 11.2 provisionally. But if this task is needed to fix the spider init bugs existing in 10.5+ then so should this task cover these versions.

Comment by Yuchen Pei [ 2023-06-06 ]

For this task, let's implement a simplified version as proposed in a comment in MDEV-22979[1], that is, initialise all the plugins, then initialise the ones that failed to initialise, and repeat the process until the list of remaining plugins do not decrease. If there are no cycles, this will eventually finish with 0 remaining plugins.

[1] https://jira.mariadb.org/browse/MDEV-22979?focusedCommentId=260463&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-260463

Since this task is considered as a solution for the spider init bugs like MDEV-22979 which exist in 10.4+, I am changing the fixversion of the present ticket accordingly.

Comment by Yuchen Pei [ 2023-06-07 ]

A PoC patch:

https://github.com/MariaDB/server/commit/0e68e51a2db

Comment by Yuchen Pei [ 2023-06-08 ]

Hi serg, PTAL thanks:

https://github.com/MariaDB/server/commit/a2e71bc8e89

Initially (e.g. in the PoC patch) I had the patch separated from the patch to fix spider init bugs, but then I was not sure how to test it without spider, so now these patched are merged together.

Comment by Yuchen Pei [ 2023-06-13 ]

Hi serg, ptal thanks

https://github.com/MariaDB/server/commit/8b5de389ab1

Comment by Yuchen Pei [ 2023-06-13 ]

The review is taking place on the mailing list. Unfortunately the original message is nowhere to be found probably due to the mailing list migration. But my reply (and hopefully further replies) can be found at https://lists.mariadb.org/hyperkitty/list/developers@lists.mariadb.org/thread/IQKT52MKQCNQXODD2GV7GKEEVEFYYP6H/

Comment by Yuchen Pei [ 2023-07-03 ]

Thanks for the comments. Updated commit for review at

https://github.com/MariaDB/server/commit/534031b77e0

Comment by Yuchen Pei [ 2023-07-20 ]

Thanks for the 3rd round comments - ptal the updated patch thanks:

https://github.com/MariaDB/server/commit/e5cafa4e265

Comment by Sergei Golubchik [ 2023-07-20 ]

https://github.com/MariaDB/server/commit/e5cafa4e265 looks good, thanks. ok to push.

you might want to create a helper

static void print_init_failed_error(st_plugin_int *p)
{
  sql_print_error("Plugin '%s' registration as a %s failed.",
                  p->name.str,
                  plugin_type_names[p->plugin->type].str);
}

simply to make sure the error message in both cases is the same and those strings won't go out of sync

Comment by Yuchen Pei [ 2023-07-25 ]

Thanks for the review serg, I'm pushing 734583b0d72 to 10.4, with the following conflict notes in the code:

/* [remove after merge] notes on merge conflict (MDEV-31400):
10.5: 81cd93bbb81d75e7cf14dedede0c9ec0712ace68
10.6-10.11: 13ba00ff4933cfc1712676f323587504e453d1b5
11.0-11.2: 42f8be10f18163c4025710cf6a212e82bddb2f62
The 10.11->11.0 conflict is trivial, but the reference commit also
contains different non-conflict changes needs to be applied to 11.0
(and beyond).
*/

Will close the ticket after it is pushed.

Generated at Thu Feb 08 10:23:35 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.