From a6ae1c2dfb272008666d1f15dc9cb0cc06a5b82a Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Mon, 13 May 2024 09:15:14 +1000 Subject: [PATCH] MDEV-32487 Check plugin is ready when resolving storage engine This handles the situation when one thread is still initiating a storage engine plugin, while another is creating a table using it. --- sql/handler.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/sql/handler.cc b/sql/handler.cc index b12014b55ec..42e1c3e7212 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -291,13 +291,20 @@ redo: } +/* + Resolve the storage engine by name. + + Succeed if the storage engine is found and initialised. Otherwise + fail if the sql mode contains NO_ENGINE_SUBSTITUTION. +*/ bool Storage_engine_name::resolve_storage_engine_with_error(THD *thd, handlerton **ha, bool tmp_table) { - if (plugin_ref plugin= ha_resolve_by_name(thd, &m_storage_engine_name, - tmp_table)) + plugin_ref plugin; + if ((plugin= ha_resolve_by_name(thd, &m_storage_engine_name, tmp_table)) && + (plugin_ref_to_int(plugin)->state == PLUGIN_IS_READY)) { *ha= plugin_hton(plugin); return false;