summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--storage/rocksdb/ha_rocksdb.cc30
-rw-r--r--storage/rocksdb/ha_rocksdb.h1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/mariadb_plugin.result8
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/mariadb_plugin.test10
-rw-r--r--storage/rocksdb/rdb_i_s.cc33
5 files changed, 80 insertions, 2 deletions
diff --git a/storage/rocksdb/ha_rocksdb.cc b/storage/rocksdb/ha_rocksdb.cc
index e77de87cf2c..898c93a4fbe 100644
--- a/storage/rocksdb/ha_rocksdb.cc
+++ b/storage/rocksdb/ha_rocksdb.cc
@@ -3957,14 +3957,25 @@ static rocksdb::Status check_rocksdb_options_compatibility(
return status;
}
+bool prevent_myrocks_loading= false;
+
/*
Storage Engine initialization function, invoked when plugin is loaded.
*/
static int rocksdb_init_func(void *const p) {
+
DBUG_ENTER_FUNC();
+ if (prevent_myrocks_loading)
+ {
+ my_error(ER_INTERNAL_ERROR, MYF(0),
+ "Loading MyRocks plugin after it has been unloaded is not "
+ "supported. Please restart mysqld");
+ DBUG_RETURN(1);
+ }
+
// Validate the assumption about the size of ROCKSDB_SIZEOF_HIDDEN_PK_COLUMN.
static_assert(sizeof(longlong) == 8, "Assuming that longlong is 8 bytes.");
@@ -4505,12 +4516,27 @@ static int rocksdb_done_func(void *const p) {
}
#endif /* HAVE_purify */
- rocksdb_db_options = nullptr;
- rocksdb_tbl_options = nullptr;
+ /*
+ MariaDB: don't clear rocksdb_db_options and rocksdb_tbl_options.
+ MyRocks' plugin variables refer to them.
+
+ The plugin cannot be loaded again (see prevent_myrocks_loading) but plugin
+ variables are processed before myrocks::rocksdb_init_func is invoked, so
+ they must point to valid memory.
+ */
+ //rocksdb_db_options = nullptr;
+ rocksdb_db_options->statistics = nullptr;
+ //rocksdb_tbl_options = nullptr;
rocksdb_stats = nullptr;
my_error_unregister(HA_ERR_ROCKSDB_FIRST, HA_ERR_ROCKSDB_LAST);
+ /*
+ Prevent loading the plugin after it has been loaded and then unloaded. This
+ doesn't work currently.
+ */
+ prevent_myrocks_loading= true;
+
DBUG_RETURN(error);
}
diff --git a/storage/rocksdb/ha_rocksdb.h b/storage/rocksdb/ha_rocksdb.h
index 1769072722a..31adef85507 100644
--- a/storage/rocksdb/ha_rocksdb.h
+++ b/storage/rocksdb/ha_rocksdb.h
@@ -1414,4 +1414,5 @@ private:
const int MYROCKS_MARIADB_PLUGIN_MATURITY_LEVEL= MariaDB_PLUGIN_MATURITY_GAMMA;
+extern bool prevent_myrocks_loading;
} // namespace myrocks
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/mariadb_plugin.result b/storage/rocksdb/mysql-test/rocksdb/r/mariadb_plugin.result
index bb06c4be2e5..3197b163132 100644
--- a/storage/rocksdb/mysql-test/rocksdb/r/mariadb_plugin.result
+++ b/storage/rocksdb/mysql-test/rocksdb/r/mariadb_plugin.result
@@ -10,3 +10,11 @@ insert into test.t1 values (1);
connection default;
DROP TABLE t1;
UNINSTALL SONAME 'ha_rocksdb';
+#
+# MDEV-15686: Loading MyRocks plugin back after it has been unloaded causes a crash
+#
+call mtr.add_suppression("Plugin 'ROCKSDB.*' init function returned error.");
+call mtr.add_suppression("Plugin 'ROCKSDB.*' registration as a INFORMATION SCHEMA failed.");
+call mtr.add_suppression("Plugin 'ROCKSDB' registration as a STORAGE ENGINE failed");
+INSTALL SONAME 'ha_rocksdb';
+ERROR HY000: Internal error: Loading MyRocks plugin after it has been unloaded is not supported. Please restart mysqld
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/mariadb_plugin.test b/storage/rocksdb/mysql-test/rocksdb/t/mariadb_plugin.test
index cdff6859fe9..4f582af1960 100644
--- a/storage/rocksdb/mysql-test/rocksdb/t/mariadb_plugin.test
+++ b/storage/rocksdb/mysql-test/rocksdb/t/mariadb_plugin.test
@@ -26,3 +26,13 @@ connection default;
# Cleanup
DROP TABLE t1;
UNINSTALL SONAME 'ha_rocksdb';
+
+--echo #
+--echo # MDEV-15686: Loading MyRocks plugin back after it has been unloaded causes a crash
+--echo #
+call mtr.add_suppression("Plugin 'ROCKSDB.*' init function returned error.");
+call mtr.add_suppression("Plugin 'ROCKSDB.*' registration as a INFORMATION SCHEMA failed.");
+call mtr.add_suppression("Plugin 'ROCKSDB' registration as a STORAGE ENGINE failed");
+
+--error ER_INTERNAL_ERROR
+INSTALL SONAME 'ha_rocksdb';
diff --git a/storage/rocksdb/rdb_i_s.cc b/storage/rocksdb/rdb_i_s.cc
index f8ddcb00fb3..8d801dd430b 100644
--- a/storage/rocksdb/rdb_i_s.cc
+++ b/storage/rocksdb/rdb_i_s.cc
@@ -142,6 +142,9 @@ static int rdb_i_s_cfstats_fill_table(
static int rdb_i_s_cfstats_init(void *p) {
DBUG_ENTER_FUNC();
+ if (prevent_myrocks_loading)
+ DBUG_RETURN(1);
+
DBUG_ASSERT(p != nullptr);
my_core::ST_SCHEMA_TABLE *schema;
@@ -235,6 +238,9 @@ static int rdb_i_s_dbstats_fill_table(
static int rdb_i_s_dbstats_init(void *const p) {
DBUG_ENTER_FUNC();
+ if (prevent_myrocks_loading)
+ DBUG_RETURN(1);
+
DBUG_ASSERT(p != nullptr);
my_core::ST_SCHEMA_TABLE *schema;
@@ -336,6 +342,8 @@ static int rdb_i_s_perf_context_fill_table(
static int rdb_i_s_perf_context_init(void *const p) {
DBUG_ENTER_FUNC();
+ if (prevent_myrocks_loading)
+ DBUG_RETURN(1);
DBUG_ASSERT(p != nullptr);
my_core::ST_SCHEMA_TABLE *schema;
@@ -403,6 +411,9 @@ static int rdb_i_s_perf_context_global_fill_table(
static int rdb_i_s_perf_context_global_init(void *const p) {
DBUG_ENTER_FUNC();
+ if (prevent_myrocks_loading)
+ DBUG_RETURN(1);
+
DBUG_ASSERT(p != nullptr);
my_core::ST_SCHEMA_TABLE *schema;
@@ -1017,6 +1028,9 @@ static int rdb_i_s_ddl_fill_table(my_core::THD *const thd,
static int rdb_i_s_ddl_init(void *const p) {
DBUG_ENTER_FUNC();
+ if (prevent_myrocks_loading)
+ DBUG_RETURN(1);
+
my_core::ST_SCHEMA_TABLE *schema;
DBUG_ASSERT(p != nullptr);
@@ -1032,6 +1046,9 @@ static int rdb_i_s_ddl_init(void *const p) {
static int rdb_i_s_cfoptions_init(void *const p) {
DBUG_ENTER_FUNC();
+ if (prevent_myrocks_loading)
+ DBUG_RETURN(1);
+
DBUG_ASSERT(p != nullptr);
my_core::ST_SCHEMA_TABLE *schema;
@@ -1047,6 +1064,9 @@ static int rdb_i_s_cfoptions_init(void *const p) {
static int rdb_i_s_global_info_init(void *const p) {
DBUG_ENTER_FUNC();
+ if (prevent_myrocks_loading)
+ DBUG_RETURN(1);
+
DBUG_ASSERT(p != nullptr);
my_core::ST_SCHEMA_TABLE *schema;
@@ -1063,6 +1083,10 @@ static int rdb_i_s_compact_stats_init(void *p) {
my_core::ST_SCHEMA_TABLE *schema;
DBUG_ENTER_FUNC();
+
+ if (prevent_myrocks_loading)
+ DBUG_RETURN(1);
+
DBUG_ASSERT(p != nullptr);
schema = reinterpret_cast<my_core::ST_SCHEMA_TABLE *>(p);
@@ -1237,6 +1261,9 @@ static int rdb_i_s_index_file_map_fill_table(
static int rdb_i_s_index_file_map_init(void *const p) {
DBUG_ENTER_FUNC();
+ if (prevent_myrocks_loading)
+ DBUG_RETURN(1);
+
DBUG_ASSERT(p != nullptr);
my_core::ST_SCHEMA_TABLE *schema;
@@ -1320,6 +1347,9 @@ static int rdb_i_s_lock_info_fill_table(
static int rdb_i_s_lock_info_init(void *const p) {
DBUG_ENTER_FUNC();
+ if (prevent_myrocks_loading)
+ DBUG_RETURN(1);
+
DBUG_ASSERT(p != nullptr);
my_core::ST_SCHEMA_TABLE *schema;
@@ -1450,6 +1480,9 @@ static int rdb_i_s_trx_info_fill_table(
static int rdb_i_s_trx_info_init(void *const p) {
DBUG_ENTER_FUNC();
+ if (prevent_myrocks_loading)
+ DBUG_RETURN(1);
+
DBUG_ASSERT(p != nullptr);
my_core::ST_SCHEMA_TABLE *schema;