diff options
-rw-r--r-- | client/mysqltest.c | 9 | ||||
-rw-r--r-- | mysql-test/mysql-test-run.sh | 15 | ||||
-rw-r--r-- | mysql-test/r/rpl000016.result | 2 | ||||
-rw-r--r-- | mysql-test/r/rpl000017.result | 2 | ||||
-rw-r--r-- | mysql-test/t/rpl000012.test | 14 | ||||
-rw-r--r-- | mysql-test/t/rpl000013.test | 12 | ||||
-rw-r--r-- | mysql-test/t/rpl000016.test | 10 | ||||
-rw-r--r-- | mysql-test/t/rpl000017-slave.opt | 1 | ||||
-rwxr-xr-x | mysql-test/t/rpl000017-slave.sh | 9 | ||||
-rw-r--r-- | mysql-test/t/rpl000017.test | 19 | ||||
-rw-r--r-- | sql/slave.cc | 6 |
11 files changed, 83 insertions, 16 deletions
diff --git a/client/mysqltest.c b/client/mysqltest.c index b7c0c09579c..953f770240b 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -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)); diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh index a63e909d823..79fee8d493a 100644 --- a/mysql-test/mysql-test-run.sh +++ b/mysql-test/mysql-test-run.sh @@ -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` diff --git a/mysql-test/r/rpl000016.result b/mysql-test/r/rpl000016.result index 96e36475c92..39ea7234e2a 100644 --- a/mysql-test/r/rpl000016.result +++ b/mysql-test/r/rpl000016.result @@ -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 diff --git a/mysql-test/r/rpl000017.result b/mysql-test/r/rpl000017.result new file mode 100644 index 00000000000..e4f324047f8 --- /dev/null +++ b/mysql-test/r/rpl000017.result @@ -0,0 +1,2 @@ +n +24 diff --git a/mysql-test/t/rpl000012.test b/mysql-test/t/rpl000012.test index 495cb81167e..eddd3ede1d7 100644 --- a/mysql-test/t/rpl000012.test +++ b/mysql-test/t/rpl000012.test @@ -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; diff --git a/mysql-test/t/rpl000013.test b/mysql-test/t/rpl000013.test index f5056839791..f870d017fa3 100644 --- a/mysql-test/t/rpl000013.test +++ b/mysql-test/t/rpl000013.test @@ -13,20 +13,24 @@ 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 catch drop table +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 to go one more event +sync_with_master 1; @r/rpl000013.result select * from t2; @r/rpl000013.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; diff --git a/mysql-test/t/rpl000016.test b/mysql-test/t/rpl000016.test index e0e035a4ae0..fd30188ea89 100644 --- a/mysql-test/t/rpl000016.test +++ b/mysql-test/t/rpl000016.test @@ -31,28 +31,34 @@ insert into t2 values (34),(67),(123); save_master_pos; flush logs; show master logs; + #now lets make some duplicate key mess and see if we can recover from it + #first insert a value on the slave connection slave; sync_with_master; insert into t2 values(1234); + #same value on the master connection master; save_master_pos; insert into t2 values(1234); connection slave; sync_with_master; + #the slave may have already stopped, so we ignore the error !slave stop; + #restart slave skipping one event set sql_slave_skip_counter=1; slave start; + connection master; save_master_pos; + #let slave catch up connection slave; sync_with_master; -show slave status; connection master; purge master logs to 'master-bin.003'; show master logs; @@ -74,6 +80,8 @@ while ($1) show master logs; save_master_pos; connection slave; +slave stop; +slave start; sync_with_master; select count(*) from t3 where n = 4; #clean up diff --git a/mysql-test/t/rpl000017-slave.opt b/mysql-test/t/rpl000017-slave.opt new file mode 100644 index 00000000000..58a964c90d0 --- /dev/null +++ b/mysql-test/t/rpl000017-slave.opt @@ -0,0 +1 @@ +--skip-slave-start diff --git a/mysql-test/t/rpl000017-slave.sh b/mysql-test/t/rpl000017-slave.sh new file mode 100755 index 00000000000..fe875f1a778 --- /dev/null +++ b/mysql-test/t/rpl000017-slave.sh @@ -0,0 +1,9 @@ +cat > $MYSQL_TEST_DIR/var/slave-data/master.info <<EOF +master-bin.001 +4 +127.0.0.1 +root + +9306 +1 +EOF diff --git a/mysql-test/t/rpl000017.test b/mysql-test/t/rpl000017.test new file mode 100644 index 00000000000..c93d861bec8 --- /dev/null +++ b/mysql-test/t/rpl000017.test @@ -0,0 +1,19 @@ +connect (master,localhost,root,,test,0,mysql-master.sock); +connect (slave,localhost,root,,test,0,mysql-slave.sock); +connection master; +reset master; +connection slave; +slave start; +connection master; +drop table if exists t1; +create table t1(n int); +insert into t1 values(24); +save_master_pos; +connection slave; +sync_with_master; +select * from t1; +connection master; +drop table t1; +save_master_pos; +connection slave; +sync_with_master; diff --git a/sql/slave.cc b/sql/slave.cc index a798af7e0ed..58d1d173968 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -509,14 +509,14 @@ int init_master_info(MASTER_INFO* mi) return 1; } - if (!(length=my_b_gets(&mi->file, mi->log_file_name, - sizeof(mi->log_file_name)))) + if ((length=my_b_gets(&mi->file, mi->log_file_name, + sizeof(mi->log_file_name))) < 1) { msg="Error reading log file name from master info file "; goto error; } - mi->log_file_name[length]= 0; // kill \n + mi->log_file_name[length-1]= 0; // kill \n char buf[FN_REFLEN]; if(!my_b_gets(&mi->file, buf, sizeof(buf))) { |