Commit fa7051c4 authored by Kentoku SHIBA's avatar Kentoku SHIBA Committed by GitHub

MDEV-19842 Crash while creating statistics for Spider table (#1355)

Added checks of the number of columns of the system tables.
Move install_spider.sql into source code except installing Spider
parent 4a739d76
--connection master_1
alter table mysql.spider_table_sts add column checksum bigint unsigned default null after update_time;
DROP DATABASE IF EXISTS auto_test_local;
--let $MASTER_1_COMMENT_2_1= $MASTER_1_COMMENT_2_1_BACKUP
--disable_warnings
--disable_query_log
--disable_result_log
--source ../t/test_deinit.inc
--enable_result_log
--enable_query_log
--enable_warnings
--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", host "127.0.0.1", port "$MASTER_1_MYPORT", user "root"';
--connection master_1
alter table mysql.spider_table_sts drop column checksum;
insert into mysql.spider_table_sts values ('auto_test_local', 'tbl_a', 0, 0, 0, 0, 0, '2019-01-01 00:00:00', '2019-01-01 00:00:00', '2019-01-01 00:00:00');
for master_1
for child2
for child3
connection master_1;
alter table mysql.spider_table_sts drop column checksum;
insert into mysql.spider_table_sts values ('auto_test_local', 'tbl_a', 0, 0, 0, 0, 0, '2019-01-01 00:00:00', '2019-01-01 00:00:00', '2019-01-01 00:00:00');
this test is for MDEV-19842
drop and create databases
connection master_1;
CREATE DATABASE auto_test_local;
USE auto_test_local;
create table
connection master_1;
CREATE TABLE tbl_a (
pkey int NOT NULL,
PRIMARY KEY (pkey)
) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1
select test 1
connection master_1;
SELECT pkey FROM tbl_a;
ERROR HY000: System table spider_table_sts is different version
deinit
connection master_1;
DROP DATABASE IF EXISTS auto_test_local;
ERROR HY000: System table spider_table_sts is different version
connection master_1;
alter table mysql.spider_table_sts add column checksum bigint unsigned default null after update_time;
DROP DATABASE IF EXISTS auto_test_local;
for master_1
for child2
for child3
end of test
!include include/default_mysqld.cnf
!include ../my_1_1.cnf
--source ../include/spider_table_sts_init.inc
--echo
--echo this test is for MDEV-19842
--echo
--echo drop and create databases
--connection master_1
--disable_warnings
CREATE DATABASE auto_test_local;
USE auto_test_local;
--enable_warnings
--echo
--echo create table
--connection master_1
--disable_query_log
echo CREATE TABLE tbl_a (
pkey int NOT NULL,
PRIMARY KEY (pkey)
) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1;
eval CREATE TABLE tbl_a (
pkey int NOT NULL,
PRIMARY KEY (pkey)
) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1;
--enable_query_log
--echo
--echo select test 1
--connection master_1
--error 12609
SELECT pkey FROM tbl_a;
--echo
--echo deinit
--disable_warnings
--connection master_1
--error 12609
DROP DATABASE IF EXISTS auto_test_local;
--enable_warnings
--source ../include/spider_table_sts_deinit.inc
--echo
--echo end of test
DROP FUNCTION spider_direct_sql;
DROP FUNCTION spider_bg_direct_sql;
DROP FUNCTION spider_ping_table;
DROP FUNCTION spider_copy_tables;
let $SERVER_NAME=
`SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(version(), '-', 2), '-', -1)`;
let $SERVER_MAJOR_VERSION=
`SELECT SUBSTRING_INDEX(version(), '.', 1)`;
let $SERVER_MINOR_VERSION=
`SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(version(), '.', 2), '.', -1)`;
let $PLUGIN_VERSION=
`SELECT SUBSTRING_INDEX(plugin_version, '.', 1)
FROM information_schema.plugins
WHERE plugin_name = 'SPIDER'`;
if (`SELECT IF($PLUGIN_VERSION = 3, 1, 0)`)
{
let $HAS_REWRITE=
`SELECT IF (STRCMP('$SERVER_NAME', 'MariaDB') = 0,
IF ($SERVER_MAJOR_VERSION = 10,
IF ($SERVER_MINOR_VERSION < 4, 0, 1),
IF ($SERVER_MAJOR_VERSION < 10, 0, 1)),
0)`;
let $HAS_REWRITE= 0;
if ($HAS_REWRITE)
{
DROP FUNCTION spider_flush_rewrite_cache;
UNINSTALL PLUGIN spider_rewrite;
DROP TABLE IF EXISTS mysql.spider_rewrite_tables;
DROP TABLE IF EXISTS mysql.spider_rewrite_table_tables;
DROP TABLE IF EXISTS mysql.spider_rewrite_table_partitions;
DROP TABLE IF EXISTS mysql.spider_rewrite_table_subpartitions;
DROP TABLE IF EXISTS mysql.spider_rewritten_tables;
}
}
DROP FUNCTION spider_flush_table_mon_cache;
DROP FUNCTION spider_copy_tables;
DROP FUNCTION spider_ping_table;
DROP FUNCTION spider_bg_direct_sql;
DROP FUNCTION spider_direct_sql;
UNINSTALL PLUGIN spider_alloc_mem;
UNINSTALL PLUGIN spider;
DROP TABLE IF EXISTS mysql.spider_xa;
DROP TABLE IF EXISTS mysql.spider_xa_member;
......@@ -13,9 +44,57 @@ DROP TABLE IF EXISTS mysql.spider_link_failed_log;
DROP TABLE IF EXISTS mysql.spider_table_position_for_recovery;
DROP TABLE IF EXISTS mysql.spider_table_sts;
DROP TABLE IF EXISTS mysql.spider_table_crd;
DROP SERVER s_2_1;
DROP SERVER s_2_2;
DROP SERVER s_2_3;
DROP SERVER s_3_1;
DROP SERVER s_3_2;
DROP SERVER s_3_3;
if ($VERSION_COMPILE_OS_WIN)
{
if ($CHILD2_1_MYPORT)
{
DROP SERVER s_2_1;
}
if ($CHILD2_2_MYPORT)
{
DROP SERVER s_2_2;
}
if ($CHILD2_3_MYPORT)
{
DROP SERVER s_2_3;
}
if ($CHILD3_1_MYPORT)
{
DROP SERVER s_3_1;
}
if ($CHILD3_2_MYPORT)
{
DROP SERVER s_3_2;
}
if ($CHILD2_3_MYPORT)
{
DROP SERVER s_3_3;
}
}
if (!$VERSION_COMPILE_OS_WIN)
{
if ($CHILD2_1_MYSOCK)
{
DROP SERVER s_2_1;
}
if ($CHILD2_2_MYSOCK)
{
DROP SERVER s_2_2;
}
if ($CHILD2_3_MYSOCK)
{
DROP SERVER s_2_3;
}
if ($CHILD3_1_MYSOCK)
{
DROP SERVER s_3_1;
}
if ($CHILD3_2_MYSOCK)
{
DROP SERVER s_3_2;
}
if ($CHILD3_3_MYSOCK)
{
DROP SERVER s_3_3;
}
}
This diff is collapsed.
......@@ -292,6 +292,7 @@ typedef struct st_spider_thread
volatile bool killed;
volatile bool thd_wait;
volatile bool first_free_wait;
volatile bool init_command;
pthread_t thread;
pthread_cond_t cond;
pthread_mutex_t mutex;
......
This diff is collapsed.
This diff is collapsed.
/* Copyright (C) 2008-2018 Kentoku Shiba
/* Copyright (C) 2008-2019 Kentoku Shiba
Copyright (C) 2019 MariaDB corp
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -14,23 +15,33 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */
#define SPIDER_SYS_XA_TABLE_NAME_STR "spider_xa"
#define SPIDER_SYS_XA_TABLE_NAME_LEN (sizeof(SPIDER_SYS_XA_TABLE_NAME_STR) - 1)
#define SPIDER_SYS_XA_TABLE_NAME_LEN 9
#define SPIDER_SYS_XA_MEMBER_TABLE_NAME_STR "spider_xa_member"
#define SPIDER_SYS_XA_MEMBER_TABLE_NAME_LEN (sizeof(SPIDER_SYS_XA_MEMBER_TABLE_NAME_STR) - 1)
#define SPIDER_SYS_XA_MEMBER_TABLE_NAME_LEN 16
#define SPIDER_SYS_TABLES_TABLE_NAME_STR "spider_tables"
#define SPIDER_SYS_TABLES_TABLE_NAME_LEN (sizeof(SPIDER_SYS_TABLES_TABLE_NAME_STR) - 1)
#define SPIDER_SYS_TABLES_TABLE_NAME_LEN 13
#define SPIDER_SYS_LINK_MON_TABLE_NAME_STR "spider_link_mon_servers"
#define SPIDER_SYS_LINK_MON_TABLE_NAME_LEN (sizeof(SPIDER_SYS_LINK_MON_TABLE_NAME_STR) - 1)
#define SPIDER_SYS_LINK_MON_TABLE_NAME_LEN 23
#define SPIDER_SYS_LINK_FAILED_TABLE_NAME_STR "spider_link_failed_log"
#define SPIDER_SYS_LINK_FAILED_TABLE_NAME_LEN (sizeof(SPIDER_SYS_LINK_FAILED_TABLE_NAME_STR) - 1)
#define SPIDER_SYS_LINK_FAILED_TABLE_NAME_LEN 22
#define SPIDER_SYS_XA_FAILED_TABLE_NAME_STR "spider_xa_failed_log"
#define SPIDER_SYS_XA_FAILED_TABLE_NAME_LEN (sizeof(SPIDER_SYS_XA_FAILED_TABLE_NAME_STR) - 1)
#define SPIDER_SYS_XA_FAILED_TABLE_NAME_LEN 20
#define SPIDER_SYS_POS_FOR_RECOVERY_TABLE_NAME_STR "spider_table_position_for_recovery"
#define SPIDER_SYS_POS_FOR_RECOVERY_TABLE_NAME_LEN (sizeof(SPIDER_SYS_POS_FOR_RECOVERY_TABLE_NAME_STR) - 1)
#define SPIDER_SYS_POS_FOR_RECOVERY_TABLE_NAME_LEN 34
#define SPIDER_SYS_TABLE_STS_TABLE_NAME_STR "spider_table_sts"
#define SPIDER_SYS_TABLE_STS_TABLE_NAME_LEN (sizeof(SPIDER_SYS_TABLE_STS_TABLE_NAME_STR) - 1)
#define SPIDER_SYS_TABLE_STS_TABLE_NAME_LEN 16
#define SPIDER_SYS_TABLE_CRD_TABLE_NAME_STR "spider_table_crd"
#define SPIDER_SYS_TABLE_CRD_TABLE_NAME_LEN (sizeof(SPIDER_SYS_TABLE_CRD_TABLE_NAME_STR) - 1)
#define SPIDER_SYS_TABLE_CRD_TABLE_NAME_LEN 16
#define SPIDER_SYS_RW_TBLS_TABLE_NAME_STR "spider_rewrite_tables"
#define SPIDER_SYS_RW_TBLS_TABLE_NAME_LEN 21
#define SPIDER_SYS_RW_TBL_TBLS_TABLE_NAME_STR "spider_rewrite_table_tables"
#define SPIDER_SYS_RW_TBL_TBLS_TABLE_NAME_LEN 27
#define SPIDER_SYS_RW_TBL_PTTS_TABLE_NAME_STR "spider_rewrite_table_partitions"
#define SPIDER_SYS_RW_TBL_PTTS_TABLE_NAME_LEN 31
#define SPIDER_SYS_RW_TBL_SPTTS_TABLE_NAME_STR "spider_rewrite_table_subpartitions"
#define SPIDER_SYS_RW_TBL_SPTTS_TABLE_NAME_LEN 34
#define SPIDER_SYS_RWN_TBLS_TABLE_NAME_STR "spider_rewritten_tables"
#define SPIDER_SYS_RWN_TBLS_TABLE_NAME_LEN 23
#define SPIDER_SYS_XA_PREPARED_STR "PREPARED"
#define SPIDER_SYS_XA_NOT_YET_STR "NOT YET"
......@@ -47,11 +58,18 @@
#define SPIDER_SYS_TABLES_IDX1_COL_CNT 1
#define SPIDER_SYS_TABLES_UIDX1_COL_CNT 3
#define SPIDER_SYS_LINK_MON_TABLE_COL_CNT 19
#define SPIDER_SYS_LINK_FAILED_TABLE_COL_CNT 4
#define SPIDER_SYS_XA_FAILED_TABLE_COL_CNT 21
#define SPIDER_SYS_POS_FOR_RECOVERY_TABLE_COL_CNT 7
#define SPIDER_SYS_TABLE_STS_COL_CNT 10
#define SPIDER_SYS_TABLE_STS_COL_CNT 11
#define SPIDER_SYS_TABLE_STS_PK_COL_CNT 2
#define SPIDER_SYS_TABLE_CRD_COL_CNT 4
#define SPIDER_SYS_TABLE_CRD_PK_COL_CNT 3
#define SPIDER_SYS_RW_TBLS_COL_CNT 3
#define SPIDER_SYS_RW_TBL_TBLS_COL_CNT 8
#define SPIDER_SYS_RW_TBL_PTTS_COL_CNT 7
#define SPIDER_SYS_RW_TBL_SPTTS_COL_CNT 8
#define SPIDER_SYS_RWN_TBLS_COL_CNT 4
#define SPIDER_SYS_LINK_MON_TABLE_DB_NAME_SIZE 64
#define SPIDER_SYS_LINK_MON_TABLE_TABLE_NAME_SIZE 64
......
This diff is collapsed.
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