[Commits] e02da40: MDEV-7192: binlog_annotate_row_events not completely compatible with galera

Nirbhay Choubey nirbhay at mariadb.com
Thu Mar 5 04:15:48 EET 2015


revision-id: e02da4033b4ec7f3249ea3ca5aff45e4f41d6a17
parent(s): aa2904a7f4014cd4790086a2512dc39b533b2a8a
committer: Nirbhay Choubey
branch nick: 10.0-galera-b7192
timestamp: 2015-03-04 21:15:45 -0500
message:

MDEV-7192: binlog_annotate_row_events not completely compatible with galera

Annotate_rows event needs to be preserved until the last Rows event has
been applied because after it has been applied thd->query points to the
query stored inside this event.

---
 mysql-test/suite/galera/r/rpl_row_annotate.result | 56 +++++++++++++++++++++++
 mysql-test/suite/galera/t/rpl_row_annotate.cnf    |  6 +++
 mysql-test/suite/galera/t/rpl_row_annotate.test   | 42 +++++++++++++++++
 sql/wsrep_applier.cc                              |  8 ++--
 4 files changed, 109 insertions(+), 3 deletions(-)

diff --git a/mysql-test/suite/galera/r/rpl_row_annotate.result b/mysql-test/suite/galera/r/rpl_row_annotate.result
new file mode 100644
index 0000000..17dbde4
--- /dev/null
+++ b/mysql-test/suite/galera/r/rpl_row_annotate.result
@@ -0,0 +1,56 @@
+# On node_2
+RESET MASTER;
+# On node_1
+RESET MASTER;
+CREATE TABLE t1(i INT)ENGINE=INNODB;
+INSERT INTO t1 VALUES(1);
+DELETE FROM t1 WHERE i = 1;
+# On node_2
+INSERT INTO t1 VALUES(2);
+DELETE FROM t1 WHERE i = 1;
+# On node_1
+SHOW BINLOG EVENTS IN 'mysqld-bin.000001' FROM <start_pos>;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+mysqld-bin.000001	#	Gtid_list	1	#	[]
+mysqld-bin.000001	#	Binlog_checkpoint	1	#	mysqld-bin.000001
+mysqld-bin.000001	#	Gtid	1	#	GTID 0-1-1
+mysqld-bin.000001	#	Query	1	#	use `test`; CREATE TABLE t1(i INT)ENGINE=INNODB
+mysqld-bin.000001	#	Gtid	1	#	BEGIN GTID 0-1-2
+mysqld-bin.000001	#	Annotate_rows	1	#	INSERT INTO t1 VALUES(1)
+mysqld-bin.000001	#	Table_map	1	#	table_id: # (test.t1)
+mysqld-bin.000001	#	Write_rows_v1	1	#	table_id: # flags: STMT_END_F
+mysqld-bin.000001	#	Xid	1	#	COMMIT /* xid= */
+mysqld-bin.000001	#	Gtid	1	#	BEGIN GTID 0-1-3
+mysqld-bin.000001	#	Annotate_rows	1	#	DELETE FROM t1 WHERE i = 1
+mysqld-bin.000001	#	Table_map	1	#	table_id: # (test.t1)
+mysqld-bin.000001	#	Delete_rows_v1	1	#	table_id: # flags: STMT_END_F
+mysqld-bin.000001	#	Xid	1	#	COMMIT /* xid= */
+mysqld-bin.000001	#	Gtid	2	#	BEGIN GTID 0-2-4
+mysqld-bin.000001	#	Annotate_rows	2	#	INSERT INTO t1 VALUES(2)
+mysqld-bin.000001	#	Table_map	2	#	table_id: # (test.t1)
+mysqld-bin.000001	#	Write_rows_v1	2	#	table_id: # flags: STMT_END_F
+mysqld-bin.000001	#	Xid	2	#	COMMIT /* xid= */
+# On node_2
+SHOW BINLOG EVENTS IN 'mysqld-bin.000001' FROM <start_pos>;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+mysqld-bin.000001	#	Gtid_list	2	#	[]
+mysqld-bin.000001	#	Binlog_checkpoint	2	#	mysqld-bin.000001
+mysqld-bin.000001	#	Gtid	1	#	GTID 0-1-1
+mysqld-bin.000001	#	Query	1	#	use `test`; CREATE TABLE t1(i INT)ENGINE=INNODB
+mysqld-bin.000001	#	Gtid	1	#	BEGIN GTID 0-1-2
+mysqld-bin.000001	#	Annotate_rows	1	#	INSERT INTO t1 VALUES(1)
+mysqld-bin.000001	#	Table_map	1	#	table_id: # (test.t1)
+mysqld-bin.000001	#	Write_rows_v1	1	#	table_id: # flags: STMT_END_F
+mysqld-bin.000001	#	Xid	1	#	COMMIT /* xid= */
+mysqld-bin.000001	#	Gtid	1	#	BEGIN GTID 0-1-3
+mysqld-bin.000001	#	Annotate_rows	1	#	DELETE FROM t1 WHERE i = 1
+mysqld-bin.000001	#	Table_map	1	#	table_id: # (test.t1)
+mysqld-bin.000001	#	Delete_rows_v1	1	#	table_id: # flags: STMT_END_F
+mysqld-bin.000001	#	Xid	1	#	COMMIT /* xid= */
+mysqld-bin.000001	#	Gtid	2	#	BEGIN GTID 0-2-4
+mysqld-bin.000001	#	Annotate_rows	2	#	INSERT INTO t1 VALUES(2)
+mysqld-bin.000001	#	Table_map	2	#	table_id: # (test.t1)
+mysqld-bin.000001	#	Write_rows_v1	2	#	table_id: # flags: STMT_END_F
+mysqld-bin.000001	#	Xid	2	#	COMMIT /* xid= */
+DROP TABLE t1;
+# End of test
diff --git a/mysql-test/suite/galera/t/rpl_row_annotate.cnf b/mysql-test/suite/galera/t/rpl_row_annotate.cnf
new file mode 100644
index 0000000..1f1d83d
--- /dev/null
+++ b/mysql-test/suite/galera/t/rpl_row_annotate.cnf
@@ -0,0 +1,6 @@
+!include ../galera_2nodes.cnf
+
+[mysqld]
+log-bin
+log-slave-updates
+binlog-annotate-row-events=ON
diff --git a/mysql-test/suite/galera/t/rpl_row_annotate.test b/mysql-test/suite/galera/t/rpl_row_annotate.test
new file mode 100644
index 0000000..1cb2403
--- /dev/null
+++ b/mysql-test/suite/galera/t/rpl_row_annotate.test
@@ -0,0 +1,42 @@
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+
+--echo # On node_2
+--connection node_2
+RESET MASTER;
+
+--echo # On node_1
+--connection node_1
+RESET MASTER;
+CREATE TABLE t1(i INT)ENGINE=INNODB;
+INSERT INTO t1 VALUES(1);
+DELETE FROM t1 WHERE i = 1;
+
+--echo # On node_2
+--connection node_2
+INSERT INTO t1 VALUES(2);
+DELETE FROM t1 WHERE i = 1;
+
+--echo # On node_1
+--connection node_1
+--source include/binlog_start_pos.inc
+let $start_pos= `select @binlog_start_pos`;
+--replace_column 2 # 5 #
+--replace_result $start_pos <start_pos>
+--replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\//
+--eval SHOW BINLOG EVENTS IN 'mysqld-bin.000001' FROM $start_pos
+
+--echo # On node_2
+--connection node_2
+--source include/binlog_start_pos.inc
+let $start_pos= `select @binlog_start_pos`;
+--replace_column 2 # 5 #
+--replace_result $start_pos <start_pos>
+--replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\//
+--eval SHOW BINLOG EVENTS IN 'mysqld-bin.000001' FROM $start_pos
+
+# Cleanup
+DROP TABLE t1;
+
+--source include/galera_end.inc
+--echo # End of test
diff --git a/sql/wsrep_applier.cc b/sql/wsrep_applier.cc
index 03d356a..6f1ead8 100644
--- a/sql/wsrep_applier.cc
+++ b/sql/wsrep_applier.cc
@@ -92,6 +92,7 @@ static wsrep_cb_status_t wsrep_apply_events(THD*        thd,
   char *buf= (char *)events_buf;
   int rcode= 0;
   int event= 1;
+  Log_event_type typ;
 
   DBUG_ENTER("wsrep_apply_events");
 
@@ -126,7 +127,9 @@ static wsrep_cb_status_t wsrep_apply_events(THD*        thd,
       goto error;
     }
 
-    switch (ev->get_type_code()) {
+    typ= ev->get_type_code();
+
+    switch (typ) {
     case FORMAT_DESCRIPTION_EVENT:
       wsrep_set_apply_format(thd, (Format_description_log_event*)ev);
       continue;
@@ -160,7 +163,6 @@ static wsrep_cb_status_t wsrep_apply_events(THD*        thd,
     }
 
     ev->thd = thd;
-    //exec_res = ev->apply_event(thd->wsrep_rli);
     exec_res = ev->apply_event(thd->wsrep_rgi);
     DBUG_PRINT("info", ("exec_event result: %d", exec_res));
 
@@ -192,7 +194,7 @@ static wsrep_cb_status_t wsrep_apply_events(THD*        thd,
       DBUG_RETURN(WSREP_CB_FAILURE);
     }
 
-    delete ev;
+    delete_or_keep_event_post_apply(thd->wsrep_rgi, typ, ev);
   }
 
  error:


More information about the commits mailing list