Skip to content

Commit 0254eb9

Browse files
MDEV-31586 Make the MDEV-31463 test more fitting and stable
The original test in the report of MDEV-31463 is contrived and nondeterministic, causing MDEV-31586. We update the test to make it more directly addresses the underlying cause of MDEV-31463, namely errors from queries sent to the data node not consumed when trying to set lock wait timeout. This is achieved through the debug sync facility.
1 parent baf00fc commit 0254eb9

File tree

4 files changed

+88
-51
lines changed

4 files changed

+88
-51
lines changed

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

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,40 @@
33
#
44
for master_1
55
for child2
6+
child2_1
7+
child2_2
8+
child2_3
69
for child3
7-
CREATE SERVER IF NOT EXISTS $srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
8-
SET @old_wait_timeout = @@global.wait_timeout;
9-
SET GLOBAL wait_timeout=1;
10-
CREATE TABLE t (c INT KEY,c1 BLOB,c2 TEXT) ENGINE=Spider COMMENT='WRAPPER "mysql",srv "srv_mdev_31463"';
11-
XA START 'a';
12-
INSERT INTO t VALUES (0,0,0,0);
13-
ERROR 21S01: Column count doesn't match value count at row 1
14-
SELECT SLEEP (1);
15-
SLEEP (1)
16-
0
17-
INSERT INTO t VALUES (1,2,3),(4,5,6),(7,8,9);
18-
Got one of the listed errors
19-
SELECT * FROM information_schema.key_column_usage;
20-
XA END 'a';
21-
XA PREPARE 'a';
22-
XA COMMIT 'a';
23-
SET GLOBAL wait_timeout=@old_wait_timeout;
24-
drop table t;
10+
connection child2_1;
11+
CREATE DATABASE auto_test_remote;
12+
USE auto_test_remote;
13+
CREATE TABLE t1 (a INT) ENGINE=InnoDB DEFAULT CHARSET=utf8;
14+
connection master_1;
15+
CREATE DATABASE auto_test_local;
16+
USE auto_test_local;
17+
CREATE TABLE t2 (a INT) ENGINE=Spider COMMENT='table "t1", srv "s_2_1"';
18+
connect master_1_another, localhost, root, , auto_test_local, $MASTER_1_MYPORT, $MASTER_1_MYSOCK;
19+
SET DEBUG_SYNC='spider_set_lock_wait_timeout_before_query SIGNAL ready WAIT_FOR go';
20+
insert into t2 values (42);
21+
connection master_1;
22+
SET DEBUG_SYNC='now WAIT_FOR ready';
23+
connection child2_1;
24+
connection master_1;
25+
SET DEBUG_SYNC='now SIGNAL go';
26+
connection master_1_another;
27+
ERROR HY000: Got an error writing communication packets
28+
connection master_1;
29+
DROP DATABASE IF EXISTS auto_test_local;
30+
connection child2_1;
31+
# restart
32+
connection child2_1;
33+
DROP DATABASE IF EXISTS auto_test_remote;
2534
for master_1
2635
for child2
36+
child2_1
37+
child2_2
38+
child2_3
2739
for child3
40+
#
41+
# end test
42+
#
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
!include include/default_mysqld.cnf
2+
!include ../my_1_1.cnf
3+
!include ../my_2_1.cnf
Lines changed: 50 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,65 @@
1+
--source include/have_debug.inc
12
--echo #
23
--echo # MDEV-31463 SIGSEGV in server_mysql_send_query | server_mysql_real_query
34
--echo #
45

6+
# The original test in the report of MDEV-31463 is contrived and
7+
# nondeterministic, causing MDEV-31586. This test more directly
8+
# addresses the underlying issue causing MDEV-31463, namely errors
9+
# from queries sent to the data node not consumed when trying to set
10+
# lock wait timeout.
11+
512
--disable_query_log
613
--disable_result_log
714
--source ../../t/test_init.inc
815
--enable_result_log
916
--enable_query_log
1017

