From 5c4a6807c1d9fa49b95f564f39f4fb6cf49ffc71 Mon Sep 17 00:00:00 2001 From: "brian@zim.(none)" <> Date: Wed, 11 Oct 2006 18:02:12 -0700 Subject: [PATCH 1/2] Panic was being called twice! Both on its own and in the plugin shutdown.... not so good. The code is a bit simpler, and we could now technically remove the panic all entirely if we wanted to. --- sql/handler.cc | 31 +++---------------------------- sql/mysqld.cc | 1 - 2 files changed, 3 insertions(+), 29 deletions(-) diff --git a/sql/handler.cc b/sql/handler.cc index ccf1a1ef8d9..4beef164ee1 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -376,11 +376,12 @@ int ha_finalize_handlerton(st_plugin_int *plugin) case SHOW_OPTION_YES: if (installed_htons[hton->db_type] == hton) installed_htons[hton->db_type]= NULL; - if (hton->panic && hton->panic(hton, HA_PANIC_CLOSE)) - DBUG_RETURN(1); break; }; + if (hton->panic) + hton->panic(hton, HA_PANIC_CLOSE); + if (plugin->plugin->deinit) { /* @@ -509,32 +510,6 @@ int ha_init() DBUG_RETURN(error); } -/* - close, flush or restart databases - Ignore this for other databases than ours -*/ - -static my_bool panic_handlerton(THD *unused1, st_plugin_int *plugin, void *arg) -{ - handlerton *hton= (handlerton *)plugin->data; - if (hton->state == SHOW_OPTION_YES && hton->panic) - ((int*)arg)[0]|= hton->panic(hton, (enum ha_panic_function)((int*)arg)[1]); - return FALSE; -} - - -int ha_panic(enum ha_panic_function flag) -{ - int error[2]; - - error[0]= 0; error[1]= (int)flag; - plugin_foreach(NULL, panic_handlerton, MYSQL_STORAGE_ENGINE_PLUGIN, error); - - if (flag == HA_PANIC_CLOSE && ha_finish_errors()) - error[0]= 1; - return error[0]; -} /* ha_panic */ - static my_bool dropdb_handlerton(THD *unused1, st_plugin_int *plugin, void *path) { diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 6674dd87757..b5e4115c376 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1186,7 +1186,6 @@ void clean_up(bool print_message) lex_free(); /* Free some memory */ set_var_free(); free_charsets(); - (void) ha_panic(HA_PANIC_CLOSE); /* close all tables and logs */ if (!opt_noacl) { #ifdef HAVE_DLOPEN From 31e47a9511c44b1bd0d5e0327303b427402ffd40 Mon Sep 17 00:00:00 2001 From: "brian@zim.(none)" <> Date: Tue, 31 Oct 2006 20:10:32 -0800 Subject: [PATCH 2/2] Adding in an ha_end() call. This is the first part of the patch I and Monty have agreed on. In the future engines will have the option of shutting down more quickly via the panic call, or just shutting down during the unloading of a plugin. --- sql/handler.cc | 17 +++++++++++++++++ sql/handler.h | 1 + sql/mysqld.cc | 1 + 3 files changed, 19 insertions(+) diff --git a/sql/handler.cc b/sql/handler.cc index 4beef164ee1..01f73347397 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -510,6 +510,23 @@ int ha_init() DBUG_RETURN(error); } +int ha_end() +{ + int error= 0; + DBUG_ENTER("ha_end"); + + + /* + This should be eventualy based on the graceful shutdown flag. + So if flag is equal to HA_PANIC_CLOSE, the deallocate + the errors. + */ + if (ha_finish_errors()) + error= 1; + + DBUG_RETURN(error); +} + static my_bool dropdb_handlerton(THD *unused1, st_plugin_int *plugin, void *path) { diff --git a/sql/handler.h b/sql/handler.h index 5e26d9c7b63..56c34b8b75e 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -1654,6 +1654,7 @@ static inline bool ha_storage_engine_is_enabled(const handlerton *db_type) /* basic stuff */ int ha_init(void); +int ha_end(void); int ha_initialize_handlerton(st_plugin_int *plugin); int ha_finalize_handlerton(st_plugin_int *plugin); diff --git a/sql/mysqld.cc b/sql/mysqld.cc index b5e4115c376..877a2d5e220 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1193,6 +1193,7 @@ void clean_up(bool print_message) #endif } plugin_shutdown(); + ha_end(); if (tc_log) tc_log->close(); xid_cache_free();