summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKentoku SHIBA <kentokushiba@gmail.com>2020-04-17 01:49:46 +0900
committerKentoku SHIBA <kentokushiba@gmail.com>2020-04-17 01:49:46 +0900
commit619a2ccd67813b98a92983fca70a93a8d32b9abe (patch)
tree3fd3d32baa529fca096b365aaa6b651a0220cb0d
parentb092d35f13ceae37cda26478635b127f9b401e2c (diff)
downloadmariadb-git-bb-10.3-MDEV-21884.tar.gz
MDEV-21884 MariaDB with Spider crashes on a querybb-10.3-MDEV-21884
-rw-r--r--storage/spider/mysql-test/spider/bugfix/include/mdev_21884_deinit.inc14
-rw-r--r--storage/spider/mysql-test/spider/bugfix/include/mdev_21884_init.inc57
-rw-r--r--storage/spider/mysql-test/spider/bugfix/r/mdev_21884.result107
-rw-r--r--storage/spider/mysql-test/spider/bugfix/t/mdev_21884.cnf3
-rw-r--r--storage/spider/mysql-test/spider/bugfix/t/mdev_21884.test97
-rw-r--r--storage/spider/spd_db_conn.cc15
6 files changed, 293 insertions, 0 deletions
diff --git a/storage/spider/mysql-test/spider/bugfix/include/mdev_21884_deinit.inc b/storage/spider/mysql-test/spider/bugfix/include/mdev_21884_deinit.inc
new file mode 100644
index 00000000000..74efe3a274c
--- /dev/null
+++ b/storage/spider/mysql-test/spider/bugfix/include/mdev_21884_deinit.inc
@@ -0,0 +1,14 @@
+--let $MASTER_1_COMMENT_2_1= $MASTER_1_COMMENT_2_1_BACKUP
+--let $CHILD2_1_DROP_TABLES= $CHILD2_1_DROP_TABLES_BACKUP
+--let $CHILD2_1_CREATE_TABLES= $CHILD2_1_CREATE_TABLES_BACKUP
+--let $CHILD2_1_SELECT_TABLES= $CHILD2_1_SELECT_TABLES_BACKUP
+--connection master_1
+set session spider_bgs_mode= @old_spider_bgs_mode;
+set session spider_quick_mode= @old_spider_quick_mode;
+--disable_warnings
+--disable_query_log
+--disable_result_log
+--source ../t/test_deinit.inc
+--enable_result_log
+--enable_query_log
+--enable_warnings
diff --git a/storage/spider/mysql-test/spider/bugfix/include/mdev_21884_init.inc b/storage/spider/mysql-test/spider/bugfix/include/mdev_21884_init.inc
new file mode 100644
index 00000000000..25455ffcdf1
--- /dev/null
+++ b/storage/spider/mysql-test/spider/bugfix/include/mdev_21884_init.inc
@@ -0,0 +1,57 @@
+--disable_warnings
+--disable_query_log
+--disable_result_log
+--source ../t/test_init.inc
+--enable_result_log
+--enable_query_log
+--enable_warnings
+--let $MASTER_1_COMMENT_2_1_BACKUP= $MASTER_1_COMMENT_2_1
+let $MASTER_1_COMMENT_2_1=
+ COMMENT='table "tbl_a", srv "s_2_1"';
+--let $MASTER_1_COMMENT_P_2_1_BACKUP= $MASTER_1_COMMENT_P_2_1
+let $MASTER_1_COMMENT_P_2_1=
+ COMMENT='table "ta_r3"'
+ PARTITION BY RANGE(a) (
+ PARTITION pt1 VALUES LESS THAN (10) COMMENT='srv "s_2_1", table "ta_r2",
+ priority "1000"',
+ PARTITION pt2 VALUES LESS THAN MAXVALUE COMMENT='srv "s_2_1", priority "1000001"'
+ );
+--let $CHILD2_1_DROP_TABLES_BACKUP= $CHILD2_1_DROP_TABLES
+let $CHILD2_1_DROP_TABLES=
+ DROP TABLE IF EXISTS tbl_a;
+let $CHILD2_1_DROP_TABLES=
+ DROP TABLE IF EXISTS ta_r2 $STR_SEMICOLON
+ DROP TABLE IF EXISTS ta_r3;
+--let $CHILD2_1_CREATE_TABLES_BACKUP= $CHILD2_1_CREATE_TABLES
+let $CHILD2_1_CREATE_TABLES=
+ CREATE TABLE tbl_a (
+ pkey int NOT NULL,
+ txt char(8) NOT NULL,
+ PRIMARY KEY (pkey, txt)
+ ) $CHILD2_1_ENGINE DEFAULT CHARACTER SET utf8;
+let $CHILD2_1_CREATE_TABLES=
+ CREATE TABLE ta_r2 (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a,b)
+ ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET $STR_SEMICOLON
+ CREATE TABLE ta_r3 (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a,b)
+ ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET;
+--let $CHILD2_1_SELECT_TABLES_BACKUP= $CHILD2_1_SELECT_TABLES
+let $CHILD2_1_SELECT_TABLES=
+ SELECT pkey, txt FROM tbl_a ORDER BY pkey;
+let $CHILD2_1_SELECT_TABLES=
+ SELECT a, b, c FROM ta_r2 ORDER BY a $STR_SEMICOLON
+ SELECT a, b, c FROM ta_r3 ORDER BY a;
+let $CHILD2_1_SELECT_ARGUMENT1=
+ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+--connection master_1
+set @old_spider_bgs_mode= @@spider_bgs_mode;
+set session spider_bgs_mode= 2;
+set @old_spider_quick_mode= @@spider_quick_mode;
+set session spider_quick_mode= 3;
diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_21884.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_21884.result
new file mode 100644
index 00000000000..921744f7f76
--- /dev/null
+++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_21884.result
@@ -0,0 +1,107 @@
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+connection master_1;
+set @old_spider_bgs_mode= @@spider_bgs_mode;
+set session spider_bgs_mode= 2;
+set @old_spider_quick_mode= @@spider_quick_mode;
+set session spider_quick_mode= 3;
+
+this test is for MDEV-21884
+
+drop and create databases
+connection master_1;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+connection child2_1;
+SET @old_log_output = @@global.log_output;
+SET GLOBAL log_output = 'TABLE,FILE';
+CREATE DATABASE auto_test_remote;
+USE auto_test_remote;
+
+create table and insert
+connection child2_1;
+CHILD2_1_CREATE_TABLES
+TRUNCATE TABLE mysql.general_log;
+connection master_1;
+CREATE TABLE tbl_a (
+a INT,
+b CHAR(1),
+c DATETIME,
+PRIMARY KEY(a,b)
+) ENGINE=Spider COMMENT='table "ta_r3"'
+ PARTITION BY RANGE(a) (
+PARTITION pt1 VALUES LESS THAN (10) COMMENT='srv "s_2_1", table "ta_r2",
+ priority "1000"',
+PARTITION pt2 VALUES LESS THAN MAXVALUE COMMENT='srv "s_2_1", priority "1000001"'
+ )
+CREATE TABLE tb_l (
+a INT,
+b CHAR(1),
+c DATETIME,
+PRIMARY KEY(a)
+) MASTER_1_ENGINE2 MASTER_1_CHARSET2
+INSERT INTO tbl_a (a, b, c) VALUES
+(11, 'a', '2008-08-01 10:21:39'),
+(11, 'b', '2000-01-01 00:00:00'),
+(12, 'e', '2007-06-04 20:03:11'),
+(12, 'd', '2003-11-30 05:01:03'),
+(13, 'c', '2001-12-31 23:59:59');
+INSERT INTO tb_l (a, b, c) VALUES
+(11, 'a', '2008-08-01 10:21:39'),
+(12, 'b', '2000-01-01 00:00:00'),
+(13, 'e', '2007-06-04 20:03:11'),
+(14, 'd', '2003-11-30 05:01:03'),
+(15, 'c', '2001-12-31 23:59:59');
+
+test 1
+connection child2_1;
+TRUNCATE TABLE mysql.general_log;
+connection master_1;
+SELECT STRAIGHT_JOIN b.a, b.b FROM tb_l a, tbl_a b WHERE a.a = b.a;
+a b
+11 a
+11 b
+12 d
+12 e
+13 c
+connection child2_1;
+SET NAMES utf8;
+SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
+argument
+select `a`,`b` from `auto_test_remote`.`ta_r3` where `a` = 11 order by `b`
+select `a`,`b` from `auto_test_remote`.`ta_r3` where `a` = 12 order by `b`
+select `a`,`b` from `auto_test_remote`.`ta_r3` where `a` = 13 order by `b`
+select `a`,`b` from `auto_test_remote`.`ta_r3` where `a` = 14 order by `b`
+select `a`,`b` from `auto_test_remote`.`ta_r3` where `a` = 15 order by `b`
+SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'
+SELECT a, b, c FROM ta_r2 ORDER BY a ;
+SELECT a, b, c FROM ta_r3 ORDER BY a;
+a b c
+a b c
+11 a 2008-08-01 10:21:39
+11 b 2000-01-01 00:00:00
+12 d 2003-11-30 05:01:03
+12 e 2007-06-04 20:03:11
+13 c 2001-12-31 23:59:59
+
+deinit
+connection master_1;
+DROP DATABASE IF EXISTS auto_test_local;
+connection child2_1;
+DROP DATABASE IF EXISTS auto_test_remote;
+SET GLOBAL log_output = @old_log_output;
+connection master_1;
+set session spider_bgs_mode= @old_spider_bgs_mode;
+set session spider_quick_mode= @old_spider_quick_mode;
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+
+end of test
diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_21884.cnf b/storage/spider/mysql-test/spider/bugfix/t/mdev_21884.cnf
new file mode 100644
index 00000000000..05dfd8a0bce
--- /dev/null
+++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_21884.cnf
@@ -0,0 +1,3 @@
+!include include/default_mysqld.cnf
+!include ../my_1_1.cnf
+!include ../my_2_1.cnf
diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_21884.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_21884.test
new file mode 100644
index 00000000000..be4aa6a6330
--- /dev/null
+++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_21884.test
@@ -0,0 +1,97 @@
+--source ../include/mdev_21884_init.inc
+--echo
+--echo this test is for MDEV-21884
+--echo
+--echo drop and create databases
+
+--connection master_1
+--disable_warnings
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+
+--connection child2_1
+SET @old_log_output = @@global.log_output;
+SET GLOBAL log_output = 'TABLE,FILE';
+CREATE DATABASE auto_test_remote;
+USE auto_test_remote;
+--enable_warnings
+
+--echo
+--echo create table and insert
+
+--connection child2_1
+--disable_query_log
+echo CHILD2_1_CREATE_TABLES;
+eval $CHILD2_1_CREATE_TABLES;
+--enable_query_log
+TRUNCATE TABLE mysql.general_log;
+
+--connection master_1
+--disable_query_log
+echo CREATE TABLE tbl_a (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a,b)
+) $MASTER_1_ENGINE $MASTER_1_COMMENT_P_2_1;
+eval CREATE TABLE tbl_a (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a,b)
+) $MASTER_1_ENGINE $MASTER_1_COMMENT_P_2_1;
+echo CREATE TABLE tb_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+) MASTER_1_ENGINE2 MASTER_1_CHARSET2;
+eval CREATE TABLE tb_l (
+ a INT,
+ b CHAR(1),
+ c DATETIME,
+ PRIMARY KEY(a)
+) $MASTER_1_ENGINE2 $MASTER_1_CHARSET2;
+--enable_query_log
+INSERT INTO tbl_a (a, b, c) VALUES
+ (11, 'a', '2008-08-01 10:21:39'),
+ (11, 'b', '2000-01-01 00:00:00'),
+ (12, 'e', '2007-06-04 20:03:11'),
+ (12, 'd', '2003-11-30 05:01:03'),
+ (13, 'c', '2001-12-31 23:59:59');
+INSERT INTO tb_l (a, b, c) VALUES
+ (11, 'a', '2008-08-01 10:21:39'),
+ (12, 'b', '2000-01-01 00:00:00'),
+ (13, 'e', '2007-06-04 20:03:11'),
+ (14, 'd', '2003-11-30 05:01:03'),
+ (15, 'c', '2001-12-31 23:59:59');
+
+--echo
+--echo test 1
+
+--connection child2_1
+TRUNCATE TABLE mysql.general_log;
+
+--connection master_1
+SELECT STRAIGHT_JOIN b.a, b.b FROM tb_l a, tbl_a b WHERE a.a = b.a;
+
+--connection child2_1
+SET NAMES utf8;
+eval $CHILD2_1_SELECT_ARGUMENT1;
+eval $CHILD2_1_SELECT_TABLES;
+
+--echo
+--echo deinit
+--disable_warnings
+
+--connection master_1
+DROP DATABASE IF EXISTS auto_test_local;
+
+--connection child2_1
+DROP DATABASE IF EXISTS auto_test_remote;
+SET GLOBAL log_output = @old_log_output;
+
+--enable_warnings
+--source ../include/mdev_21884_deinit.inc
+--echo
+--echo end of test
diff --git a/storage/spider/spd_db_conn.cc b/storage/spider/spd_db_conn.cc
index cc4599ce0b3..bf576f2359e 100644
--- a/storage/spider/spd_db_conn.cc
+++ b/storage/spider/spd_db_conn.cc
@@ -2945,6 +2945,11 @@ int spider_db_fetch_table(
} else {
if (result_list->current_row_num < result_list->quick_page_size)
{
+ if (!current->first_position)
+ {
+ table->status = STATUS_NOT_FOUND;
+ DBUG_RETURN(HA_ERR_END_OF_FILE);
+ }
row = current->first_position[result_list->current_row_num].row;
} else {
if ((error_num = spider_db_get_row_from_tmp_tbl(
@@ -3143,6 +3148,11 @@ int spider_db_fetch_key(
} else {
if (result_list->current_row_num < result_list->quick_page_size)
{
+ if (!current->first_position)
+ {
+ table->status = STATUS_NOT_FOUND;
+ DBUG_RETURN(HA_ERR_END_OF_FILE);
+ }
row = current->first_position[result_list->current_row_num].row;
} else {
if ((error_num = spider_db_get_row_from_tmp_tbl(
@@ -3253,6 +3263,11 @@ int spider_db_fetch_minimum_columns(
{
DBUG_PRINT("info", ("spider current=%p", current));
DBUG_PRINT("info", ("spider first_position=%p", current->first_position));
+ if (!current->first_position)
+ {
+ table->status = STATUS_NOT_FOUND;
+ DBUG_RETURN(HA_ERR_END_OF_FILE);
+ }
DBUG_PRINT("info", ("spider current_row_num=%lld", result_list->current_row_num));
DBUG_PRINT("info", ("spider first_position[]=%p", &current->first_position[result_list->current_row_num]));
row = current->first_position[result_list->current_row_num].row;