11-
--let $srv=srv_mdev_31463
12-
--disable_warnings
13-
evalp CREATE SERVER IF NOT EXISTS $srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
14-
--enable_warnings
15-
16-
SET @old_wait_timeout = @@global.wait_timeout;
17-
SET GLOBAL wait_timeout=1;
18-
eval CREATE TABLE t (c INT KEY,c1 BLOB,c2 TEXT) ENGINE=Spider COMMENT='WRAPPER "mysql",srv "$srv"';
19-
XA START 'a';
20-
--error ER_WRONG_VALUE_COUNT_ON_ROW
21-
INSERT INTO t VALUES (0,0,0,0);
22-
SELECT SLEEP (1);
23-
# MDEV-31586: The error code is non-deterministic, presumably due to
24-
# some race condition from the SLEEP statement above. The correct
25-
# error should be 12701 ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM as it is
26-
# the last failure. Nevertheless, this contrived test is needed to
27-
# cover the error reporting when setting lock wait timeout, until we
28-
# find a better one and/or fixing the non-deterministic error
29-
# reporting
30-
--error 12701,ER_NET_READ_ERROR,ER_NET_ERROR_ON_WRITE,ER_XAER_DUPID
31-
INSERT INTO t VALUES (1,2,3),(4,5,6),(7,8,9);
32-
--disable_result_log
33-
--error 0,12701,ER_XAER_DUPID
34-
SELECT * FROM information_schema.key_column_usage;
35-
--enable_result_log
18+
connection child2_1;
19+
CREATE DATABASE auto_test_remote;
20+
USE auto_test_remote;
21+
eval CREATE TABLE t1 (a INT) $CHILD2_1_ENGINE $CHILD2_1_CHARSET;
22+
23+
connection master_1;
24+
CREATE DATABASE auto_test_local;
25+
USE auto_test_local;
26+
eval CREATE TABLE t2 (a INT) $MASTER_1_ENGINE COMMENT='table "t1", srv "s_2_1"';
27+
28+
# Create a new thread on the spider node server, send an insert query
29+
# to the spider node. Shutdown the data node server when the query
30+
# reaches and waits at set lockwait timeout so it fails there. Check
31+
# the error code is correct.
32+
connect (master_1_another, localhost, root, , auto_test_local, $MASTER_1_MYPORT, $MASTER_1_MYSOCK);
33+
SET DEBUG_SYNC='spider_set_lock_wait_timeout_before_query SIGNAL ready WAIT_FOR go';
34+
send insert into t2 values (42);
35+
connection master_1;
36+
SET DEBUG_SYNC='now WAIT_FOR ready';
37+
38+
connection child2_1;
39+
let $shutdown_timeout=0;
40+
--source include/shutdown_mysqld.inc
41+
42+
connection master_1;
43+
SET DEBUG_SYNC='now SIGNAL go';
44+
connection master_1_another;
45+
--error ER_CONNECT_TO_FOREIGN_DATA_SOURCE
46+
reap;
3647

37-
XA END 'a';
38-
XA PREPARE 'a';
39-
XA COMMIT 'a';
40-
SET GLOBAL wait_timeout=@old_wait_timeout;
41-
drop table t;
48+
# Cleanup
49+
connection master_1;
50+
DROP DATABASE IF EXISTS auto_test_local;
51+
52+
connection child2_1;
53+
--source include/start_mysqld.inc
54+
connection child2_1;
55+
DROP DATABASE IF EXISTS auto_test_remote;
4256

4357
--disable_query_log
4458
--disable_result_log
45-
--source ../../t/test_deinit.inc
46-
--enable_result_log
59+
--source ../t/test_deinit.inc
4760
--enable_query_log
61+
--enable_result_log
62+
63+
--echo #
64+
--echo # end test
65+
--echo #

storage/spider/spd_db_mysql.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13429,14 +13429,15 @@ int spider_mbase_handler::sts_mode_exchange(
1342913429
static int spider_set_lock_wait_timeout(uint seconds, SPIDER_CONN *conn,
1343013430
int *need_mon)
1343113431
{
13432-
char query[512];;
13432+
char query[512];
1343313433
int error_num;
1343413434
DBUG_ENTER("spider_db_set_lock_wait_timeout");
1343513435
size_t query_len =
1343613436
my_snprintf(query, sizeof(query),
1343713437
"set @old_lock_wait_timeout=@@session.lock_wait_timeout;"
1343813438
"set session lock_wait_timeout=%d;",
1343913439
seconds);
13440+
DEBUG_SYNC(conn->thd, "spider_set_lock_wait_timeout_before_query");
1344013441
if (spider_db_query(conn, query, query_len, -1, need_mon))
1344113442
DBUG_RETURN(spider_db_errorno(conn));
1344213443
spider_db_result *result;

0 commit comments

Comments
 (0)