mirror of
https://github.com/MariaDB/server.git
synced 2025-07-05 12:42:17 +03:00
Replication: small bug fixes in mysql-test-run.sh and in replication code (more reinitializations)
+ fix for #70 + test result fix for LOAD DATA LOCAL bug #82 client/mysqltest.c: Removed wrong comment and useless sleep mysql-test/mysql-test-run.sh: Fix $slave_datadir variable because this if [ -n "$1" ] ; slave_datadir="var/$slave_ident-data/" else slave_datadir=$SLAVE_MYDDIR was not coherent and led to problems of master.info not being deleted. Delete relay-log.info too. mysql-test/r/rpl000001.result: SUM is 1022 (1021 was when we had the LOAD DATA LOCAL bug #82). It's logical to have an even number as we load the same file twice. sql/slave.cc: When we RESET SLAVE, clear rli->master_log_* to give a good display in SHOW SLAVE STATUS ; seeing the old values may confuse the user. When we START SLAVE, clear rli->master_log_name, not only rli->master_log_pos. sql/sql_repl.cc: When we RESET SLAVE, clear mi->master_log_* to give a good display in SHOW SLAVE STATUS (bug #70)
This commit is contained in:
@ -994,13 +994,6 @@ int do_sync_with_master2(const char* p)
|
|||||||
if (rpl_parse)
|
if (rpl_parse)
|
||||||
mysql_enable_rpl_parse(mysql);
|
mysql_enable_rpl_parse(mysql);
|
||||||
|
|
||||||
#ifndef TO_BE_REMOVED
|
|
||||||
/*
|
|
||||||
We need this because wait_for_pos() only waits for the relay log,
|
|
||||||
which doesn't guarantee that the slave has executed the statement.
|
|
||||||
*/
|
|
||||||
my_sleep(2*1000000L);
|
|
||||||
#endif
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -810,8 +810,8 @@ start_master()
|
|||||||
$RM -f $MASTER_MYDDIR/log.*
|
$RM -f $MASTER_MYDDIR/log.*
|
||||||
# Remove stale binary logs
|
# Remove stale binary logs
|
||||||
$RM -f $MYSQL_TEST_DIR/var/log/master-bin.*
|
$RM -f $MYSQL_TEST_DIR/var/log/master-bin.*
|
||||||
# Remove old master.info files
|
# Remove old master.info and relay-log.info files
|
||||||
$RM -f $MYSQL_TEST_DIR/var/master-data/master.info
|
$RM -f $MYSQL_TEST_DIR/var/master-data/master.info $MYSQL_TEST_DIR/var/master-data/relay-log.info
|
||||||
|
|
||||||
#run master initialization shell script if one exists
|
#run master initialization shell script if one exists
|
||||||
|
|
||||||
@ -915,7 +915,7 @@ start_slave()
|
|||||||
slave_port=`expr $SLAVE_MYPORT + $1`
|
slave_port=`expr $SLAVE_MYPORT + $1`
|
||||||
slave_log="$SLAVE_MYLOG.$1"
|
slave_log="$SLAVE_MYLOG.$1"
|
||||||
slave_err="$SLAVE_MYERR.$1"
|
slave_err="$SLAVE_MYERR.$1"
|
||||||
slave_datadir="var/$slave_ident-data/"
|
slave_datadir="$SLAVE_MYDDIR/../$slave_ident-data/"
|
||||||
slave_pid="$MYRUN_DIR/mysqld-$slave_ident.pid"
|
slave_pid="$MYRUN_DIR/mysqld-$slave_ident.pid"
|
||||||
slave_sock="$SLAVE_MYSOCK-$1"
|
slave_sock="$SLAVE_MYSOCK-$1"
|
||||||
else
|
else
|
||||||
@ -930,7 +930,7 @@ start_slave()
|
|||||||
fi
|
fi
|
||||||
# Remove stale binary logs and old master.info files
|
# Remove stale binary logs and old master.info files
|
||||||
$RM -f $MYSQL_TEST_DIR/var/log/$slave_ident-*bin.*
|
$RM -f $MYSQL_TEST_DIR/var/log/$slave_ident-*bin.*
|
||||||
$RM -f $MYSQL_TEST_DIR/$slave_datadir/master.info
|
$RM -f $slave_datadir/master.info $slave_datadir/relay-log.info
|
||||||
|
|
||||||
#run slave initialization shell script if one exists
|
#run slave initialization shell script if one exists
|
||||||
if [ -f "$slave_init_script" ] ;
|
if [ -f "$slave_init_script" ] ;
|
||||||
|
@ -32,7 +32,7 @@ n
|
|||||||
2
|
2
|
||||||
select sum(length(word)) from t1;
|
select sum(length(word)) from t1;
|
||||||
sum(length(word))
|
sum(length(word))
|
||||||
1021
|
1022
|
||||||
drop table t1,t3;
|
drop table t1,t3;
|
||||||
reset master;
|
reset master;
|
||||||
slave stop;
|
slave stop;
|
||||||
|
33
sql/slave.cc
33
sql/slave.cc
@ -322,17 +322,37 @@ int purge_relay_logs(RELAY_LOG_INFO* rli, THD *thd, bool just_reset,
|
|||||||
{
|
{
|
||||||
int error=0;
|
int error=0;
|
||||||
DBUG_ENTER("purge_relay_logs");
|
DBUG_ENTER("purge_relay_logs");
|
||||||
|
|
||||||
|
/*
|
||||||
|
Even if rli->inited==0, we still try to empty rli->master_log_* variables.
|
||||||
|
Indeed, rli->inited==0 does not imply that they already are empty.
|
||||||
|
It could be that slave's info initialization partly succeeded :
|
||||||
|
for example if relay-log.info existed but *relay-bin*.*
|
||||||
|
have been manually removed, init_relay_log_info reads the old
|
||||||
|
relay-log.info and fills rli->master_log_*, then init_relay_log_info
|
||||||
|
checks for the existence of the relay log, this fails and
|
||||||
|
init_relay_log_info leaves rli->inited to 0.
|
||||||
|
In that pathological case, rli->master_log_pos* will be properly reinited
|
||||||
|
at the next START SLAVE (as RESET SLAVE or CHANGE
|
||||||
|
MASTER, the callers of purge_relay_logs, will delete bogus *.info files
|
||||||
|
or replace them with correct files), however if the user does SHOW SLAVE
|
||||||
|
STATUS before START SLAVE, he will see old, confusing rli->master_log_*.
|
||||||
|
In other words, we reinit rli->master_log_* for SHOW SLAVE STATUS
|
||||||
|
to display fine in any case.
|
||||||
|
*/
|
||||||
|
|
||||||
|
rli->master_log_name[0]= 0;
|
||||||
|
rli->master_log_pos= 0;
|
||||||
|
rli->pending= 0;
|
||||||
|
|
||||||
if (!rli->inited)
|
if (!rli->inited)
|
||||||
DBUG_RETURN(0); /* successfully do nothing */
|
DBUG_RETURN(0);
|
||||||
|
|
||||||
DBUG_ASSERT(rli->slave_running == 0);
|
DBUG_ASSERT(rli->slave_running == 0);
|
||||||
DBUG_ASSERT(rli->mi->slave_running == 0);
|
DBUG_ASSERT(rli->mi->slave_running == 0);
|
||||||
|
|
||||||
rli->slave_skip_counter=0;
|
rli->slave_skip_counter=0;
|
||||||
pthread_mutex_lock(&rli->data_lock);
|
pthread_mutex_lock(&rli->data_lock);
|
||||||
rli->pending=0;
|
|
||||||
rli->master_log_name[0]=0;
|
|
||||||
rli->master_log_pos=0; // 0 means uninitialized
|
|
||||||
if (rli->relay_log.reset_logs(thd))
|
if (rli->relay_log.reset_logs(thd))
|
||||||
{
|
{
|
||||||
*errmsg = "Failed during log reset";
|
*errmsg = "Failed during log reset";
|
||||||
@ -1193,8 +1213,9 @@ int init_relay_log_info(RELAY_LOG_INFO* rli, const char* info_fname)
|
|||||||
if (init_relay_log_pos(rli,NullS,BIN_LOG_HEADER_SIZE,0 /* no data lock */,
|
if (init_relay_log_pos(rli,NullS,BIN_LOG_HEADER_SIZE,0 /* no data lock */,
|
||||||
&msg))
|
&msg))
|
||||||
goto err;
|
goto err;
|
||||||
rli->master_log_pos = 0; // uninitialized
|
rli->master_log_name[0]= 0;
|
||||||
rli->info_fd = info_fd;
|
rli->master_log_pos= 0;
|
||||||
|
rli->info_fd= info_fd;
|
||||||
}
|
}
|
||||||
else // file exists
|
else // file exists
|
||||||
{
|
{
|
||||||
|
@ -734,12 +734,18 @@ int reset_slave(THD *thd, MASTER_INFO* mi)
|
|||||||
error=1;
|
error=1;
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
//delete relay logs, clear relay log coordinates
|
||||||
if ((error= purge_relay_logs(&mi->rli, thd,
|
if ((error= purge_relay_logs(&mi->rli, thd,
|
||||||
1 /* just reset */,
|
1 /* just reset */,
|
||||||
&errmsg)))
|
&errmsg)))
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
|
//Clear master's log coordinates (only for good display of SHOW SLAVE STATUS)
|
||||||
|
mi->master_log_name[0]= 0;
|
||||||
|
mi->master_log_pos= BIN_LOG_HEADER_SIZE;
|
||||||
|
//close master_info_file, relay_log_info_file, set mi->inited=rli->inited=0
|
||||||
end_master_info(mi);
|
end_master_info(mi);
|
||||||
|
//and delete these two files
|
||||||
fn_format(fname, master_info_file, mysql_data_home, "", 4+32);
|
fn_format(fname, master_info_file, mysql_data_home, "", 4+32);
|
||||||
if (my_stat(fname, &stat_area, MYF(0)) && my_delete(fname, MYF(MY_WME)))
|
if (my_stat(fname, &stat_area, MYF(0)) && my_delete(fname, MYF(MY_WME)))
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user