Commit 12ede13a authored by unknown's avatar unknown

Fix for BUG#3015

"(binlog, position) stored by InnoDB for a replication slave can be wrong".
This code contains conditional #if to distinguish between versions;
it should be merged into 4.1 and 5.0.


sql/ha_innodb.cc:
  correcting the binlog position stored in InnoDB in a slave.
sql/log_event.cc:
  better code to store the binlog position in InnoDB for a slave.
sql/slave.h:
  Better code for storing the binlog position in InnoDB for a slave.
parent bf53c870
...@@ -938,19 +938,17 @@ innobase_commit_low( ...@@ -938,19 +938,17 @@ innobase_commit_low(
return; return;
} }
/* TODO: Guilhem should check if master_log_name, pending
etc. are right if the master log gets rotated! Possible bug here.
Comment by Heikki March 4, 2003. */
if (current_thd->slave_thread) { if (current_thd->slave_thread) {
/* Update the replication position info inside InnoDB */ /* Update the replication position info inside InnoDB */
trx->mysql_master_log_file_name trx->mysql_master_log_file_name
= active_mi->rli.master_log_name; = active_mi->rli.master_log_name;
trx->mysql_master_log_pos = ((ib_longlong) trx->mysql_master_log_pos = (ib_longlong)
(active_mi->rli.master_log_pos + #if MYSQL_VERSION_ID < 40100
active_mi->rli.event_len + (active_mi->rli.future_master_log_pos);
active_mi->rli.pending)); #else
(active_mi->rli.future_group_master_log_pos);
#endif
} }
trx_commit_for_mysql(trx); trx_commit_for_mysql(trx);
......
...@@ -1792,10 +1792,15 @@ int Query_log_event::exec_event(struct st_relay_log_info* rli) ...@@ -1792,10 +1792,15 @@ int Query_log_event::exec_event(struct st_relay_log_info* rli)
/* /*
InnoDB internally stores the master log position it has processed so far; InnoDB internally stores the master log position it has processed so far;
position to store is really pos + pending + event_len position to store is of the END of the current log event.
since we must store the pos of the END of the current log event
*/ */
rli->event_len= get_event_len(); #if MYSQL_VERSION_ID < 40100
rli->future_master_log_pos= log_pos + get_event_len();
#elif MYSQL_VERSION_ID < 50000
rli->future_group_master_log_pos= log_pos + get_event_len();
#else
rli->future_group_master_log_pos= log_pos;
#endif
thd->query_error= 0; // clear error thd->query_error= 0; // clear error
thd->clear_error(); thd->clear_error();
...@@ -1935,6 +1940,17 @@ int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli, ...@@ -1935,6 +1940,17 @@ int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli,
thd->query_error = 0; thd->query_error = 0;
thd->clear_error(); thd->clear_error();
if (!use_rli_only_for_errors)
{
#if MYSQL_VERSION_ID < 40100
rli->future_master_log_pos= log_pos + get_event_len();
#elif MYSQL_VERSION_ID < 50000
rli->future_group_master_log_pos= log_pos + get_event_len();
#else
rli->future_group_master_log_pos= log_pos;
#endif
}
/* /*
We test replicate_*_db rules. Note that we have already prepared the file to We test replicate_*_db rules. Note that we have already prepared the file to
load, even if we are going to ignore and delete it now. So it is possible load, even if we are going to ignore and delete it now. So it is possible
...@@ -2392,6 +2408,14 @@ int Execute_load_log_event::exec_event(struct st_relay_log_info* rli) ...@@ -2392,6 +2408,14 @@ int Execute_load_log_event::exec_event(struct st_relay_log_info* rli)
lev->exec_event is the place where the table is loaded (it calls lev->exec_event is the place where the table is loaded (it calls
mysql_load()). mysql_load()).
*/ */
#if MYSQL_VERSION_ID < 40100
rli->future_master_log_pos= log_pos + get_event_len();
#elif MYSQL_VERSION_ID < 50000
rli->future_group_master_log_pos= log_pos + get_event_len();
#else
rli->future_group_master_log_pos= log_pos;
#endif
if (lev->exec_event(0,rli,1)) if (lev->exec_event(0,rli,1))
{ {
/* /*
......
...@@ -177,12 +177,16 @@ typedef struct st_relay_log_info ...@@ -177,12 +177,16 @@ typedef struct st_relay_log_info
bool ignore_log_space_limit; bool ignore_log_space_limit;
/* /*
InnoDB internally stores the master log position it has processed When it commits, InnoDB internally stores the master log position it has
so far; the position to store is really the sum of processed so far; the position to store is the one of the end of the
pos + pending + event_len here since we must store the pos of the committing event (the COMMIT query event, or the event if in autocommit
END of the current log event mode).
*/ */
int event_len; #if MYSQL_VERSION_ID < 40100
ulonglong future_master_log_pos;
#else
ulonglong future_group_master_log_pos;
#endif
/* /*
Needed for problems when slave stops and we want to restart it Needed for problems when slave stops and we want to restart it
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment