Commit 8ebc9715 authored by sasha@mysql.sashanet.com's avatar sasha@mysql.sashanet.com

Merge work.mysql.com:/home/bk/mysql

into mysql.sashanet.com:/home/sasha/src/bk/mysql
parents 8dfd21ad 6b004aa7
jani@prima.mysql.com
jani@prima.mysql.fi
monty@donna.mysql.com
monty@work.mysql.com
paul@central.snake.net
sasha@mysql.sashanet.com
sasha@work.mysql.com
serg@serg.mysql.com
monty@work.mysql.com
......@@ -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,12 +335,19 @@ 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 \
--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 \
--basedir=$MY_BASEDIR \
--datadir=$SLAVE_MYDDIR \
......@@ -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,29 +458,43 @@ 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
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)
{
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
err = "Master host not set, or server id not configured";
......@@ -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
// thd->killed for the slave thread
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
err = "Slave is not running";
......@@ -633,7 +636,8 @@ int change_master(THD* thd)
abort_slave = 1;
thr_alarm_kill(slave_real_id);
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);
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