Skip to content

Commit

Permalink
MDEV-26539 SIGSEGV in spider_check_and_set_trx_isolation and I_P_List…
Browse files Browse the repository at this point in the history
…_iterator from THD::drop_temporary_table (10.5.3 opt only) on ALTER

The server crashes if ALTER TABLE, which accesses physical data
placed at data nodes, is performed on a Spider table.

The cause of the bug is that spider_check_trx_and_get_conn() does
not allocate connections if sql_command == SQLCOM_ALTER_TABLE.
Some ALTER TABLE statements, like ALTER TABLE ... CHECK PARTITION,
access data nodes. So, we need to allocate a new connection before
performing ALTER TABLEs.
  • Loading branch information
nayuta-yanagisawa committed Oct 18, 2021
1 parent 052dda6 commit 9068020
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 4 deletions.
36 changes: 36 additions & 0 deletions storage/spider/mysql-test/spider/bugfix/r/mdev_26539.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
for master_1
for child2
child2_1
child2_2
child2_3
for child3
#
# MDEV-26539 SIGSEGV in spider_check_and_set_trx_isolation and I_P_List_iterator from THD::drop_temporary_table (10.5.3 opt only) on ALTER
#
connection child2_1;
CREATE DATABASE auto_test_remote;
USE auto_test_remote;
CREATE TABLE tbl_a (
c INT
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
connection master_1;
CREATE DATABASE auto_test_local;
USE auto_test_local;
CREATE TABLE tbl_a (
c INT
) ENGINE=Spider DEFAULT CHARSET=utf8 COMMENT='table "tbl_a"' PARTITION BY LIST COLUMNS (c) (
PARTITION pt1 DEFAULT COMMENT = 'srv "s_2_1"'
);
INSERT INTO tbl_a VALUES (1);
ALTER TABLE tbl_a CHECK PARTITION ALL;
Table Op Msg_type Msg_text
auto_test_local.tbl_a check status OK
DROP DATABASE auto_test_local;
connection child2_1;
DROP DATABASE auto_test_remote;
for master_1
for child2
child2_1
child2_2
child2_3
for child3
3 changes: 3 additions & 0 deletions storage/spider/mysql-test/spider/bugfix/t/mdev_26539.cnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
!include include/default_mysqld.cnf
!include ../my_1_1.cnf
!include ../my_2_1.cnf
40 changes: 40 additions & 0 deletions storage/spider/mysql-test/spider/bugfix/t/mdev_26539.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
--disable_query_log
--disable_result_log
--source ../../t/test_init.inc
--enable_result_log
--enable_query_log

--echo #
--echo # MDEV-26539 SIGSEGV in spider_check_and_set_trx_isolation and I_P_List_iterator from THD::drop_temporary_table (10.5.3 opt only) on ALTER
--echo #

--connection child2_1
CREATE DATABASE auto_test_remote;
USE auto_test_remote;
eval CREATE TABLE tbl_a (
c INT
) $CHILD2_1_ENGINE $CHILD2_1_CHARSET;

--connection master_1
CREATE DATABASE auto_test_local;
USE auto_test_local;

eval CREATE TABLE tbl_a (
c INT
) $MASTER_1_ENGINE $MASTER_1_CHARSET COMMENT='table "tbl_a"' PARTITION BY LIST COLUMNS (c) (
PARTITION pt1 DEFAULT COMMENT = 'srv "s_2_1"'
);

INSERT INTO tbl_a VALUES (1);
ALTER TABLE tbl_a CHECK PARTITION ALL;

DROP DATABASE auto_test_local;

--connection child2_1
DROP DATABASE auto_test_remote;

--disable_query_log
--disable_result_log
--source ../../t/test_deinit.inc
--enable_result_log
--enable_query_log
6 changes: 2 additions & 4 deletions storage/spider/spd_trx.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3744,10 +3744,8 @@ int spider_check_trx_and_get_conn(
}
spider->wide_handler->trx = trx;
spider->set_error_mode();
if (
spider->wide_handler->sql_command != SQLCOM_DROP_TABLE &&
spider->wide_handler->sql_command != SQLCOM_ALTER_TABLE
) {
if (spider->wide_handler->sql_command != SQLCOM_DROP_TABLE)
{
SPIDER_TRX_HA *trx_ha = spider_check_trx_ha(trx, spider);
if (!trx_ha || trx_ha->wait_for_reusing)
spider_trx_set_link_idx_for_all(spider);
Expand Down

0 comments on commit 9068020

Please sign in to comment.