Skip to content

Commit

Permalink
Spider cannot run DDL (e.g. create tables) before ddl recovery
Browse files Browse the repository at this point in the history
use signal_ddl_recovery_done callback for that.

also make the server to call signal_ddl_recovery_done() when loading
plugins at run-time (so that plugins would't need to detect that
on their own)
  • Loading branch information
vuvova committed Dec 17, 2023
1 parent e95bba9 commit 0930eb8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
6 changes: 5 additions & 1 deletion sql/handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ int ha_finalize_handlerton(st_plugin_int *plugin)


const char *hton_no_exts[]= { 0 };

static bool ddl_recovery_done= false;

int ha_initialize_handlerton(st_plugin_int *plugin)
{
Expand Down Expand Up @@ -779,6 +779,9 @@ int ha_initialize_handlerton(st_plugin_int *plugin)
resolve_sysvar_table_options(hton);
update_discovery_counters(hton, 1);

if (ddl_recovery_done && hton->signal_ddl_recovery_done)
hton->signal_ddl_recovery_done(hton);

DBUG_RETURN(ret);

err_deinit:
Expand Down Expand Up @@ -975,6 +978,7 @@ void ha_signal_ddl_recovery_done()
DBUG_ENTER("ha_signal_ddl_recovery_done");
plugin_foreach(NULL, signal_ddl_recovery_done, MYSQL_STORAGE_ENGINE_PLUGIN,
NULL);
ddl_recovery_done= true;
DBUG_VOID_RETURN;
}

Expand Down
16 changes: 10 additions & 6 deletions storage/spider/spd_table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7123,6 +7123,15 @@ bool spider_init_system_tables()
}


/*
Spider is typically loaded before ddl_recovery, but DDL statements
cannot be executed before ddl_recovery, so we delay system table creation.
*/
static void spider_after_ddl_recovery(handlerton *)
{
spider_init_system_tables();
}

int spider_db_init(
void *p
) {
Expand Down Expand Up @@ -7153,6 +7162,7 @@ int spider_db_init(
spider_hton->close_cursor_read_view = spider_close_cursor_read_view;
*/
spider_hton->panic = spider_panic;
spider_hton->signal_ddl_recovery_done= spider_after_ddl_recovery;
spider_hton->close_connection = spider_close_connection;
spider_hton->start_consistent_snapshot = spider_start_consistent_snapshot;
spider_hton->flush_logs = spider_flush_logs;
Expand Down Expand Up @@ -7490,11 +7500,6 @@ int spider_db_init(
spider_udf_table_mon_list_hash[roop_count].array.size_of_element);
}

if (spider_init_system_tables())
{
goto error_system_table_creation;
}

#ifndef WITHOUT_SPIDER_BG_SEARCH
if (!(spider_table_sts_threads = (SPIDER_THREAD *)
spider_bulk_malloc(NULL, SPD_MID_DB_INIT_12, MYF(MY_WME | MY_ZEROFILL),
Expand Down Expand Up @@ -7595,7 +7600,6 @@ int spider_db_init(
error_init_udf_table_mon_cond:
for (; roop_count >= 0; roop_count--)
pthread_cond_destroy(&spider_udf_table_mon_conds[roop_count]);
error_system_table_creation:
roop_count = spider_param_udf_table_mon_mutex_count() - 1;
error_init_udf_table_mon_mutex:
for (; roop_count >= 0; roop_count--)
Expand Down

0 comments on commit 0930eb8

Please sign in to comment.