Commit 877845dd authored by sasha@mysql.sashanet.com's avatar sasha@mysql.sashanet.com
Browse files

fixed improper read of log name from master.info which broke slave server restart

fixed sync bugs in three test cases
added offset argument to sync_with_master to mysqltest to be able to fix sync bugs
added a test case for slave startup with existing master.info
expanded mysql-test-run.sh to be able to run pre-start shell script initializations
parent 0ae142f5
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -485,14 +485,19 @@ int do_echo(struct st_query* q)
  return 0;
}

int do_sync_with_master()
int do_sync_with_master(struct st_query* q)
{
  MYSQL_RES* res;
  MYSQL_ROW row;
  MYSQL* mysql = &cur_con->mysql;
  char query_buf[FN_REFLEN+128];
  int offset = 0;
  char* p = q->first_argument;
  if(*p)
    offset = atoi(p);
  
  sprintf(query_buf, "select master_pos_wait('%s', %ld)", master_pos.file,
	  master_pos.pos);
	  master_pos.pos + offset);
  if(mysql_query(mysql, query_buf))
    die("At line %u: failed in %s: %d: %s", start_lineno, query_buf,
	mysql_errno(mysql), mysql_error(mysql));
+15 −0
Original line number Diff line number Diff line
@@ -72,6 +72,7 @@ cd ..
BASEDIR=`pwd`
cd $CWD
MYSQL_TEST_DIR=$BASEDIR/mysql-test
export MYSQL_TEST_DIR
STD_DATA=$MYSQL_TEST_DIR/std_data
hostname=`hostname`		# Installed in the mysql privilege table
  
@@ -336,6 +337,11 @@ gcov_collect () {
start_master()
{
    [ x$MASTER_RUNNING = 1 ] && return
    #run master initialization shell script if one exists
    if [ -f "$master_init_script" ] ;
    then
        /bin/sh $master_init_script
    fi
    cd $BASEDIR # for gcov
    # Remove old berkeley db log files that can confuse the server
    $RM -f $MASTER_MYDDIR/log.*	
@@ -375,6 +381,13 @@ start_slave()
{
    [ x$SKIP_SLAVE = x1 ] && return
    [ x$SLAVE_RUNNING = 1 ] && return
    
    #run slave initialization shell script if one exists
    if [ -f "$slave_init_script" ] ;
    then
	  /bin/sh $slave_init_script
    fi
    
    if [ -z "$SLAVE_MASTER_INFO" ] ; then
      master_info="--master-user=root \
	    --master-connect-retry=1 \
@@ -502,6 +515,8 @@ run_testcase ()
 tname=`$BASENAME $tf .test`
 master_opt_file=$TESTDIR/$tname-master.opt
 slave_opt_file=$TESTDIR/$tname-slave.opt
 master_init_script=$TESTDIR/$tname-master.sh
 slave_init_script=$TESTDIR/$tname-slave.sh
 slave_master_info_file=$TESTDIR/$tname-slave-master-info.opt
 SKIP_SLAVE=`$EXPR \( $tname : rpl \) = 0`

+0 −2
Original line number Diff line number Diff line
@@ -7,8 +7,6 @@ Log_name
master-bin.001
master-bin.002
master-bin.003
Master_Host	Master_User	Master_Port	Connect_retry	Log_File	Pos	Slave_Running	Replicate_do_db	Replicate_ignore_db	Last_errno	Last_error	Skip_counter
127.0.0.1	root	9306	60	master-bin.003	129	Yes			1062	error 'Duplicate entry '1234' for key 1' on query 'insert into t2 values(1234)'	0
Log_name
master-bin.003
Master_Host	Master_User	Master_Port	Connect_retry	Log_File	Pos	Slave_Running	Replicate_do_db	Replicate_ignore_db	Last_errno	Last_error	Skip_counter
+2 −0
Original line number Diff line number Diff line
n
24
+10 −4
Original line number Diff line number Diff line
@@ -10,20 +10,26 @@ connection master1;
create temporary table t1 (n int);
insert into t1 values (4),(5);
insert into t2 select * from t1;
save_master_pos;
disconnect master;
connection slave;

#add 1 to the saved position, so we will catch  drop table on disconnect
#for sure
sync_with_master 1;
connection master1;
insert into t2 values(6);
disconnect master1;
connect (master2,localhost,root,,test,0,mysql-master.sock);
connection master2;
save_master_pos;
disconnect master1;
connection slave;
sync_with_master;
#same trick - make sure we catch drop of temporary table on disconnect
sync_with_master 1;
@r/rpl000012.result select * from t2;
@r/rpl000012.status.result show status like 'Slave_open_temp_tables';
#
# Clean up
#
connect (master2,localhost,root,,test,0,mysql-master.sock);
connection master2;
drop table if exists t1,t2;
save_master_pos;
Loading