mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
MDEV-33538 make auxiliary spider plugins init depend on actual spider
The two I_S plugins SPIDER_ALLOC_MEM and SPIDER_WRAPPER_PROTOCOL only makes sense if the main SPIDER plugin is installed. Further, SPIDER_ALLOC_MEM requires a mutex that requires SPIDER init to fill the table. We also update the spider init query to override --transaction_read_only=on so that it does not affect the spider init. Also fixed error handling in spider_db_init() so that failure in spider table init does not result in memory leak
This commit is contained in:
@ -641,13 +641,6 @@ int ha_initialize_handlerton(st_plugin_int *plugin)
|
|||||||
hton->slot= HA_SLOT_UNDEF;
|
hton->slot= HA_SLOT_UNDEF;
|
||||||
/* Historical Requirement */
|
/* Historical Requirement */
|
||||||
plugin->data= hton; // shortcut for the future
|
plugin->data= hton; // shortcut for the future
|
||||||
/* [remove after merge] notes on merge conflict (MDEV-31400):
|
|
||||||
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).
|
|
||||||
*/
|
|
||||||
if (plugin->plugin->init && (ret= plugin->plugin->init(hton)))
|
if (plugin->plugin->init && (ret= plugin->plugin->init(hton)))
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
|
@ -9942,6 +9942,7 @@ ST_SCHEMA_TABLE schema_tables[]=
|
|||||||
int initialize_schema_table(st_plugin_int *plugin)
|
int initialize_schema_table(st_plugin_int *plugin)
|
||||||
{
|
{
|
||||||
ST_SCHEMA_TABLE *schema_table;
|
ST_SCHEMA_TABLE *schema_table;
|
||||||
|
int err;
|
||||||
DBUG_ENTER("initialize_schema_table");
|
DBUG_ENTER("initialize_schema_table");
|
||||||
|
|
||||||
if (!(schema_table= (ST_SCHEMA_TABLE *)my_malloc(key_memory_ST_SCHEMA_TABLE,
|
if (!(schema_table= (ST_SCHEMA_TABLE *)my_malloc(key_memory_ST_SCHEMA_TABLE,
|
||||||
@ -9958,12 +9959,15 @@ int initialize_schema_table(st_plugin_int *plugin)
|
|||||||
/* Make the name available to the init() function. */
|
/* Make the name available to the init() function. */
|
||||||
schema_table->table_name= plugin->name.str;
|
schema_table->table_name= plugin->name.str;
|
||||||
|
|
||||||
if (plugin->plugin->init(schema_table))
|
if ((err= plugin->plugin->init(schema_table)))
|
||||||
{
|
{
|
||||||
sql_print_error("Plugin '%s' init function returned error.",
|
if (err != HA_ERR_RETRY_INIT)
|
||||||
plugin->name.str);
|
sql_print_error("Plugin '%s' init function returned error.",
|
||||||
|
plugin->name.str);
|
||||||
plugin->data= NULL;
|
plugin->data= NULL;
|
||||||
my_free(schema_table);
|
my_free(schema_table);
|
||||||
|
if (err == HA_ERR_RETRY_INIT)
|
||||||
|
DBUG_RETURN(err);
|
||||||
DBUG_RETURN(1);
|
DBUG_RETURN(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
12
storage/spider/mysql-test/spider/bugfix/r/mdev_33538.result
Normal file
12
storage/spider/mysql-test/spider/bugfix/r/mdev_33538.result
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
show create table information_schema.SPIDER_ALLOC_MEM;
|
||||||
|
Table Create Table
|
||||||
|
SPIDER_ALLOC_MEM CREATE TEMPORARY TABLE `SPIDER_ALLOC_MEM` (
|
||||||
|
`ID` int(10) unsigned NOT NULL,
|
||||||
|
`FUNC_NAME` varchar(64),
|
||||||
|
`FILE_NAME` varchar(64),
|
||||||
|
`LINE_NO` int(10) unsigned,
|
||||||
|
`TOTAL_ALLOC_MEM` bigint(20) unsigned,
|
||||||
|
`CURRENT_ALLOC_MEM` bigint(20),
|
||||||
|
`ALLOC_MEM_COUNT` bigint(20) unsigned,
|
||||||
|
`FREE_MEM_COUNT` bigint(20) unsigned
|
||||||
|
) ENGINE=MEMORY DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci
|
@ -0,0 +1,8 @@
|
|||||||
|
call mtr.add_suppression("\\[ERROR\\] SPIDER plugin initialization failed");
|
||||||
|
call mtr.add_suppression(".*\\[ERROR\\] Plugin 'SPIDER' registration as a STORAGE ENGINE failed.");
|
||||||
|
call mtr.add_suppression(".*\\[ERROR\\] Plugin 'SPIDER_WRAPPER_PROTOCOLS' registration as a INFORMATION SCHEMA failed.");
|
||||||
|
call mtr.add_suppression(".*\\[ERROR\\] Plugin 'SPIDER_ALLOC_MEM' registration as a INFORMATION SCHEMA failed.");
|
||||||
|
create table mysql.spider_tables (c int);
|
||||||
|
# restart: --plugin-load-add=ha_spider
|
||||||
|
SELECT * FROM information_schema.SPIDER_ALLOC_MEM;
|
||||||
|
ERROR 42S02: Unknown table 'SPIDER_ALLOC_MEM' in information_schema
|
@ -3,5 +3,9 @@
|
|||||||
#
|
#
|
||||||
select * from mysql.plugin;
|
select * from mysql.plugin;
|
||||||
name dl
|
name dl
|
||||||
|
select TABLE_NAME from information_schema.TABLES where TABLE_SCHEMA = "information_schema" and TABLE_NAME like "SPIDER_%";
|
||||||
|
TABLE_NAME
|
||||||
|
SPIDER_ALLOC_MEM
|
||||||
|
SPIDER_WRAPPER_PROTOCOLS
|
||||||
create table t (c int) Engine=SPIDER;
|
create table t (c int) Engine=SPIDER;
|
||||||
drop table t;
|
drop table t;
|
||||||
|
2
storage/spider/mysql-test/spider/bugfix/t/mdev_33538.opt
Normal file
2
storage/spider/mysql-test/spider/bugfix/t/mdev_33538.opt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
--plugin-load-add=ha_spider
|
||||||
|
--transaction-read-only=on
|
@ -0,0 +1,2 @@
|
|||||||
|
# we check that information_schema.SPIDER_ALLOC_MEM exists
|
||||||
|
show create table information_schema.SPIDER_ALLOC_MEM;
|
@ -0,0 +1,17 @@
|
|||||||
|
call mtr.add_suppression("\\[ERROR\\] SPIDER plugin initialization failed");
|
||||||
|
call mtr.add_suppression(".*\\[ERROR\\] Plugin 'SPIDER' registration as a STORAGE ENGINE failed.");
|
||||||
|
call mtr.add_suppression(".*\\[ERROR\\] Plugin 'SPIDER_WRAPPER_PROTOCOLS' registration as a INFORMATION SCHEMA failed.");
|
||||||
|
call mtr.add_suppression(".*\\[ERROR\\] Plugin 'SPIDER_ALLOC_MEM' registration as a INFORMATION SCHEMA failed.");
|
||||||
|
# We create a table with identical name of the spider system table, to
|
||||||
|
# fail the spider init query ([ERROR] SPIDER plugin initialization
|
||||||
|
# failed at 'alter table mysql.spider_tables add column if not exists
|
||||||
|
# link_id int not null default 0 after table_name, drop primary key,
|
||||||
|
# add primary key (db_name, table_name, link_id), algorithm=copy,
|
||||||
|
# lock=shared;' by 'Unknown column 'table_name' in 'spider_tables'')
|
||||||
|
# This will cause the init of spider_alloc_mem to fail because it
|
||||||
|
# depends on the main spider plugin.
|
||||||
|
create table mysql.spider_tables (c int);
|
||||||
|
--let $restart_parameters= --plugin-load-add=ha_spider
|
||||||
|
--source include/restart_mysqld.inc
|
||||||
|
--error ER_UNKNOWN_TABLE
|
||||||
|
SELECT * FROM information_schema.SPIDER_ALLOC_MEM;
|
@ -3,5 +3,6 @@
|
|||||||
--echo #
|
--echo #
|
||||||
# A simple test that tests plugin-load-add=ha_spider
|
# A simple test that tests plugin-load-add=ha_spider
|
||||||
select * from mysql.plugin;
|
select * from mysql.plugin;
|
||||||
|
select TABLE_NAME from information_schema.TABLES where TABLE_SCHEMA = "information_schema" and TABLE_NAME like "SPIDER_%";
|
||||||
create table t (c int) Engine=SPIDER;
|
create table t (c int) Engine=SPIDER;
|
||||||
drop table t;
|
drop table t;
|
||||||
|
@ -129,7 +129,10 @@ static int spider_i_s_alloc_mem_init(
|
|||||||
void *p
|
void *p
|
||||||
) {
|
) {
|
||||||
ST_SCHEMA_TABLE *schema = (ST_SCHEMA_TABLE *) p;
|
ST_SCHEMA_TABLE *schema = (ST_SCHEMA_TABLE *) p;
|
||||||
|
const LEX_CSTRING spider_name={STRING_WITH_LEN("SPIDER")};
|
||||||
DBUG_ENTER("spider_i_s_alloc_mem_init");
|
DBUG_ENTER("spider_i_s_alloc_mem_init");
|
||||||
|
if (!plugin_is_ready(&spider_name, MYSQL_STORAGE_ENGINE_PLUGIN))
|
||||||
|
DBUG_RETURN(HA_ERR_RETRY_INIT);
|
||||||
schema->fields_info = Show::spider_i_s_alloc_mem_fields_info;
|
schema->fields_info = Show::spider_i_s_alloc_mem_fields_info;
|
||||||
schema->fill_table = spider_i_s_alloc_mem_fill_table;
|
schema->fill_table = spider_i_s_alloc_mem_fill_table;
|
||||||
schema->idx_field1 = 0;
|
schema->idx_field1 = 0;
|
||||||
@ -249,7 +252,10 @@ static int spider_i_s_wrapper_protocols_init(
|
|||||||
void *p
|
void *p
|
||||||
) {
|
) {
|
||||||
ST_SCHEMA_TABLE *schema = (ST_SCHEMA_TABLE *) p;
|
ST_SCHEMA_TABLE *schema = (ST_SCHEMA_TABLE *) p;
|
||||||
|
const LEX_CSTRING spider_name={STRING_WITH_LEN("SPIDER")};
|
||||||
DBUG_ENTER("spider_i_s_wrapper_protocols_init");
|
DBUG_ENTER("spider_i_s_wrapper_protocols_init");
|
||||||
|
if (!plugin_is_ready(&spider_name, MYSQL_STORAGE_ENGINE_PLUGIN))
|
||||||
|
DBUG_RETURN(HA_ERR_RETRY_INIT);
|
||||||
schema->fields_info = Show::spider_i_s_wrapper_protocols_fields_info;
|
schema->fields_info = Show::spider_i_s_wrapper_protocols_fields_info;
|
||||||
schema->fill_table = spider_i_s_wrapper_protocols_fill_table;
|
schema->fill_table = spider_i_s_wrapper_protocols_fill_table;
|
||||||
schema->idx_field1 = 0;
|
schema->idx_field1 = 0;
|
||||||
|
@ -25,6 +25,9 @@ static LEX_STRING spider_init_queries[] = {
|
|||||||
"SET @@SQL_MODE = 'STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,"
|
"SET @@SQL_MODE = 'STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,"
|
||||||
"NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';"
|
"NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';"
|
||||||
)},
|
)},
|
||||||
|
{C_STRING_WITH_LEN(
|
||||||
|
"SET tx_read_only = off;"
|
||||||
|
)},
|
||||||
{C_STRING_WITH_LEN(
|
{C_STRING_WITH_LEN(
|
||||||
"create table if not exists mysql.spider_xa("
|
"create table if not exists mysql.spider_xa("
|
||||||
" format_id int not null default 0,"
|
" format_id int not null default 0,"
|
||||||
|
@ -7230,7 +7230,7 @@ int spider_db_init(
|
|||||||
spider_param_table_crd_thread_count()),
|
spider_param_table_crd_thread_count()),
|
||||||
NullS))
|
NullS))
|
||||||
)
|
)
|
||||||
goto error_alloc_mon_mutxes;
|
goto error_alloc_table_sts_crd_threads;
|
||||||
|
|
||||||
for (roop_count = 0;
|
for (roop_count = 0;
|
||||||
roop_count < (int) spider_param_table_sts_thread_count();
|
roop_count < (int) spider_param_table_sts_thread_count();
|
||||||
@ -7305,9 +7305,11 @@ error_init_table_sts_threads:
|
|||||||
{
|
{
|
||||||
spider_free_sts_threads(&spider_table_sts_threads[roop_count]);
|
spider_free_sts_threads(&spider_table_sts_threads[roop_count]);
|
||||||
}
|
}
|
||||||
|
error_alloc_table_sts_crd_threads:
|
||||||
spider_free(NULL, spider_table_sts_threads, MYF(0));
|
spider_free(NULL, spider_table_sts_threads, MYF(0));
|
||||||
roop_count = spider_param_udf_table_mon_mutex_count() - 1;
|
|
||||||
#endif
|
#endif
|
||||||
|
error_system_table_creation:
|
||||||
|
roop_count = spider_param_udf_table_mon_mutex_count() - 1;
|
||||||
error_init_udf_table_mon_list_hash:
|
error_init_udf_table_mon_list_hash:
|
||||||
for (; roop_count >= 0; roop_count--)
|
for (; roop_count >= 0; roop_count--)
|
||||||
{
|
{
|
||||||
@ -7321,7 +7323,6 @@ error_init_udf_table_mon_list_hash:
|
|||||||
error_init_udf_table_mon_cond:
|
error_init_udf_table_mon_cond:
|
||||||
for (; roop_count >= 0; roop_count--)
|
for (; roop_count >= 0; roop_count--)
|
||||||
pthread_cond_destroy(&spider_udf_table_mon_conds[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;
|
roop_count = spider_param_udf_table_mon_mutex_count() - 1;
|
||||||
error_init_udf_table_mon_mutex:
|
error_init_udf_table_mon_mutex:
|
||||||
for (; roop_count >= 0; roop_count--)
|
for (; roop_count >= 0; roop_count--)
|
||||||
|
Reference in New Issue
Block a user