mirror of
https://github.com/MariaDB/server.git
synced 2026-01-06 05:22:24 +03:00
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.
This commit is contained in:
66
mysql-test/suite/galera/r/rpl_row_annotate.result
Normal file
66
mysql-test/suite/galera/r/rpl_row_annotate.result
Normal file
@@ -0,0 +1,66 @@
|
||||
# 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 = 2;
|
||||
# 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= */
|
||||
mysqld-bin.000001 # Gtid 2 # BEGIN GTID 0-2-5
|
||||
mysqld-bin.000001 # Annotate_rows 2 # DELETE FROM t1 WHERE i = 2
|
||||
mysqld-bin.000001 # Table_map 2 # table_id: # (test.t1)
|
||||
mysqld-bin.000001 # Delete_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= */
|
||||
mysqld-bin.000001 # Gtid 2 # BEGIN GTID 0-2-5
|
||||
mysqld-bin.000001 # Annotate_rows 2 # DELETE FROM t1 WHERE i = 2
|
||||
mysqld-bin.000001 # Table_map 2 # table_id: # (test.t1)
|
||||
mysqld-bin.000001 # Delete_rows_v1 2 # table_id: # flags: STMT_END_F
|
||||
mysqld-bin.000001 # Xid 2 # COMMIT /* xid= */
|
||||
DROP TABLE t1;
|
||||
# End of test
|
||||
6
mysql-test/suite/galera/t/rpl_row_annotate.cnf
Normal file
6
mysql-test/suite/galera/t/rpl_row_annotate.cnf
Normal file
@@ -0,0 +1,6 @@
|
||||
!include ../galera_2nodes.cnf
|
||||
|
||||
[mysqld]
|
||||
log-bin
|
||||
log-slave-updates
|
||||
binlog-annotate-row-events=ON
|
||||
42
mysql-test/suite/galera/t/rpl_row_annotate.test
Normal file
42
mysql-test/suite/galera/t/rpl_row_annotate.test
Normal file
@@ -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 = 2;
|
||||
|
||||
--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
|
||||
@@ -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:
|
||||
|
||||
@@ -121,10 +121,13 @@ static rpl_group_info* wsrep_relay_group_init(const char* log_fname)
|
||||
*/
|
||||
rli->mi = new Master_info(&connection_name, false);
|
||||
|
||||
rli->sql_driver_thd= current_thd;
|
||||
|
||||
struct rpl_group_info *rgi= new rpl_group_info(rli);
|
||||
rgi->thd= current_thd;
|
||||
rgi->thd= rli->sql_driver_thd= current_thd;
|
||||
|
||||
if ((rgi->deferred_events_collecting= rli->mi->rpl_filter->is_on()))
|
||||
{
|
||||
rgi->deferred_events= new Deferred_log_events(rli);
|
||||
}
|
||||
|
||||
return rgi;
|
||||
}
|
||||
@@ -172,6 +175,8 @@ static void wsrep_return_from_bf_mode(THD *thd, struct wsrep_thd_shadow* shadow)
|
||||
delete thd->system_thread_info.rpl_sql_info;
|
||||
delete thd->wsrep_rgi->rli->mi;
|
||||
delete thd->wsrep_rgi->rli;
|
||||
|
||||
thd->wsrep_rgi->cleanup_after_session();
|
||||
delete thd->wsrep_rgi;
|
||||
thd->wsrep_rgi = NULL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user