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