Skip to content

Commit d8f5d2b

Browse files
MDEV-22979 MDEV-27233 MDEV-28218 Fixing spider init bugs
Fix spider init bugs (MDEV-22979, MDEV-27233, MDEV-28218) while preventing regression on old ones (MDEV-30370, MDEV-29904) Two things are changed: First, Spider initialisation is made fully synchronous, i.e. it no longer happens in a background thread. Adapted from the original fix by nayuta for MDEV-27233. This change itself would cause failure when spider is initialised early, by plugin-load-add, due to dependency on Aria and udf function creation, which are fixed in the second and third parts below. Requires SQL Service, thus porting earlier versions requires MDEV-27595 Second, if spider is initialised before udf_init(), create udf by inserting into `mysql.func`, otherwise do it by `CREATE FUNCTION` as usual. This change may be generalised in MDEV-31401. Also factor out some clean-up queries from deinit_spider.inc for use of spider init tests. A minor caveat is that early spider initialisation will fail if the server is bootstrapped for the first time, due to missing `mysql` database which needs to be created by the bootstrap script.
1 parent afe63ec commit d8f5d2b

36 files changed

+337
-139
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
MDEV-22979 "mysqld --bootstrap" / mysql_install_db hangs when Spider is installed
2+
# Kill the server
3+
# restart
4+
Warnings:
5+
Note 1305 SONAME ha_spider.so does not exist
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#
2+
# MDEV-27233 Server hangs when using --init-file which loads Spider and creates a Spider table
3+
#
4+
show create table t;
5+
Table Create Table
6+
t CREATE TABLE `t` (
7+
`c` int(11) DEFAULT NULL
8+
) ENGINE=SPIDER DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
9+
Warnings:
10+
Error 1429 Unable to connect to foreign data source: localhost
11+
Error 1429 Unable to connect to foreign data source: localhost
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#
2+
# MDEV-28218 Spider: thread hang/deadlock as result of INSTALL PLUGIN and DROP TABLE
3+
#
4+
INSTALL SONAME 'ha_spider.so';
5+
DROP TABLE IF EXISTS mysql.spider_tables;
6+
show create table mysql.spider_tables;
7+
ERROR 42S02: Table 'mysql.spider_tables' doesn't exist
8+
Warnings:
9+
Note 1051 Unknown table 'mysql.spider_tables'
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#
2+
# MDEV-28218 Spider: thread hang/deadlock as result of INSTALL PLUGIN and DROP TABLE
3+
#
4+
show create table mysql.spider_tables;
5+
ERROR 42S02: Table 'mysql.spider_tables' doesn't exist
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#
2+
# MDEV-28218 Spider: thread hang/deadlock as result of INSTALL PLUGIN and DROP TABLE
3+
#
4+
show create table mysql.spider_tables;
5+
ERROR 42S02: Table 'mysql.spider_tables' doesn't exist
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
#
22
# MDEV-30370 mariadbd hangs when running with --wsrep-recover and --plugin-load-add=ha_spider.so
33
#
4+
# Kill the server
5+
# restart
6+
Warnings:
7+
Note 1305 SONAME ha_spider.so does not exist
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#
2+
# plugin-load-add=ha_spider
3+
#
4+
select * from mysql.plugin;
5+
name dl
6+
create table t (c int) Engine=SPIDER;
7+
drop table t;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#
2+
# plugin-load-add=ha_spider
3+
#
4+
select * from mysql.plugin;
5+
name dl
6+
create table t (c int) Engine=SPIDER;
7+
drop table t;
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#
2+
# Test that udf created by inserting into mysql_func works as expected
3+
#
4+
CREATE SERVER s_1 FOREIGN DATA WRAPPER mysql OPTIONS (
5+
HOST 'localhost',
6+
DATABASE 'auto_test_local',
7+
USER 'root',
8+
PASSWORD '',
9+
SOCKET '$MASTER_1_MYSOCK'
10+
);
11+
CREATE SERVER s_2_1 FOREIGN DATA WRAPPER mysql OPTIONS (
12+
HOST 'localhost',
13+
DATABASE 'auto_test_remote',
14+
USER 'root',
15+
PASSWORD '',
16+
SOCKET '$CHILD2_1_MYSOCK'
17+
);
18+
connect master_1, localhost, root, , , $MASTER_1_MYPORT, $MASTER_1_MYSOCK;
19+
connect child2_1, localhost, root, , , $CHILD2_1_MYPORT, $CHILD2_1_MYSOCK;
20+
connection child2_1;
21+
CREATE DATABASE auto_test_remote;
22+
USE auto_test_remote;
23+
CREATE TABLE tbl_a (
24+
a INT
25+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
26+
insert into tbl_a values (42);
27+
connection master_1;
28+
CREATE DATABASE auto_test_local;
29+
USE auto_test_local;
30+
CREATE TABLE tbl_a (
31+
a INT
32+
) ENGINE=Spider DEFAULT CHARSET=utf8 COMMENT='table "tbl_a", srv "s_2_1"';
33+
create temporary table results (a int);
34+
SELECT SPIDER_DIRECT_SQL('select * from tbl_a', 'results', 'srv "s_2_1", database "auto_test_remote"');
35+
SPIDER_DIRECT_SQL('select * from tbl_a', 'results', 'srv "s_2_1", database "auto_test_remote"')
36+
1
37+
select * from results;
38+
a
39+
42
40+
connection master_1;
41+
DROP DATABASE IF EXISTS auto_test_local;
42+
connection child2_1;
43+
DROP DATABASE IF EXISTS auto_test_remote;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
udf_mysql_func_early.result

0 commit comments

Comments
 (0)