Skip to content

Commit 3f114a0

Browse files
MDEV-35046 SIGSEGV in list_delete in optimized builds when using pseudo_slave_mode
slave_applier_reset_xa_trans() should clear the THD::pseudo_thread_id when called to reset XA transaction state completely. Clearing when pseudo_thread_id models the binlog applier that handles BASE64-encoded events which possibly contain the pseudo_thread_id, allowing us to restore the pre-event's state of the connection's respective session var.
1 parent 41f54da commit 3f114a0

File tree

6 files changed

+47
-0
lines changed

6 files changed

+47
-0
lines changed

mysql-test/main/mdev-35046.result

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
SET pseudo_slave_mode=1;
2+
CREATE TABLE t1 (c INT) ENGINE=InnoDB;
3+
CREATE TABLE t2 (c INT) ENGINE=MEMORY;
4+
XA START 'a';
5+
INSERT INTO t1 VALUES (0);
6+
CREATE TEMPORARY TABLE t1t (c INT) ENGINE=InnoDB;
7+
INSERT INTO t1t VALUES (0);
8+
XA END 'a';
9+
XA PREPARE 'a';
10+
OPTIMIZE TABLE t1t;
11+
Table Op Msg_type Msg_text
12+
test.t1t optimize Error Table 'test.t1t' doesn't exist
13+
test.t1t optimize status Operation failed
14+
LOCK TABLE t2 READ;
15+
XA COMMIT 'a';
16+
# restart
17+
DROP TABLE t1, t2;

mysql-test/main/mdev-35046.test

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#
2+
# MDEV-35046 SIGSEGV in list_delete in optimized builds when using pseudo_slave_mode
3+
# https://jira.mariadb.org/browse/MDEV-35046
4+
#
5+
--source include/have_innodb.inc
6+
SET pseudo_slave_mode=1;
7+
CREATE TABLE t1 (c INT) ENGINE=InnoDB;
8+
CREATE TABLE t2 (c INT) ENGINE=MEMORY;
9+
XA START 'a';
10+
INSERT INTO t1 VALUES (0);
11+
CREATE TEMPORARY TABLE t1t (c INT) ENGINE=InnoDB;
12+
INSERT INTO t1t VALUES (0);
13+
XA END 'a';
14+
XA PREPARE 'a';
15+
OPTIMIZE TABLE t1t;
16+
LOCK TABLE t2 READ;
17+
XA COMMIT 'a';
18+
--source include/restart_mysqld.inc
19+
DROP TABLE t1, t2;

mysql-test/suite/rpl/r/rpl_xa.result

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ xa start 's';
2929
insert into t2 values (0);
3030
xa end 's';
3131
xa prepare 's';
32+
Warnings:
33+
Warning 4196 Pseudo thread id should not be modified by the client as it will be overwritten
3234
include/save_master_gtid.inc
3335
connection slave;
3436
include/sync_with_master_gtid.inc

mysql-test/suite/rpl/r/rpl_xa_gtid_pos_auto_engine.result

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ xa start 's';
3535
insert into t2 values (0);
3636
xa end 's';
3737
xa prepare 's';
38+
Warnings:
39+
Warning 4196 Pseudo thread id should not be modified by the client as it will be overwritten
3840
include/save_master_gtid.inc
3941
connection slave;
4042
include/sync_with_master_gtid.inc

sql/share/errmsg-utf8.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12270,3 +12270,5 @@ ER_JSON_SCHEMA_KEYWORD_UNSUPPORTED
1227012270
sw "%s neno kuu halitumiki"
1227112271
ER_JSON_NO_VARIABLE_SCHEMA
1227212272
eng "Variable schema is not supported."
12273+
ER_PSEUDO_THREAD_ID_OVERWRITE
12274+
eng "Pseudo thread id should not be modified by the client as it will be overwritten"

sql/xa.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,5 +1196,10 @@ static bool slave_applier_reset_xa_trans(THD *thd)
11961196
thd->has_waiter= false;
11971197
MYSQL_COMMIT_TRANSACTION(thd->m_transaction_psi); // TODO/Fixme: commit?
11981198
thd->m_transaction_psi= NULL;
1199+
if (thd->variables.pseudo_slave_mode && thd->variables.pseudo_thread_id == 0)
1200+
push_warning(thd, Sql_condition::WARN_LEVEL_WARN,
1201+
ER_PSEUDO_THREAD_ID_OVERWRITE,
1202+
ER_THD(thd, ER_PSEUDO_THREAD_ID_OVERWRITE));
1203+
thd->variables.pseudo_thread_id= 0;
11991204
return thd->is_error();
12001205
}

0 commit comments

Comments
 (0)