Commit e4667fc5 authored by unknown's avatar unknown

fixed bug in master_pos_wait(), got rid of sleep hack,

added test/sanity check for master_pos_wait()


mysql-test/r/rpl000016.result:
  do show slave status to test master_pos_wait()
mysql-test/t/rpl000001.test:
  no sleep
mysql-test/t/rpl000002.test:
  no sleep
mysql-test/t/rpl000003.test:
  no sleep
mysql-test/t/rpl000007.test:
  !sleep
mysql-test/t/rpl000008.test:
  !sleep
mysql-test/t/rpl000009.test:
  no sleep
mysql-test/t/rpl000010.test:
  no sleep
mysql-test/t/rpl000011.test:
  no sleep
mysql-test/t/rpl000012.test:
  no sleep
mysql-test/t/rpl000013.test:
  no sleep
mysql-test/t/rpl000014.test:
  no sleep
mysql-test/t/rpl000015.test:
  no sleep
mysql-test/t/rpl000016.test:
  no sleep, test that master_pos_wait() works right
sql/slave.cc:
  fixed bug in master_pos_wait()
parent 682234e6
Master_Host Master_User Master_Port Connect_retry Log_File Pos Slave_Running Replicate_do_db Replicate_ignore_db
127.0.0.1 root 9306 60 master-bin.001 216 Yes
s
Could not break slave
Tried hard
......@@ -7,6 +9,8 @@ master-bin.002
master-bin.003
Log_name
master-bin.003
Master_Host Master_User Master_Port Connect_retry Log_File Pos Slave_Running Replicate_do_db Replicate_ignore_db
127.0.0.1 root 9306 60 master-bin.003 128 Yes
m
34
67
......
......@@ -12,7 +12,6 @@ insert into foo values(1),(2);
save_master_pos;
connection slave;
sync_with_master;
sleep 1;
use test;
select * from foo;
select sum(length(word)) from t1;
......
......@@ -9,7 +9,6 @@ save_master_pos;
connection slave;
use test;
sync_with_master;
sleep 1;
@r/rpl000002.result select * from t1;
connection master;
drop table t1;
......
......@@ -7,7 +7,6 @@ insert into t1 values (3);
save_master_pos;
connection slave;
sync_with_master;
sleep 1;
@r/rpl000003.result select * from t1;
connection master;
drop table t1;
......
......@@ -18,7 +18,6 @@ insert into bar values(15);
save_master_pos;
connection slave;
sync_with_master;
sleep 1;
@r/rpl000007.result select foo.n,bar.m from foo,bar;
connection master;
drop table if exists bar,foo;
......
......@@ -20,7 +20,6 @@ insert into choo values(55);
save_master_pos;
connection slave;
sync_with_master;
sleep 1;
@r/rpl000008.result select foo.n,bar.m,choo.k from foo,bar,choo;
connection master;
drop table if exists foo,bar,choo;
......
......@@ -22,7 +22,6 @@ insert into bar.bar values(15);
save_master_pos;
connection slave;
sync_with_master;
sleep 1;
@r/rpl000009.result select foo.foo.n,bar.bar.m from foo.foo,bar.bar;
connection master;
drop database if exists bar;
......
......@@ -11,10 +11,10 @@ insert into t1 values(2);
save_master_pos;
connection slave;
sync_with_master;
sleep 1;
@r/rpl000010.result select n from t1;
connection master;
drop table t1;
save_master_pos;
connection slave;
sync_with_master;
......@@ -6,7 +6,6 @@ create table t1 (n int);
insert into t1 values(1);
save_master_pos;
connection slave;
#give slave some breathing room to get started
sync_with_master;
slave stop;
slave start;
......@@ -16,7 +15,6 @@ save_master_pos;
connection slave;
#let slave catch up
sync_with_master;
sleep 1;
@r/rpl000011.result select * from t1;
connection master;
drop table t1;
......
......@@ -19,7 +19,6 @@ connection master2;
save_master_pos;
connection slave;
sync_with_master;
sleep 1;
@r/rpl000012.result select * from t2;
@r/rpl000012.status.result show status like 'Slave_open_temp_tables';
#
......
......@@ -22,7 +22,6 @@ connection master2;
save_master_pos;
connection slave;
sync_with_master;
sleep 1;
@r/rpl000013.result select * from t2;
@r/rpl000013.status.result show status like 'Slave_open_temp_tables';
#
......
......@@ -24,7 +24,6 @@ save_master_pos;
connection slave;
change master to master_log_pos=73;
sync_with_master;
sleep 1;
select * from foo;
connection master;
drop table foo;
......
......@@ -4,6 +4,7 @@ source include/have_default_master.inc;
connection master;
reset master;
show master status;
save_master_pos;
connection slave;
reset slave;
show slave status;
......@@ -13,7 +14,7 @@ change master to master_host='127.0.0.1',master_user='root',
master_password='',master_port=9306;
show slave status;
slave start;
sleep 3;
sync_with_master;
show slave status;
connection master;
drop table if exists foo;
......@@ -22,7 +23,6 @@ insert into foo values (10),(45),(90);
save_master_pos;
connection slave;
sync_with_master;
sleep 1;
select * from foo;
connection master;
drop table foo;
......
......@@ -10,6 +10,9 @@ system chmod 600 var/slave-data/master.info;
!change master to master_host='127.0.0.1',master_port=9306,master_user='root';
reset slave;
!change master to master_host='127.0.0.1',master_port=9306,master_user='root';
connection master;
reset master;
connection slave;
slave start;
connection master;
drop table if exists t1;
......@@ -18,7 +21,7 @@ insert into t1 values('Could not break slave'),('Tried hard');
save_master_pos;
connection slave;
sync_with_master;
sleep 1;
show slave status;
select * from t1;
connection master;
flush logs;
......@@ -27,14 +30,13 @@ create table t2(m int);
insert into t2 values (34),(67),(123);
flush logs;
show master logs;
sleep 2; # If a slow machine
purge master logs to 'master-bin.003';
show master logs;
insert into t2 values (65);
save_master_pos;
connection slave;
sync_with_master;
sleep 1;
show slave status;
select * from t2;
drop table if exists t1,t2;
connection master;
......
......@@ -616,7 +616,7 @@ int st_master_info::wait_for_pos(THD* thd, String* log_name, ulong log_pos)
bool pos_reached;
int event_count = 0;
pthread_mutex_lock(&lock);
do
while(!thd->killed)
{
int cmp_result;
if (*log_file_name)
......@@ -638,15 +638,13 @@ int st_master_info::wait_for_pos(THD* thd, String* log_name, ulong log_pos)
pos_reached = ((!cmp_result && pos >= log_pos) || cmp_result > 0);
if (pos_reached || thd->killed)
break;
{
const char* msg = thd->enter_cond(&cond, &lock,
"Waiting for master update");
pthread_cond_wait(&cond, &lock);
thd->exit_cond(msg);
event_count++;
pos_reached = (pos >= log_pos);
}
} while (!pos_reached && !thd->killed);
const char* msg = thd->enter_cond(&cond, &lock,
"Waiting for master update");
pthread_cond_wait(&cond, &lock);
thd->exit_cond(msg);
event_count++;
}
pthread_mutex_unlock(&lock);
return thd->killed ? -1 : event_count;
}
......
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