Skip to content

Commit bdfd93d

Browse files
MDEV-28739 MDEV-29421 Remove spider persistent table stats
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.
1 parent 1a76d75 commit bdfd93d

16 files changed

+164
-789
lines changed

storage/spider/ha_spider.cc

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11965,12 +11965,6 @@ int ha_spider::delete_table(
1196511965
)
1196611966
need_lock = TRUE;
1196711967

11968-
if ((error_num = spider_sys_delete_table_sts(
11969-
current_thd, name, name_len, need_lock)))
11970-
goto error;
11971-
if ((error_num = spider_sys_delete_table_crd(
11972-
current_thd, name, name_len, need_lock)))
11973-
goto error;
1197411968
if (
1197511969
!(table_tables = spider_open_sys_table(
1197611970
current_thd, SPIDER_SYS_TABLES_TABLE_NAME_STR,

storage/spider/mysql-test/spider/bugfix/include/spider_table_sts_deinit.inc

Lines changed: 0 additions & 12 deletions
This file was deleted.

storage/spider/mysql-test/spider/bugfix/include/spider_table_sts_init.inc

Lines changed: 0 additions & 13 deletions
This file was deleted.

storage/spider/mysql-test/spider/bugfix/r/mdev_27575.result

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,11 @@
44
for master_1
55
for child2
66
for child3
7+
call mtr.add_suppression("\\[ERROR\\] Table 'mysql.spider_table_sts' doesn't exist");
8+
call mtr.add_suppression("\\[ERROR\\] Server shutdown in progress");
79
SET GLOBAL default_tmp_storage_engine=spider;
8-
SELECT SLEEP(1);
9-
SLEEP(1)
10-
0
1110
# restart
1211
SET GLOBAL default_storage_engine=Spider;
13-
SELECT SLEEP(1);
14-
SLEEP(1)
15-
0
1612
# restart
1713
for master_1
1814
for child2
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#
2+
# MDEV-28739 Trying to lock uninitialized mutex or hang upon shutdown after using Spider with query_cache
3+
#
4+
for master_1
5+
for child2
6+
child2_1
7+
child2_2
8+
child2_3
9+
for child3
10+
connection child2_1;
11+
CREATE DATABASE auto_test_remote;
12+
USE auto_test_remote;
13+
CREATE TABLE tbl_a (id INT);
14+
connection master_1;
15+
CREATE DATABASE auto_test_local;
16+
USE auto_test_local;
17+
set global query_cache_type= on;
18+
set spider_same_server_link = on;
19+
CREATE TABLE tbl_a (
20+
id INT
21+
) ENGINE=Spider DEFAULT CHARSET=utf8 COMMENT='table "tbl_a", srv "s_2_1"';
22+
SELECT * FROM tbl_a;
23+
id
24+
# restart
25+
connection master_1;
26+
DROP DATABASE IF EXISTS auto_test_local;
27+
connection child2_1;
28+
DROP DATABASE IF EXISTS auto_test_remote;
29+
for master_1
30+
for child2
31+
child2_1
32+
child2_2
33+
child2_3
34+
for child3
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
for master_1
2+
for child2
3+
for child3
4+
set @old_table_open_cache=@@global.table_open_cache;
5+
set global table_open_cache=10;
6+
CREATE SERVER srv FOREIGN DATA WRAPPER mysql
7+
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
8+
CREATE TABLE t (c INT) ENGINE=InnoDB;
9+
CREATE TABLE t_s (c INT) ENGINE=Spider COMMENT='WRAPPER "mysql", srv "srv", TABLE "t"';
10+
CREATE TABLE t1 (a INT) ENGINE=Spider;
11+
SELECT * FROM t1;
12+
ERROR HY000: Unable to connect to foreign data source: localhost
13+
SELECT * FROM information_schema.tables;
14+
DROP TABLE t, t_s, t1;
15+
drop server srv;
16+
set global table_open_cache=@old_table_open_cache;
17+
for master_1
18+
for child2
19+
for child3

storage/spider/mysql-test/spider/bugfix/r/spider_table_sts.result

Lines changed: 0 additions & 38 deletions
This file was deleted.

storage/spider/mysql-test/spider/bugfix/t/mdev_27575.test

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@
77
--enable_result_log
88
--enable_query_log
99

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

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

1820
--disable_query_log
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
!include include/default_mysqld.cnf
22
!include ../my_1_1.cnf
3+
!include ../my_2_1.cnf
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
--echo #
2+
--echo # MDEV-28739 Trying to lock uninitialized mutex or hang upon shutdown after using Spider with query_cache
3+
--echo #
4+
5+
--disable_query_log
6+
--disable_result_log
7+
--source ../../t/test_init.inc
8+
--enable_result_log
9+
--enable_query_log
10+
11+
--connection child2_1
12+
CREATE DATABASE auto_test_remote;
13+
USE auto_test_remote;
14+
15+
CREATE TABLE tbl_a (id INT);
16+
17+
--connection master_1
18+
CREATE DATABASE auto_test_local;
19+
USE auto_test_local;
20+
21+
set global query_cache_type= on;
22+
set spider_same_server_link = on;
23+
24+
eval CREATE TABLE tbl_a (
25+
id INT
26+
) $MASTER_1_ENGINE $MASTER_1_CHARSET COMMENT='table "tbl_a", srv "s_2_1"';
27+
28+
SELECT * FROM tbl_a;
29+
30+
--source include/restart_mysqld.inc
31+
32+
--connection master_1
33+
DROP DATABASE IF EXISTS auto_test_local;
34+
--connection child2_1
35+
DROP DATABASE IF EXISTS auto_test_remote;
36+
37+
--disable_query_log
38+
--disable_result_log
39+
--source ../t/test_deinit.inc
40+
--enable_query_log
41+
--enable_result_log

0 commit comments

Comments
 (0)