summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei <andrei.elkin@mariadb.com>2022-01-14 18:03:38 +0200
committerAndrei <andrei.elkin@mariadb.com>2022-01-14 18:03:38 +0200
commit3aeac791220a45046f57c7351c58b6a14921addc (patch)
tree4c2d90c4a4c37fb794a7f80a186cef9458492395
parent37b789d97bb07ed290fc9f39cbf01e0cdcd7d937 (diff)
downloadmariadb-git-3aeac791220a45046f57c7351c58b6a14921addc.tar.gz
MDEV-27511 Assertion `rgi->gtid_ev_flags_extra & Gtid_log_event::FL_COMMIT_ALTER_E1' failed in write_bin_log_start_alter
The assert was caused by lack of proper cleanup of the sequential slave's execution context, enriched by MDEV-11675 2 phase loggable ALTER. Fixed to conduct an explicit cleanup in non-parallel execution.
-rw-r--r--mysql-test/suite/rpl/r/rpl_start_alter_para_to_seq.result14
-rw-r--r--mysql-test/suite/rpl/t/rpl_start_alter_para_to_seq.test24
-rw-r--r--sql/log_event_server.cc14
3 files changed, 49 insertions, 3 deletions
diff --git a/mysql-test/suite/rpl/r/rpl_start_alter_para_to_seq.result b/mysql-test/suite/rpl/r/rpl_start_alter_para_to_seq.result
new file mode 100644
index 00000000000..f391b01b0a6
--- /dev/null
+++ b/mysql-test/suite/rpl/r/rpl_start_alter_para_to_seq.result
@@ -0,0 +1,14 @@
+include/master-slave.inc
+[connection master]
+connection master;
+CREATE TABLE t1 (a1 int, d1 int DEFAULT 0);
+INSERT INTO t1 VALUES (1,1) ;
+SET binlog_alter_two_phase=YES;
+ALTER TABLE t1 WAIT 9 RENAME COLUMN a1 TO a2;
+SET binlog_alter_two_phase=NO;
+ALTER TABLE t1 ALTER COLUMN d1 DROP DEFAULT;
+connection slave;
+connection master;
+drop table t1;
+connection slave;
+include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/t/rpl_start_alter_para_to_seq.test b/mysql-test/suite/rpl/t/rpl_start_alter_para_to_seq.test
new file mode 100644
index 00000000000..577e65d0a71
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_start_alter_para_to_seq.test
@@ -0,0 +1,24 @@
+# MDEV-11675 binlog_alter_two_phase
+# MDEV-27511 Assertion `rgi->gtid_ev_flags_extra & Gtid_log_event::FL_COMMIT_ALTER_E1' failed
+# in write_bin_log_start_alter
+#
+--source include/have_log_bin.inc
+--source include/master-slave.inc
+
+# The test proves the assert is not hit anymore.
+--connection master
+CREATE TABLE t1 (a1 int, d1 int DEFAULT 0);
+INSERT INTO t1 VALUES (1,1) ;
+SET binlog_alter_two_phase=YES;
+ALTER TABLE t1 WAIT 9 RENAME COLUMN a1 TO a2;
+SET binlog_alter_two_phase=NO;
+ALTER TABLE t1 ALTER COLUMN d1 DROP DEFAULT;
+
+--sync_slave_with_master
+
+# Cleanup
+--connection master
+drop table t1;
+--sync_slave_with_master
+
+--source include/rpl_end.inc
diff --git a/sql/log_event_server.cc b/sql/log_event_server.cc
index d36ca519973..3178aac8915 100644
--- a/sql/log_event_server.cc
+++ b/sql/log_event_server.cc
@@ -2112,9 +2112,11 @@ int Query_log_event::do_apply_event(rpl_group_info *rgi,
}
int sa_result= 0;
- if (gtid_flags_extra & (Gtid_log_event::FL_START_ALTER_E1 |
- Gtid_log_event::FL_COMMIT_ALTER_E1 |
- Gtid_log_event::FL_ROLLBACK_ALTER_E1))
+ bool is_2p_alter= gtid_flags_extra &
+ (Gtid_log_event::FL_START_ALTER_E1 |
+ Gtid_log_event::FL_COMMIT_ALTER_E1 |
+ Gtid_log_event::FL_ROLLBACK_ALTER_E1);
+ if (is_2p_alter)
sa_result= handle_split_alter_query_log_event(rgi, skip_error_check);
if (sa_result == 0)
{
@@ -2158,6 +2160,12 @@ int Query_log_event::do_apply_event(rpl_group_info *rgi,
goto end;
}
thd->variables.option_bits&= ~OPTION_MASTER_SQL_ERROR;
+ if (is_2p_alter && !rgi->is_parallel_exec)
+ {
+ rgi->gtid_ev_flags_extra= 0;
+ rgi->direct_commit_alter= 0;
+ rgi->gtid_ev_sa_seq_no= 0;
+ }
}
else
{