Skip to content

Commit

Permalink
MDEV-28739 MDEV-29421 Remove spider persistent table stats
Browse files Browse the repository at this point in the history
We remove the call to update spider persistent table stats (sts/crd)
in spider_free_share(). This prevents spider from opening and closing
further tables during close(), which fixes the following issues:

MDEV-28739: ha_spider::close() is called during tdc_start_shutdown(),
which is called after query_cache_destroy(). Closing the sts/crd Aria
tables will trigger a call to Query_cache::invalidate_table(), which
will attempt to use the query cache mutex structure_guard_mutex
destroyed previously.

MDEV-29421: during ha_spider::close(), spider_free_share() could
trigger another spider_free_share() through updating sts/crd table,
because open_table() calls tc_add_table(), which could trigger another
ha_spider::close()...

Since spider sts/crd system tables are only updated here, there's no
use for these tables any more, and we remove all uses of these tables
too.

The removal should not cause any performance issue, as in memory
spider table stats are only updated based on a time
interval (spider_sts_interval and spider_crd_interval), which defaults
to 10 seconds. It should not affect accuracy either, due to the
infrequency of server restart. And inaccurate stats are not a problem
for optimizer anyway.

To be on the safe side, we defer the removal of the spider sts/crd
tables themselves to future.
  • Loading branch information
mariadb-YuchenPei committed Nov 24, 2023
1 parent 1a76d75 commit bdfd93d
Show file tree
Hide file tree
Showing 16 changed files with 164 additions and 789 deletions.
6 changes: 0 additions & 6 deletions storage/spider/ha_spider.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11965,12 +11965,6 @@ int ha_spider::delete_table(
)
need_lock = TRUE;

