1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +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:
Yuchen Pei
2024-03-04 10:25:34 +11:00
parent 20f60fe70f
commit b84d335d9d
12 changed files with 66 additions and 13 deletions

View 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

View File

@@ -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

View File

@@ -3,5 +3,9 @@
#
select * from mysql.plugin;
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;
drop table t;

View File

@@ -0,0 +1,2 @@
--plugin-load-add=ha_spider
--transaction-read-only=on

View File

@@ -0,0 +1,2 @@
# we check that information_schema.SPIDER_ALLOC_MEM exists
show create table information_schema.SPIDER_ALLOC_MEM;

View File

@@ -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;

View File

@@ -3,5 +3,6 @@
--echo #
# A simple test that tests plugin-load-add=ha_spider
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;
drop table t;