fixed

parent c1581940
......@@ -61,6 +61,9 @@ MYSQLD_SRC_DIRS="strings mysys include extra regex isam merge myisam \
GCOV_MSG=/tmp/mysqld-gcov.out #gcov output
GCOV_ERR=/tmp/mysqld-gcov.err
MASTER_RUNNING=0
SLAVE_RUNNING=0
[ -d $MY_TMP_DIR ] || mkdir -p $MY_TMP_DIR
[ -z $COLUMNS ] && COLUMNS=80
......@@ -141,6 +144,7 @@ if [ "$1" = "-force" ] ; then
shift 1
fi
if [ "$1" = "-record" ] ; then
RECORD=1
shift 1
......@@ -304,6 +308,7 @@ gcov_collect () {
start_master()
{
[ x$MASTER_RUNNING = 1 ] && return
cd $BASEDIR # for gcov
#start master
master_args="--no-defaults --log-bin=master-bin \
......@@ -330,11 +335,18 @@ start_master()
start_slave()
{
[ x$SKIP_SLAVE = x1 ] && return
slave_args="--no-defaults --server-id=2 \
--master-user=root \
[ x$SLAVE_RUNNING = 1 ] && return
if [ -z $SLAVE_MASTER_INFO ] ; then
master_info="--master-user=root \
--master-connect-retry=1 \
--master-host=127.0.0.1 \
--master-port=$MASTER_MYPORT \
--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 \
--basedir=$MY_BASEDIR \
......@@ -413,14 +425,8 @@ mysql_stop ()
mysql_restart () {
return 1
mysql_stop
res=$?
[ $res != 1 ] && echo_notok && error "Stopping mysqld"
mysql_start
res=$?
[ $res != 1 ] && echo_notok && error "Starting mysqld"
return 1
}
......@@ -438,6 +444,7 @@ run_testcase ()
tname=`$ECHO $tname | $CUT -d . -f 1`
master_opt_file=$TESTDIR/$tname-master.opt
slave_opt_file=$TESTDIR/$tname-slave.opt
slave_master_info_file=$TESTDIR/$tname-slave-master-info.opt
SKIP_SLAVE=`$EXPR \( $tname : rpl \) = 0`
if [ x$RECORD = x1 ]; then
extra_flags="-r"
......@@ -451,27 +458,41 @@ run_testcase ()
stop_master
start_master
else
if [ ! -z EXTRA_MASTER_OPT ] || [ x$MASTER_RUNNING != x1 ] ;
if [ ! -z $EXTRA_MASTER_OPT ] || [ x$MASTER_RUNNING != x1 ] ;
then
EXTRA_MASTER_OPT=""
stop_master
start_master
fi
fi
do_slave_restart=0
if [ -f $slave_opt_file ] ;
then
EXTRA_SLAVE_OPT=`cat $slave_opt_file`
stop_slave
start_slave
do_slave_restart=1
else
if [ ! -z EXTRA_SLAVE_OPT ] || [ x$SLAVE_RUNNING != x1 ] ;
if [ ! -z $EXTRA_SLAVE_OPT ] || [ x$SLAVE_RUNNING != x1 ] ;
then
EXTRA_SLAVE_OPT=""
stop_slave
start_slave
do_slave_restart=1
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
......
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,6 +515,7 @@ int start_slave(THD* thd , bool net_report)
{
err = "cannot create slave thread";
}
while(!slave_running) // slave might already be running by now
pthread_cond_wait(&COND_slave_start, &LOCK_slave);
}
else
......@@ -552,6 +553,8 @@ int stop_slave(THD* thd, bool net_report )
// do not abort the slave in the middle of a query, so we do not set
// thd->killed for the slave thread
thd->proc_info = "waiting for slave to die";
while(slave_running) // we may miss slave start broadcast, if it starts
// very quickly
pthread_cond_wait(&COND_slave_stopped, &LOCK_slave);
}
else
......@@ -633,6 +636,7 @@ int change_master(THD* thd)
abort_slave = 1;
thr_alarm_kill(slave_real_id);
thd->proc_info = "waiting for slave to die";
while(slave_running)
pthread_cond_wait(&COND_slave_stopped, &LOCK_slave); // wait until done
}
pthread_mutex_unlock(&LOCK_slave);
......
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