if ((error_num = spider_sys_delete_table_sts(
current_thd, name, name_len, need_lock)))
goto error;
if ((error_num = spider_sys_delete_table_crd(
current_thd, name, name_len, need_lock)))
goto error;
if (
!(table_tables = spider_open_sys_table(
current_thd, SPIDER_SYS_TABLES_TABLE_NAME_STR,
Expand Down

This file was deleted.

This file was deleted.

8 changes: 2 additions & 6 deletions storage/spider/mysql-test/spider/bugfix/r/mdev_27575.result
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,11 @@
for master_1
for child2
for child3
call mtr.add_suppression("\\[ERROR\\] Table 'mysql.spider_table_sts' doesn't exist");
call mtr.add_suppression("\\[ERROR\\] Server shutdown in progress");
SET GLOBAL default_tmp_storage_engine=spider;
SELECT SLEEP(1);
SLEEP(1)
0
# restart
SET GLOBAL default_storage_engine=Spider;
SELECT SLEEP(1);
SLEEP(1)
0
# restart
for master_1
for child2
Expand Down
34 changes: 34 additions & 0 deletions storage/spider/mysql-test/spider/bugfix/r/mdev_28739.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#
# MDEV-28739 Trying to lock uninitialized mutex or hang upon shutdown after using Spider with query_cache
#
for master_1
for child2
child2_1
child2_2
child2_3
for child3
connection child2_1;
CREATE DATABASE auto_test_remote;
USE auto_test_remote;
CREATE TABLE tbl_a (id INT);
connection master_1;
CREATE DATABASE auto_test_local;
USE auto_test_local;
set global query_cache_type= on;
set spider_same_server_link = on;
CREATE TABLE tbl_a (
id INT
) ENGINE=Spider DEFAULT CHARSET=utf8 COMMENT='table "tbl_a", srv "s_2_1"';
SELECT * FROM tbl_a;
id
# restart
connection master_1;
DROP DATABASE IF EXISTS auto_test_local;
connection child2_1;
DROP DATABASE IF EXISTS auto_test_remote;
for master_1
for child2
child2_1
child2_2
child2_3
for child3
19 changes: 19 additions & 0 deletions storage/spider/mysql-test/spider/bugfix/r/mdev_29421.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
for master_1
for child2
for child3
set @old_table_open_cache=@@global.table_open_cache;
set global table_open_cache=10;
CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
CREATE TABLE t (c INT) ENGINE=InnoDB;
CREATE TABLE t_s (c INT) ENGINE=Spider COMMENT='WRAPPER "mysql", srv "srv", TABLE "t"';
CREATE TABLE t1 (a INT) ENGINE=Spider;
SELECT * FROM t1;
ERROR HY000: Unable to connect to foreign data source: localhost
SELECT * FROM information_schema.tables;
DROP TABLE t, t_s, t1;
drop server srv;
set global table_open_cache=@old_table_open_cache;
for master_1
for child2
for child3
38 changes: 0 additions & 38 deletions storage/spider/mysql-test/spider/bugfix/r/spider_table_sts.result

This file was deleted.

6 changes: 4 additions & 2 deletions storage/spider/mysql-test/spider/bugfix/t/mdev_27575.test
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
--enable_result_log
--enable_query_log

# These suppressions are a workaround and should not be needed once
# MDEV-29870 is done.
call mtr.add_suppression("\\[ERROR\\] Table 'mysql.spider_table_sts' doesn't exist");
call mtr.add_suppression("\\[ERROR\\] Server shutdown in progress");
SET GLOBAL default_tmp_storage_engine=spider;
SELECT SLEEP(1);
--source include/restart_mysqld.inc

SET GLOBAL default_storage_engine=Spider;
SELECT SLEEP(1);
--source include/restart_mysqld.inc

--disable_query_log
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
!include include/default_mysqld.cnf
!include ../my_1_1.cnf
!include ../my_2_1.cnf
41 changes: 41 additions & 0 deletions storage/spider/mysql-test/spider/bugfix/t/mdev_28739.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
--echo #
--echo # MDEV-28739 Trying to lock uninitialized mutex or hang upon shutdown after using Spider with query_cache
--echo #

--disable_query_log
--disable_result_log
--source ../../t/test_init.inc
--enable_result_log
--enable_query_log

--connection child2_1
CREATE DATABASE auto_test_remote;
USE auto_test_remote;

CREATE TABLE tbl_a (id INT);

--connection master_1
CREATE DATABASE auto_test_local;
USE auto_test_local;

set global query_cache_type= on;
set spider_same_server_link = on;

eval CREATE TABLE tbl_a (
id INT
) $MASTER_1_ENGINE $MASTER_1_CHARSET COMMENT='table "tbl_a", srv "s_2_1"';

SELECT * FROM tbl_a;

--source include/restart_mysqld.inc

--connection master_1
DROP DATABASE IF EXISTS auto_test_local;
--connection child2_1
DROP DATABASE IF EXISTS auto_test_remote;

--disable_query_log
--disable_result_log
--source ../t/test_deinit.inc
--enable_query_log
--enable_result_log
30 changes: 30 additions & 0 deletions storage/spider/mysql-test/spider/bugfix/t/mdev_28739_simple.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
--echo #
--echo # MDEV-28739 Trying to lock uninitialized mutex or hang upon shutdown after using Spider with query_cache
--echo #

--disable_query_log
--disable_result_log
--source ../../t/test_init.inc
--enable_result_log
--enable_query_log

# set @@global.debug_dbug="+d,xid_thd_trace,enter,exit,info,error:o,/tmp/trace2.out:i:F:L";
#set @@global.debug_dbug="d:t:i:o,mysqld.trace";

set global query_cache_type= on;
evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
create table t2 (c int);
create table t1 (c int) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2"';
SELECT * FROM t1;
#shutdown;
--source include/restart_mysqld.inc
drop table t1, t2;
drop server srv;

--disable_query_log
--disable_result_log
--source ../t/test_deinit.inc
--enable_query_log
--enable_result_log
26 changes: 26 additions & 0 deletions storage/spider/mysql-test/spider/bugfix/t/mdev_29421.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
--disable_query_log
--disable_result_log
--source ../../t/test_init.inc
--enable_result_log
--enable_query_log
set @old_table_open_cache=@@global.table_open_cache;
set global table_open_cache=10;
evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
CREATE TABLE t (c INT) ENGINE=InnoDB;
CREATE TABLE t_s (c INT) ENGINE=Spider COMMENT='WRAPPER "mysql", srv "srv", TABLE "t"';
CREATE TABLE t1 (a INT) ENGINE=Spider;
--error 1429
SELECT * FROM t1;
--disable_result_log
SELECT * FROM information_schema.tables;
--enable_result_log
DROP TABLE t, t_s, t1;
drop server srv;
set global table_open_cache=@old_table_open_cache;

--disable_query_log
--disable_result_log
--source ../../t/test_deinit.inc
--enable_result_log
--enable_query_log
46 changes: 0 additions & 46 deletions storage/spider/mysql-test/spider/bugfix/t/spider_table_sts.test

This file was deleted.

Loading

0 comments on commit bdfd93d

Please sign in to comment.