Commit 76eaa259 authored by unknown's avatar unknown

fixed mysterious offset confusion bug

added a test case for it - took some creative work to figure out
how to make it happen at will
updated the manual


Docs/manual.texi:
  fixed wrong info on SLAVE_SKIP_COUNTER
  fixed wrong info in BitKeeper tree build instructions
  updated change history about bug fix
mysql-test/t/rpl_sporadic_master.test:
  tried hard to get slave confused, but failed. nevertheless, a more
  exhaustive test case does not hurt
sql/slave.cc:
  fixed mysterious offset confusion bug
parent 2cbf3b9b
...@@ -6543,8 +6543,8 @@ shell> make ...@@ -6543,8 +6543,8 @@ shell> make
A collection of our standard configure scripts is located in the A collection of our standard configure scripts is located in the
@file{BUILD/} subdirectory. If you are lazy, you can use @file{BUILD/} subdirectory. If you are lazy, you can use
@file{BUILD/compile-pentium-debug}. It will actually work on a lot of @file{BUILD/compile-pentium-debug}. To compile on a different architecture,
non-x86 machines despite its name. modify the script removing flags that are Pentium-specific.
@item @item
When the build is done, run @code{make install}. Be careful with this When the build is done, run @code{make install}. Be careful with this
...@@ -29828,8 +29828,11 @@ query from the master. ...@@ -29828,8 +29828,11 @@ query from the master.
@item @item
If you have decided you can skip the next query, do If you have decided you can skip the next query, do
@code{SET SQL_SLAVE_SKIP_COUNTER=1; SLAVE START;} to skip a query that @code{SET SQL_SLAVE_SKIP_COUNTER=1; SLAVE START;} to skip a query that
does not use auto_increment, last_insert_id or timestamp, or does not use auto_increment, or last_insert_id or
@code{SET SQL_SLAVE_SKIP_COUNTER=2; SLAVE START;} otherwise @code{SET SQL_SLAVE_SKIP_COUNTER=2; SLAVE START;} otherwise. The reason
auto_increment/last_insert_id queries are different is that they take
two events in the binary log of the master.
@item @item
If you are sure the slave started out perfectly in sync with the master, If you are sure the slave started out perfectly in sync with the master,
and no one has updated the tables involved outside of slave thread, and no one has updated the tables involved outside of slave thread,
...@@ -45728,6 +45731,9 @@ not yet 100% confident in this code. ...@@ -45728,6 +45731,9 @@ not yet 100% confident in this code.
@appendixsubsec Changes in release 3.23.40 @appendixsubsec Changes in release 3.23.40
@itemize @bullet @itemize @bullet
@item @item
Fixed bug in slave thread when under some rare circumstances it could
get 22 bytes ahead on the offset in the master
@item
Added @code{slave_wait_timeout} for replication. Added @code{slave_wait_timeout} for replication.
@item @item
Fixed problem with @code{UPDATE} and BDB tables. Fixed problem with @code{UPDATE} and BDB tables.
# test case to make slave thread get ahead by 22 bytes
source include/master-slave.inc;
connection master;
# first, cause a duplicate key problem on the slave
create table t1(n int auto_increment primary key);
save_master_pos;
connection slave;
sync_with_master;
insert into t1 values (2);
connection master;
insert into t1 values(NULL);
insert into t1 values(NULL);
save_master_pos;
connection slave;
sleep 1; # there is no way around this sleep - we have to wait until
# the slave tries to run the query, fails and aborts slave thread
delete from t1 where n = 2;
slave start;
sync_with_master;
#now the buggy slave would be confused on the offset but it can replicate
#in order to make it break, we need to stop/start the slave one more time
slave stop;
connection master;
# to be able to really confuse the slave, we need some non-auto-increment
# events in the log
create table t2(n int);
drop table t2;
insert into t1 values(NULL);
save_master_pos;
connection slave;
slave start;
#now the truth comes out - if the slave is buggy, it will never sync because
#the slave thread is not able to read events
sync_with_master;
select * from t1;
#clean up
connection master;
drop table t1;
save_master_pos;
connection slave;
sync_with_master;
...@@ -3,12 +3,19 @@ ...@@ -3,12 +3,19 @@
source include/master-slave.inc; source include/master-slave.inc;
connection master; connection master;
drop table if exists t1; drop table if exists t1,t2;
create table t2(n int);
create table t1(n int not null auto_increment primary key); create table t1(n int not null auto_increment primary key);
insert into t1 values (NULL),(NULL); insert into t1 values (NULL),(NULL);
delete from t1; delete from t1;
# We have to use 4 in the following to make this test work with all table types # We have to use 4 in the following to make this test work with all table types
insert into t1 values (4),(NULL); insert into t1 values (4),(NULL);
save_master_pos;
connection slave;
sync_with_master;
slave stop;
slave start;
connection master;
insert into t1 values (NULL),(NULL); insert into t1 values (NULL),(NULL);
flush logs; flush logs;
delete from t1; delete from t1;
...@@ -20,7 +27,7 @@ connection slave; ...@@ -20,7 +27,7 @@ connection slave;
sync_with_master; sync_with_master;
select * from t1; select * from t1;
connection master; connection master;
drop table t1; drop table t1,t2;
save_master_pos; save_master_pos;
connection slave; connection slave;
sync_with_master; sync_with_master;
...@@ -1222,6 +1222,8 @@ pthread_handler_decl(handle_slave,arg __attribute__((unused))) ...@@ -1222,6 +1222,8 @@ pthread_handler_decl(handle_slave,arg __attribute__((unused)))
thd->thread_stack = (char*)&thd; // remember where our stack is thd->thread_stack = (char*)&thd; // remember where our stack is
thd->temporary_tables = save_temporary_tables; // restore temp tables thd->temporary_tables = save_temporary_tables; // restore temp tables
threads.append(thd); threads.append(thd);
glob_mi.pending = 0; //this should always be set to 0 when the slave thread
// is started
DBUG_PRINT("info",("master info: log_file_name=%s, position=%s", DBUG_PRINT("info",("master info: log_file_name=%s, position=%s",
glob_mi.log_file_name, llstr(glob_mi.pos,llbuff))); glob_mi.log_file_name, llstr(glob_mi.pos,llbuff)));
......
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