From e022ba60634621c698ef0c093085234123eec50e Mon Sep 17 00:00:00 2001 From: "guilhem@mysql.com" <> Date: Mon, 1 Mar 2004 00:46:31 +0100 Subject: [PATCH] Fix for BUG#3017 "wrong Relay_Log_Pos if Rotate is in the middle of a transaction in relay log" increment 'pending' instead of 'relay_log_pos'. --- mysql-test/r/rpl_trunc_binlog.result | 2 +- sql/log_event.cc | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/rpl_trunc_binlog.result b/mysql-test/r/rpl_trunc_binlog.result index 272fa210807..27b7c3c5677 100644 --- a/mysql-test/r/rpl_trunc_binlog.result +++ b/mysql-test/r/rpl_trunc_binlog.result @@ -10,4 +10,4 @@ reset slave; start slave; show slave status; Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space -127.0.0.1 root MASTER_PORT 1 master-bin.002 4 slave-relay-bin.002 161 master-bin.001 Yes No 0 Rolling back unfinished transaction (no COMMIT or ROLLBACK) from relay log. Probably cause is that the master died while writing the transaction to it's binary log. 0 79 # +127.0.0.1 root MASTER_PORT 1 master-bin.002 4 slave-relay-bin.002 120 master-bin.001 Yes No 0 Rolling back unfinished transaction (no COMMIT or ROLLBACK) from relay log. A probable cause is that the master died while writing the transaction to its binary log. 0 79 # diff --git a/sql/log_event.cc b/sql/log_event.cc index 61a1ee24973..038c17ffaba 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -2121,7 +2121,7 @@ int Start_log_event::exec_event(struct st_relay_log_info* rli) slave_print_error(rli, 0, "\ Rolling back unfinished transaction (no COMMIT or ROLLBACK) from relay log. \ -Probably cause is that the master died while writing the transaction to it's \ +A probable cause is that the master died while writing the transaction to its \ binary log."); return(1); } @@ -2221,13 +2221,15 @@ int Rotate_log_event::exec_event(struct st_relay_log_info* rli) In that case, we don't want to touch the coordinates which correspond to the beginning of the transaction. */ - if (!rli->inside_transaction) + if (rli->inside_transaction) + rli->inc_pending(get_event_len()); + else { memcpy(rli->master_log_name, new_log_ident, ident_len+1); rli->master_log_pos= pos; + rli->relay_log_pos += get_event_len(); DBUG_PRINT("info", ("master_log_pos: %lu", (ulong) rli->master_log_pos)); } - rli->relay_log_pos += get_event_len(); pthread_mutex_unlock(&rli->data_lock); pthread_cond_broadcast(&rli->data_cond); flush_relay_log_info(rli);