Skip to content

Commit 9068020

Browse files
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
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.
1 parent 052dda6 commit 9068020

File tree

4 files changed

+81
-4
lines changed

4 files changed

+81
-4
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
for master_1
2+
for child2
3+
child2_1
4+
child2_2
5+
child2_3
6+
for child3
7+
#
8+
# 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
9+
#
10+
connection child2_1;
11+
CREATE DATABASE auto_test_remote;
12+
USE auto_test_remote;
13+
CREATE TABLE tbl_a (
14+
c INT
15+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
16+
connection master_1;
17+
CREATE DATABASE auto_test_local;
18+
USE auto_test_local;
19+
CREATE TABLE tbl_a (
20+
c INT
21+
) ENGINE=Spider DEFAULT CHARSET=utf8 COMMENT='table "tbl_a"' PARTITION BY LIST COLUMNS (c) (
22+
PARTITION pt1 DEFAULT COMMENT = 'srv "s_2_1"'
23+
);
24+
INSERT INTO tbl_a VALUES (1);
25+
ALTER TABLE tbl_a CHECK PARTITION ALL;
26+
Table Op Msg_type Msg_text
27+
auto_test_local.tbl_a check status OK
28+
DROP DATABASE auto_test_local;
29+
connection child2_1;
30+
DROP DATABASE auto_test_remote;
31+
for master_1
32+
for child2
33+
child2_1
34+
child2_2
35+
child2_3
36+
for child3
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
!include include/default_mysqld.cnf
2+
!include ../my_1_1.cnf
3+
!include ../my_2_1.cnf
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
--disable_query_log
2+
--disable_result_log
3+
--source ../../t/test_init.inc
4+
--enable_result_log
5+
--enable_query_log
6+
7+
--echo #
8+
--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
9+
--echo #
10+
11+
--connection child2_1
12+
CREATE DATABASE auto_test_remote;
13+
USE auto_test_remote;
14+
eval CREATE TABLE tbl_a (
15+
c INT
16+
) $CHILD2_1_ENGINE $CHILD2_1_CHARSET;
17+
18+
--connection master_1
19+
CREATE DATABASE auto_test_local;
20+
USE auto_test_local;
21+
22+
eval CREATE TABLE tbl_a (
23+
c INT
24+
) $MASTER_1_ENGINE $MASTER_1_CHARSET COMMENT='table "tbl_a"' PARTITION BY LIST COLUMNS (c) (
25+
PARTITION pt1 DEFAULT COMMENT = 'srv "s_2_1"'
26+
);
27+
28+
INSERT INTO tbl_a VALUES (1);
29+
ALTER TABLE tbl_a CHECK PARTITION ALL;
30+
31+
DROP DATABASE auto_test_local;
32+
33+
--connection child2_1
34+
DROP DATABASE auto_test_remote;
35+
36+
--disable_query_log
37+
--disable_result_log
38+
--source ../../t/test_deinit.inc
39+
--enable_result_log
40+
--enable_query_log

storage/spider/spd_trx.cc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3744,10 +3744,8 @@ int spider_check_trx_and_get_conn(
37443744
}
37453745
spider->wide_handler->trx = trx;
37463746
spider->set_error_mode();
3747-
if (
3748-
spider->wide_handler->sql_command != SQLCOM_DROP_TABLE &&
3749-
spider->wide_handler->sql_command != SQLCOM_ALTER_TABLE
3750-
) {
3747+
if (spider->wide_handler->sql_command != SQLCOM_DROP_TABLE)
3748+
{
37513749
SPIDER_TRX_HA *trx_ha = spider_check_trx_ha(trx, spider);
37523750
if (!trx_ha || trx_ha->wait_for_reusing)
37533751
spider_trx_set_link_idx_for_all(spider);

0 commit comments

Comments
 (0)