summaryrefslogtreecommitdiff
path: root/sql/slave.cc
diff options
context:
space:
mode:
authorunknown <pem@mysql.comhem.se>2004-05-14 16:00:57 +0200
committerunknown <pem@mysql.comhem.se>2004-05-14 16:00:57 +0200
commit3a272c1fa91121d3792a558840d2b764d758f4e9 (patch)
treed27d078b95ca20c323af435a836f475562c863d0 /sql/slave.cc
parente9c1e75b48e5d2c0047a3e88b35667a33d6395e4 (diff)
downloadmariadb-git-3a272c1fa91121d3792a558840d2b764d758f4e9.tar.gz
Post-merge fixes.
Note: One sp.test still fails (prime), and rpl_server_id2.test fails (will be fixed by guilhem ASAP). mysql-test/r/index_merge.result: Fixed syntax error (no ',' after last index in create table any more). mysql-test/r/index_merge_bdb.result: Fixed syntax error (no ',' after last index in create table any more). mysql-test/r/index_merge_innodb.result: Fixed syntax error (no ',' after last index in create table any more). mysql-test/r/index_merge_innodb2.result: Fixed syntax error (no ',' after last index in create table any more). mysql-test/r/rpl_server_id1.result: Update result after merge. mysql-test/r/sp-error.result: Update result after merge. mysql-test/r/variables.result: Update result after merge. mysql-test/t/index_merge.test: Fixed syntax error (no ',' after last index in create table any more). mysql-test/t/index_merge_bdb.test: Fixed syntax error (no ',' after last index in create table any more). mysql-test/t/index_merge_innodb.test: Fixed syntax error (no ',' after last index in create table any more). mysql-test/t/index_merge_innodb2.test: Fixed syntax error (no ',' after last index in create table any more). mysql-test/t/sp-error.test: Post-merge fix of error codes. sql/opt_range.cc: Manually merged by Monty. sql/opt_range.h: Manually merged by Monty. sql/slave.cc: Post-merge fixes with some help from Guilhem. sql/slave.h: Post-merge fixes with some help from Guilhem. sql/sp_head.cc: Got rid of warning (reordering initialization). sql/sql_parse.cc: Post-merge fix: Need to set/reset select_limit at SP CALL time as well. tests/client_test.c: Post-merge fix: key_len length in explain has changed.
Diffstat (limited to 'sql/slave.cc')
-rw-r--r--sql/slave.cc39
1 files changed, 30 insertions, 9 deletions
diff --git a/sql/slave.cc b/sql/slave.cc
index 3fddc4dc783..1fe4aa40f8e 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -464,16 +464,15 @@ void init_slave_skip_errors(const char* arg)
}
-void st_relay_log_info::inc_group_relay_log_pos(ulonglong val,
- ulonglong log_pos,
- bool skip_lock)
+void st_relay_log_info::inc_group_relay_log_pos(ulonglong log_pos,
+ bool skip_lock=0)
{
if (!skip_lock)
pthread_mutex_lock(&data_lock);
- inc_event_relay_log_pos(val);
+ inc_event_relay_log_pos();
group_relay_log_pos= event_relay_log_pos;
strmake(group_relay_log_name,event_relay_log_name,
- sizeof(group_relay_log_name)-1);
+ sizeof(group_relay_log_name)-1);
notify_group_relay_log_name_update();
@@ -487,6 +486,28 @@ void st_relay_log_info::inc_group_relay_log_pos(ulonglong val,
not advance as it should on the non-transactional slave (it advances by
big leaps, whereas it should advance by small leaps).
*/
+ /*
+ In 4.x we used the event's len to compute the positions here. This is
+ wrong if the event was 3.23/4.0 and has been converted to 5.0, because
+ then the event's len is not what is was in the master's binlog, so this
+ will make a wrong group_master_log_pos (yes it's a bug in 3.23->4.0
+ replication: Exec_master_log_pos is wrong). Only way to solve this is to
+ have the original offset of the end of the event the relay log. This is
+ what we do in 5.0: log_pos has become "end_log_pos" (because the real use
+ of log_pos in 4.0 was to compute the end_log_pos; so better to store
+ end_log_pos instead of begin_log_pos.
+ If we had not done this fix here, the problem would also have appeared
+ when the slave and master are 5.0 but with different event length (for
+ example the slave is more recent than the master and features the event
+ UID). It would give false MASTER_POS_WAIT, false Exec_master_log_pos in
+ SHOW SLAVE STATUS, and so the user would do some CHANGE MASTER using this
+ value which would lead to badly broken replication.
+ Even the relay_log_pos will be corrupted in this case, because the len is
+ the relay log is not "val".
+ With the end_log_pos solution, we avoid computations involving lengthes.
+ */
+ DBUG_PRINT("info", ("log_pos=%lld group_master_log_pos=%lld",
+ log_pos,group_master_log_pos));
if (log_pos) // 3.23 binlogs don't have log_posx
{
#if MYSQL_VERSION_ID < 50000
@@ -500,10 +521,10 @@ void st_relay_log_info::inc_group_relay_log_pos(ulonglong val,
Yes this is a hack but it's just to make 3.23->4.x replication work;
3.23->5.0 replication is working much better.
*/
- group_master_log_pos= log_pos + val -
+ group_master_log_pos= log_pos -
(mi->old_format ? (LOG_EVENT_HEADER_LEN - OLD_HEADER_LEN) : 0);
#else
- group_master_log_pos= log_pos+ val;
+ group_master_log_pos= log_pos;
#endif /* MYSQL_VERSION_ID < 5000 */
}
pthread_cond_broadcast(&data_cond);
@@ -2540,13 +2561,13 @@ int st_relay_log_info::wait_for_pos(THD* thd, String* log_name,
goto err;
}
- int cmp_result;
-
/* The "compare and wait" main loop */
while (!thd->killed &&
init_abort_pos_wait == abort_pos_wait &&
slave_running)
{
+ bool pos_reached;
+ int cmp_result= 0;
/*
group_master_log_name can be "", if we are just after a fresh