fixed

parent c1581940
...@@ -61,6 +61,9 @@ MYSQLD_SRC_DIRS="strings mysys include extra regex isam merge myisam \ ...@@ -61,6 +61,9 @@ MYSQLD_SRC_DIRS="strings mysys include extra regex isam merge myisam \
GCOV_MSG=/tmp/mysqld-gcov.out #gcov output GCOV_MSG=/tmp/mysqld-gcov.out #gcov output
GCOV_ERR=/tmp/mysqld-gcov.err GCOV_ERR=/tmp/mysqld-gcov.err
MASTER_RUNNING=0
SLAVE_RUNNING=0
[ -d $MY_TMP_DIR ] || mkdir -p $MY_TMP_DIR [ -d $MY_TMP_DIR ] || mkdir -p $MY_TMP_DIR
[ -z $COLUMNS ] && COLUMNS=80 [ -z $COLUMNS ] && COLUMNS=80
...@@ -141,6 +144,7 @@ if [ "$1" = "-force" ] ; then ...@@ -141,6 +144,7 @@ if [ "$1" = "-force" ] ; then
shift 1 shift 1
fi fi
if [ "$1" = "-record" ] ; then if [ "$1" = "-record" ] ; then
RECORD=1 RECORD=1
shift 1 shift 1
...@@ -304,6 +308,7 @@ gcov_collect () { ...@@ -304,6 +308,7 @@ gcov_collect () {
start_master() start_master()
{ {
[ x$MASTER_RUNNING = 1 ] && return
cd $BASEDIR # for gcov cd $BASEDIR # for gcov
#start master #start master
master_args="--no-defaults --log-bin=master-bin \ master_args="--no-defaults --log-bin=master-bin \
...@@ -330,12 +335,19 @@ start_master() ...@@ -330,12 +335,19 @@ start_master()
start_slave() start_slave()
{ {
[ x$SKIP_SLAVE = x1 ] && return [ x$SKIP_SLAVE = x1 ] && return
slave_args="--no-defaults --server-id=2 \ [ x$SLAVE_RUNNING = 1 ] && return
--master-user=root \ if [ -z $SLAVE_MASTER_INFO ] ; then
master_info="--master-user=root \
--master-connect-retry=1 \ --master-connect-retry=1 \
--master-host=127.0.0.1 \ --master-host=127.0.0.1 \
--master-port=$MASTER_MYPORT \ --master-port=$MASTER_MYPORT \
--exit-info=256 \ --server-id=2"
else
master_info=$SLAVE_MASTER_INFO
fi
slave_args="--no-defaults $master_info \
--exit-info=256 \
--log-bin=slave-bin --log-slave-updates \ --log-bin=slave-bin --log-slave-updates \
--basedir=$MY_BASEDIR \ --basedir=$MY_BASEDIR \
--datadir=$SLAVE_MYDDIR \ --datadir=$SLAVE_MYDDIR \
...@@ -413,14 +425,8 @@ mysql_stop () ...@@ -413,14 +425,8 @@ mysql_stop ()
mysql_restart () { mysql_restart () {
return 1
mysql_stop mysql_stop
res=$?
[ $res != 1 ] && echo_notok && error "Stopping mysqld"
mysql_start mysql_start
res=$?
[ $res != 1 ] && echo_notok && error "Starting mysqld"
return 1 return 1
} }
...@@ -438,6 +444,7 @@ run_testcase () ...@@ -438,6 +444,7 @@ run_testcase ()
tname=`$ECHO $tname | $CUT -d . -f 1` tname=`$ECHO $tname | $CUT -d . -f 1`
master_opt_file=$TESTDIR/$tname-master.opt master_opt_file=$TESTDIR/$tname-master.opt
slave_opt_file=$TESTDIR/$tname-slave.opt slave_opt_file=$TESTDIR/$tname-slave.opt
slave_master_info_file=$TESTDIR/$tname-slave-master-info.opt
SKIP_SLAVE=`$EXPR \( $tname : rpl \) = 0` SKIP_SLAVE=`$EXPR \( $tname : rpl \) = 0`
if [ x$RECORD = x1 ]; then if [ x$RECORD = x1 ]; then
extra_flags="-r" extra_flags="-r"
...@@ -451,29 +458,43 @@ run_testcase () ...@@ -451,29 +458,43 @@ run_testcase ()
stop_master stop_master
start_master start_master
else else
if [ ! -z EXTRA_MASTER_OPT ] || [ x$MASTER_RUNNING != x1 ] ; if [ ! -z $EXTRA_MASTER_OPT ] || [ x$MASTER_RUNNING != x1 ] ;
then then
EXTRA_MASTER_OPT="" EXTRA_MASTER_OPT=""
stop_master stop_master
start_master start_master
fi fi
fi fi
do_slave_restart=0
if [ -f $slave_opt_file ] ; if [ -f $slave_opt_file ] ;
then then
EXTRA_SLAVE_OPT=`cat $slave_opt_file` EXTRA_SLAVE_OPT=`cat $slave_opt_file`
stop_slave do_slave_restart=1
start_slave
else else
if [ ! -z EXTRA_SLAVE_OPT ] || [ x$SLAVE_RUNNING != x1 ] ; if [ ! -z $EXTRA_SLAVE_OPT ] || [ x$SLAVE_RUNNING != x1 ] ;
then then
EXTRA_SLAVE_OPT="" EXTRA_SLAVE_OPT=""
stop_slave do_slave_restart=1
start_slave
fi fi
fi fi
if [ -f $slave_master_info_file ] ; then
SLAVE_MASTER_INFO=`cat $slave_master_info_file`
do_slave_restart=1
else
if [ ! -z $SLAVE_MASTER_INFO ] || [ x$SLAVE_RUNNING != x1 ] ;
then
SLAVE_MASTER_INFO=""
do_slave_restart=1
fi
fi
if [ x$do_slave_restart = x1 ] ; then
stop_slave
start_slave
fi
cd $MYSQL_TEST_DIR cd $MYSQL_TEST_DIR
if [ -f $tf ] ; then if [ -f $tf ] ; then
......
File Position Binlog_do_db Binlog_ignore_db
master-bin.001 73
Master_Host Master_User Master_Port Connect_retry Log_File Pos Slave_Running Replicate_do_db Replicate_ignore_db
0 0 0 No
Master_Host Master_User Master_Port Connect_retry Log_File Pos Slave_Running Replicate_do_db Replicate_ignore_db
127.0.0.1 test 3306 60 4 No
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 4 No
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 4 Yes
n
10
45
90
connect (master,localhost,root,,test,0,var/tmp/mysql.sock);
connect (slave,localhost,root,,test,0,var/tmp/mysql-slave.sock);
connection master;
reset master;
show master status;
connection slave;
reset slave;
show slave status;
change master to master_host='127.0.0.1';
show slave status;
change master to master_host='127.0.0.1',master_user='root',
master_password='',master_port=9306;
show slave status;
slave start;
show slave status;
connection master;
drop table if exists foo;
create table foo (n int);
insert into foo values (10),(45),(90);
connection slave;
sleep 0.3;
select * from foo;
...@@ -515,7 +515,8 @@ int start_slave(THD* thd , bool net_report) ...@@ -515,7 +515,8 @@ int start_slave(THD* thd , bool net_report)
{ {
err = "cannot create slave thread"; err = "cannot create slave thread";
} }
pthread_cond_wait(&COND_slave_start, &LOCK_slave); while(!slave_running) // slave might already be running by now
pthread_cond_wait(&COND_slave_start, &LOCK_slave);
} }
else else
err = "Master host not set, or server id not configured"; err = "Master host not set, or server id not configured";
...@@ -552,7 +553,9 @@ int stop_slave(THD* thd, bool net_report ) ...@@ -552,7 +553,9 @@ int stop_slave(THD* thd, bool net_report )
// do not abort the slave in the middle of a query, so we do not set // do not abort the slave in the middle of a query, so we do not set
// thd->killed for the slave thread // thd->killed for the slave thread
thd->proc_info = "waiting for slave to die"; thd->proc_info = "waiting for slave to die";
pthread_cond_wait(&COND_slave_stopped, &LOCK_slave); while(slave_running) // we may miss slave start broadcast, if it starts
// very quickly
pthread_cond_wait(&COND_slave_stopped, &LOCK_slave);
} }
else else
err = "Slave is not running"; err = "Slave is not running";
...@@ -633,7 +636,8 @@ int change_master(THD* thd) ...@@ -633,7 +636,8 @@ int change_master(THD* thd)
abort_slave = 1; abort_slave = 1;
thr_alarm_kill(slave_real_id); thr_alarm_kill(slave_real_id);
thd->proc_info = "waiting for slave to die"; thd->proc_info = "waiting for slave to die";
pthread_cond_wait(&COND_slave_stopped, &LOCK_slave); // wait until done while(slave_running)
pthread_cond_wait(&COND_slave_stopped, &LOCK_slave); // wait until done
} }
pthread_mutex_unlock(&LOCK_slave); pthread_mutex_unlock(&LOCK_slave);
thd->proc_info = "changing master"; thd->proc_info = "changing master";
......
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