Commit 0254eb93 authored by Yuchen Pei's avatar Yuchen Pei

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.
parent baf00fc5
...@@ -3,25 +3,40 @@ ...@@ -3,25 +3,40 @@
# #
for master_1 for master_1
for child2 for child2
child2_1
child2_2
child2_3
for child3 for child3
CREATE SERVER IF NOT EXISTS $srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); connection child2_1;
SET @old_wait_timeout = @@global.wait_timeout; CREATE DATABASE auto_test_remote;
SET GLOBAL wait_timeout=1; USE auto_test_remote;
CREATE TABLE t (c INT KEY,c1 BLOB,c2 TEXT) ENGINE=Spider COMMENT='WRAPPER "mysql",srv "srv_mdev_31463"'; CREATE TABLE t1 (a INT) ENGINE=InnoDB DEFAULT CHARSET=utf8;
XA START 'a'; connection master_1;
INSERT INTO t VALUES (0,0,0,0); CREATE DATABASE auto_test_local;
ERROR 21S01: Column count doesn't match value count at row 1 USE auto_test_local;
SELECT SLEEP (1); CREATE TABLE t2 (a INT) ENGINE=Spider COMMENT='table "t1", srv "s_2_1"';
SLEEP (1) connect master_1_another, localhost, root, , auto_test_local, $MASTER_1_MYPORT, $MASTER_1_MYSOCK;
0 SET DEBUG_SYNC='spider_set_lock_wait_timeout_before_query SIGNAL ready WAIT_FOR go';
INSERT INTO t VALUES (1,2,3),(4,5,6),(7,8,9); insert into t2 values (42);
Got one of the listed errors connection master_1;
SELECT * FROM information_schema.key_column_usage; SET DEBUG_SYNC='now WAIT_FOR ready';
XA END 'a'; connection child2_1;
XA PREPARE 'a'; connection master_1;
XA COMMIT 'a'; SET DEBUG_SYNC='now SIGNAL go';
SET GLOBAL wait_timeout=@old_wait_timeout; connection master_1_another;
drop table t; ERROR HY000: Got an error writing communication packets
connection master_1;
DROP DATABASE IF EXISTS auto_test_local;
connection child2_1;
# restart
connection child2_1;
DROP DATABASE IF EXISTS auto_test_remote;
for master_1 for master_1
for child2 for child2
child2_1
child2_2
child2_3
for child3 for child3
#
# end test
#
!include include/default_mysqld.cnf
!include ../my_1_1.cnf
!include ../my_2_1.cnf
--source include/have_debug.inc
--echo # --echo #
--echo # MDEV-31463 SIGSEGV in server_mysql_send_query | server_mysql_real_query --echo # MDEV-31463 SIGSEGV in server_mysql_send_query | server_mysql_real_query
--echo # --echo #
# The original test in the report of MDEV-31463 is contrived and
# nondeterministic, causing MDEV-31586. This test more directly
# addresses the underlying issue causing MDEV-31463, namely errors
# from queries sent to the data node not consumed when trying to set
# lock wait timeout.
--disable_query_log --disable_query_log
--disable_result_log --disable_result_log
--source ../../t/test_init.inc --source ../../t/test_init.inc
--enable_result_log --enable_result_log
--enable_query_log --enable_query_log
--let $srv=srv_mdev_31463 connection child2_1;
--disable_warnings CREATE DATABASE auto_test_remote;
evalp CREATE SERVER IF NOT EXISTS $srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); USE auto_test_remote;
--enable_warnings eval CREATE TABLE t1 (a INT) $CHILD2_1_ENGINE $CHILD2_1_CHARSET;
SET @old_wait_timeout = @@global.wait_timeout; connection master_1;
SET GLOBAL wait_timeout=1; CREATE DATABASE auto_test_local;
eval CREATE TABLE t (c INT KEY,c1 BLOB,c2 TEXT) ENGINE=Spider COMMENT='WRAPPER "mysql",srv "$srv"'; USE auto_test_local;
XA START 'a'; eval CREATE TABLE t2 (a INT) $MASTER_1_ENGINE COMMENT='table "t1", srv "s_2_1"';
--error ER_WRONG_VALUE_COUNT_ON_ROW
INSERT INTO t VALUES (0,0,0,0); # Create a new thread on the spider node server, send an insert query
SELECT SLEEP (1); # to the spider node. Shutdown the data node server when the query
# MDEV-31586: The error code is non-deterministic, presumably due to # reaches and waits at set lockwait timeout so it fails there. Check
# some race condition from the SLEEP statement above. The correct # the error code is correct.
# error should be 12701 ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM as it is connect (master_1_another, localhost, root, , auto_test_local, $MASTER_1_MYPORT, $MASTER_1_MYSOCK);
# the last failure. Nevertheless, this contrived test is needed to SET DEBUG_SYNC='spider_set_lock_wait_timeout_before_query SIGNAL ready WAIT_FOR go';
# cover the error reporting when setting lock wait timeout, until we send insert into t2 values (42);
# find a better one and/or fixing the non-deterministic error connection master_1;
# reporting SET DEBUG_SYNC='now WAIT_FOR ready';
--error 12701,ER_NET_READ_ERROR,ER_NET_ERROR_ON_WRITE,ER_XAER_DUPID
INSERT INTO t VALUES (1,2,3),(4,5,6),(7,8,9); connection child2_1;
--disable_result_log let $shutdown_timeout=0;
--error 0,12701,ER_XAER_DUPID --source include/shutdown_mysqld.inc
SELECT * FROM information_schema.key_column_usage;
--enable_result_log connection master_1;
SET DEBUG_SYNC='now SIGNAL go';
connection master_1_another;
--error ER_CONNECT_TO_FOREIGN_DATA_SOURCE
reap;
XA END 'a'; # Cleanup
XA PREPARE 'a'; connection master_1;
XA COMMIT 'a'; DROP DATABASE IF EXISTS auto_test_local;
SET GLOBAL wait_timeout=@old_wait_timeout;
drop table t; connection child2_1;
--source include/start_mysqld.inc
connection child2_1;
DROP DATABASE IF EXISTS auto_test_remote;
--disable_query_log --disable_query_log
--disable_result_log --disable_result_log
--source ../../t/test_deinit.inc --source ../t/test_deinit.inc
--enable_result_log
--enable_query_log --enable_query_log
--enable_result_log
--echo #
--echo # end test
--echo #
...@@ -13429,7 +13429,7 @@ int spider_mbase_handler::sts_mode_exchange( ...@@ -13429,7 +13429,7 @@ int spider_mbase_handler::sts_mode_exchange(
static int spider_set_lock_wait_timeout(uint seconds, SPIDER_CONN *conn, static int spider_set_lock_wait_timeout(uint seconds, SPIDER_CONN *conn,
int *need_mon) int *need_mon)
{ {
char query[512];; char query[512];
int error_num; int error_num;
DBUG_ENTER("spider_db_set_lock_wait_timeout"); DBUG_ENTER("spider_db_set_lock_wait_timeout");
size_t query_len = size_t query_len =
...@@ -13437,6 +13437,7 @@ static int spider_set_lock_wait_timeout(uint seconds, SPIDER_CONN *conn, ...@@ -13437,6 +13437,7 @@ static int spider_set_lock_wait_timeout(uint seconds, SPIDER_CONN *conn,
"set @old_lock_wait_timeout=@@session.lock_wait_timeout;" "set @old_lock_wait_timeout=@@session.lock_wait_timeout;"
"set session lock_wait_timeout=%d;", "set session lock_wait_timeout=%d;",
seconds); seconds);
DEBUG_SYNC(conn->thd, "spider_set_lock_wait_timeout_before_query");
if (spider_db_query(conn, query, query_len, -1, need_mon)) if (spider_db_query(conn, query, query_len, -1, need_mon))
DBUG_RETURN(spider_db_errorno(conn)); DBUG_RETURN(spider_db_errorno(conn));
spider_db_result *result; spider_db_result *result;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment