Commit 27c70dc8 authored by guilhem@mysql.com's avatar guilhem@mysql.com

Merge gbichot@213.136.52.20:/home/bk/mysql-4.0

into mysql.com:/home/mysql_src/mysql-4.0
parents d640ff4a 96c8d91a
...@@ -1070,6 +1070,16 @@ stop_slave () ...@@ -1070,6 +1070,16 @@ stop_slave ()
fi fi
} }
stop_slave_threads ()
{
eval "this_slave_running=\$SLAVE$1_RUNNING"
slave_ident="slave$1"
if [ x$this_slave_running = x1 ]
then
$MYSQLADMIN --no-defaults -uroot --socket=$MYSQL_TMP_DIR/$slave_ident.sock stop-slave > /dev/null 2>&1
fi
}
stop_master () stop_master ()
{ {
if [ x$MASTER_RUNNING = x1 ] if [ x$MASTER_RUNNING = x1 ]
...@@ -1163,6 +1173,12 @@ run_testcase () ...@@ -1163,6 +1173,12 @@ run_testcase ()
return return
fi fi
# Stop all slave threads, so that we don't have useless reconnection attempts
# and error messages in case the slave and master servers restart.
stop_slave_threads
stop_slave_threads 1
stop_slave_threads 2
if [ -z "$USE_RUNNING_SERVER" ] ; if [ -z "$USE_RUNNING_SERVER" ] ;
then then
if [ -f $master_opt_file ] ; if [ -f $master_opt_file ] ;
......
reset master;
reset slave; reset slave;
slave start; slave start;
show master logs; show master logs;
......
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
require_manager; require_manager;
connect (master,localhost,root,,test,0,master.sock); connect (master,localhost,root,,test,0,master.sock);
connect (slave,localhost,root,,test,0,slave.sock); connect (slave,localhost,root,,test,0,slave.sock);
connection master;
reset master;
server_stop master; server_stop master;
server_start master; server_start master;
connection slave; connection slave;
......
...@@ -115,6 +115,8 @@ int init_slave() ...@@ -115,6 +115,8 @@ int init_slave()
{ {
DBUG_ENTER("init_slave"); DBUG_ENTER("init_slave");
/* This is called when mysqld starts */
/* /*
TODO: re-write this to interate through the list of files TODO: re-write this to interate through the list of files
for multi-master for multi-master
...@@ -126,11 +128,16 @@ int init_slave() ...@@ -126,11 +128,16 @@ int init_slave()
If master_host is specified, create the master_info file if it doesn't If master_host is specified, create the master_info file if it doesn't
exists. exists.
*/ */
if (!active_mi || if (!active_mi)
init_master_info(active_mi,master_info_file,relay_log_info_file, {
sql_print_error("Failed to allocate memory for the master info structure");
goto err;
}
if(init_master_info(active_mi,master_info_file,relay_log_info_file,
!master_host)) !master_host))
{ {
sql_print_error("Note: Failed to initialized master info"); sql_print_error("Failed to initialize the master info structure");
goto err; goto err;
} }
...@@ -150,7 +157,7 @@ int init_slave() ...@@ -150,7 +157,7 @@ int init_slave()
relay_log_info_file, relay_log_info_file,
SLAVE_IO | SLAVE_SQL)) SLAVE_IO | SLAVE_SQL))
{ {
sql_print_error("Warning: Can't create threads to handle slave"); sql_print_error("Failed to create slave threads");
goto err; goto err;
} }
} }
...@@ -1226,7 +1233,10 @@ int init_relay_log_info(RELAY_LOG_INFO* rli, const char* info_fname) ...@@ -1226,7 +1233,10 @@ int init_relay_log_info(RELAY_LOG_INFO* rli, const char* info_fname)
"-relay-bin", opt_relaylog_index_name, "-relay-bin", opt_relaylog_index_name,
LOG_BIN, 1 /* read_append cache */, LOG_BIN, 1 /* read_append cache */,
1 /* no auto events */)) 1 /* no auto events */))
{
sql_print_error("Failed in open_log() called from init_relay_log_info()");
DBUG_RETURN(1); DBUG_RETURN(1);
}
/* if file does not exist */ /* if file does not exist */
if (access(fname,F_OK)) if (access(fname,F_OK))
...@@ -1237,10 +1247,18 @@ int init_relay_log_info(RELAY_LOG_INFO* rli, const char* info_fname) ...@@ -1237,10 +1247,18 @@ int init_relay_log_info(RELAY_LOG_INFO* rli, const char* info_fname)
*/ */
if (info_fd >= 0) if (info_fd >= 0)
my_close(info_fd, MYF(MY_WME)); my_close(info_fd, MYF(MY_WME));
if ((info_fd = my_open(fname, O_CREAT|O_RDWR|O_BINARY, MYF(MY_WME))) < 0 || if ((info_fd = my_open(fname, O_CREAT|O_RDWR|O_BINARY, MYF(MY_WME))) < 0)
init_io_cache(&rli->info_file, info_fd, IO_SIZE*2, READ_CACHE, 0L,0, {
sql_print_error("Failed to create a new relay log info file (\
file '%s', errno %d)", fname, my_errno);
msg= current_thd->net.last_error;
goto err;
}
if (init_io_cache(&rli->info_file, info_fd, IO_SIZE*2, READ_CACHE, 0L,0,
MYF(MY_WME))) MYF(MY_WME)))
{ {
sql_print_error("Failed to create a cache on relay log info file (\
file '%s')", fname);
msg= current_thd->net.last_error; msg= current_thd->net.last_error;
goto err; goto err;
} }
...@@ -1248,7 +1266,11 @@ int init_relay_log_info(RELAY_LOG_INFO* rli, const char* info_fname) ...@@ -1248,7 +1266,11 @@ int init_relay_log_info(RELAY_LOG_INFO* rli, const char* info_fname)
/* Init relay log with first entry in the relay index file */ /* Init relay log with first entry in the relay index file */
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))
{
sql_print_error("Failed to open the relay log (relay_log_name='FIRST', \
relay_log_pos=4");
goto err; goto err;
}
rli->master_log_name[0]= 0; rli->master_log_name[0]= 0;
rli->master_log_pos= 0; rli->master_log_pos= 0;
rli->info_fd= info_fd; rli->info_fd= info_fd;
...@@ -1257,9 +1279,23 @@ int init_relay_log_info(RELAY_LOG_INFO* rli, const char* info_fname) ...@@ -1257,9 +1279,23 @@ int init_relay_log_info(RELAY_LOG_INFO* rli, const char* info_fname)
{ {
if (info_fd >= 0) if (info_fd >= 0)
reinit_io_cache(&rli->info_file, READ_CACHE, 0L,0,0); reinit_io_cache(&rli->info_file, READ_CACHE, 0L,0,0);
else if ((info_fd = my_open(fname, O_RDWR|O_BINARY, MYF(MY_WME))) < 0 || else
init_io_cache(&rli->info_file, info_fd, {
int error=0;
if ((info_fd = my_open(fname, O_RDWR|O_BINARY, MYF(MY_WME))) < 0)
{
sql_print_error("Failed to open the existing relay log info file (\
file '%s', errno %d)", fname, my_errno);
error= 1;
}
else if (init_io_cache(&rli->info_file, info_fd,
IO_SIZE*2, READ_CACHE, 0L, 0, MYF(MY_WME))) IO_SIZE*2, READ_CACHE, 0L, 0, MYF(MY_WME)))
{
sql_print_error("Failed to create a cache on relay log info file (\
file '%s')", fname);
error= 1;
}
if (error)
{ {
if (info_fd >= 0) if (info_fd >= 0)
my_close(info_fd, MYF(0)); my_close(info_fd, MYF(0));
...@@ -1268,6 +1304,7 @@ int init_relay_log_info(RELAY_LOG_INFO* rli, const char* info_fname) ...@@ -1268,6 +1304,7 @@ int init_relay_log_info(RELAY_LOG_INFO* rli, const char* info_fname)
pthread_mutex_unlock(&rli->data_lock); pthread_mutex_unlock(&rli->data_lock);
DBUG_RETURN(1); DBUG_RETURN(1);
} }
}
rli->info_fd = info_fd; rli->info_fd = info_fd;
int relay_log_pos, master_log_pos; int relay_log_pos, master_log_pos;
...@@ -1292,8 +1329,13 @@ int init_relay_log_info(RELAY_LOG_INFO* rli, const char* info_fname) ...@@ -1292,8 +1329,13 @@ int init_relay_log_info(RELAY_LOG_INFO* rli, const char* info_fname)
rli->relay_log_pos, rli->relay_log_pos,
0 /* no data lock*/, 0 /* no data lock*/,
&msg)) &msg))
{
char llbuf[22];
sql_print_error("Failed to open the relay log (relay_log_name='%s', \
relay_log_pos=%s", rli->relay_log_name, llstr(rli->relay_log_pos, llbuf));
goto err; goto err;
} }
}
DBUG_ASSERT(rli->relay_log_pos >= BIN_LOG_HEADER_SIZE); DBUG_ASSERT(rli->relay_log_pos >= BIN_LOG_HEADER_SIZE);
DBUG_ASSERT(my_b_tell(rli->cur_log) == rli->relay_log_pos); DBUG_ASSERT(my_b_tell(rli->cur_log) == rli->relay_log_pos);
/* /*
...@@ -1301,7 +1343,8 @@ int init_relay_log_info(RELAY_LOG_INFO* rli, const char* info_fname) ...@@ -1301,7 +1343,8 @@ int init_relay_log_info(RELAY_LOG_INFO* rli, const char* info_fname)
before flush_relay_log_info before flush_relay_log_info
*/ */
reinit_io_cache(&rli->info_file, WRITE_CACHE,0L,0,1); reinit_io_cache(&rli->info_file, WRITE_CACHE,0L,0,1);
error= flush_relay_log_info(rli); if ((error= flush_relay_log_info(rli)))
sql_print_error("Failed to flush relay log info file");
if (count_relay_log_space(rli)) if (count_relay_log_space(rli))
{ {
msg="Error counting relay log space"; msg="Error counting relay log space";
...@@ -1405,6 +1448,8 @@ int init_master_info(MASTER_INFO* mi, const char* master_info_fname, ...@@ -1405,6 +1448,8 @@ int init_master_info(MASTER_INFO* mi, const char* master_info_fname,
pthread_mutex_lock(&mi->data_lock); pthread_mutex_lock(&mi->data_lock);
fd = mi->fd; fd = mi->fd;
/* does master.info exist ? */
if (access(fname,F_OK)) if (access(fname,F_OK))
{ {
if (abort_if_no_master_info_file) if (abort_if_no_master_info_file)
...@@ -1418,10 +1463,19 @@ int init_master_info(MASTER_INFO* mi, const char* master_info_fname, ...@@ -1418,10 +1463,19 @@ int init_master_info(MASTER_INFO* mi, const char* master_info_fname,
*/ */
if (fd >= 0) if (fd >= 0)
my_close(fd, MYF(MY_WME)); my_close(fd, MYF(MY_WME));
if ((fd = my_open(fname, O_CREAT|O_RDWR|O_BINARY, MYF(MY_WME))) < 0 || if ((fd = my_open(fname, O_CREAT|O_RDWR|O_BINARY, MYF(MY_WME))) < 0 )
init_io_cache(&mi->file, fd, IO_SIZE*2, READ_CACHE, 0L,0, {
sql_print_error("Failed to create a new master info file (\
file '%s', errno %d)", fname, my_errno);
goto err;
}
if (init_io_cache(&mi->file, fd, IO_SIZE*2, READ_CACHE, 0L,0,
MYF(MY_WME))) MYF(MY_WME)))
{
sql_print_error("Failed to create a cache on master info file (\
file '%s')", fname);
goto err; goto err;
}
mi->master_log_name[0] = 0; mi->master_log_name[0] = 0;
mi->master_log_pos = BIN_LOG_HEADER_SIZE; // skip magic number mi->master_log_pos = BIN_LOG_HEADER_SIZE; // skip magic number
...@@ -1440,10 +1494,22 @@ int init_master_info(MASTER_INFO* mi, const char* master_info_fname, ...@@ -1440,10 +1494,22 @@ int init_master_info(MASTER_INFO* mi, const char* master_info_fname,
{ {
if (fd >= 0) if (fd >= 0)
reinit_io_cache(&mi->file, READ_CACHE, 0L,0,0); reinit_io_cache(&mi->file, READ_CACHE, 0L,0,0);
else if ((fd = my_open(fname, O_RDWR|O_BINARY, MYF(MY_WME))) < 0 || else
init_io_cache(&mi->file, fd, IO_SIZE*2, READ_CACHE, 0L, {
if ((fd = my_open(fname, O_RDWR|O_BINARY, MYF(MY_WME))) < 0 )
{
sql_print_error("Failed to open the existing master info file (\
file '%s', errno %d)", fname, my_errno);
goto err;
}
if (init_io_cache(&mi->file, fd, IO_SIZE*2, READ_CACHE, 0L,
0, MYF(MY_WME))) 0, MYF(MY_WME)))
{
sql_print_error("Failed to create a cache on master info file (\
file '%s')", fname);
goto err; goto err;
}
}
mi->fd = fd; mi->fd = fd;
int port, connect_retry, master_log_pos; int port, connect_retry, master_log_pos;
...@@ -1484,7 +1550,8 @@ int init_master_info(MASTER_INFO* mi, const char* master_info_fname, ...@@ -1484,7 +1550,8 @@ int init_master_info(MASTER_INFO* mi, const char* master_info_fname,
mi->inited = 1; mi->inited = 1;
// now change cache READ -> WRITE - must do this before flush_master_info // now change cache READ -> WRITE - must do this before flush_master_info
reinit_io_cache(&mi->file, WRITE_CACHE,0L,0,1); reinit_io_cache(&mi->file, WRITE_CACHE,0L,0,1);
error=test(flush_master_info(mi)); if ((error=test(flush_master_info(mi))))
sql_print_error("Failed to flush master info file");
pthread_mutex_unlock(&mi->data_lock); pthread_mutex_unlock(&mi->data_lock);
DBUG_RETURN(error); DBUG_RETURN(error);
......
...@@ -159,10 +159,18 @@ File open_binlog(IO_CACHE *log, const char *log_file_name, ...@@ -159,10 +159,18 @@ File open_binlog(IO_CACHE *log, const char *log_file_name,
File file; File file;
DBUG_ENTER("open_binlog"); DBUG_ENTER("open_binlog");
if ((file = my_open(log_file_name, O_RDONLY | O_BINARY, MYF(MY_WME))) < 0 || if ((file = my_open(log_file_name, O_RDONLY | O_BINARY, MYF(MY_WME))) < 0)
init_io_cache(log, file, IO_SIZE*2, READ_CACHE, 0, 0, {
sql_print_error("Failed to open log (\
file '%s', errno %d)", log_file_name, my_errno);
*errmsg = "Could not open log file"; // This will not be sent
goto err;
}
if (init_io_cache(log, file, IO_SIZE*2, READ_CACHE, 0, 0,
MYF(MY_WME | MY_DONT_CHECK_FILESIZE))) MYF(MY_WME | MY_DONT_CHECK_FILESIZE)))
{ {
sql_print_error("Failed to create a cache on log (\
file '%s')", log_file_name);
*errmsg = "Could not open log file"; // This will not be sent *errmsg = "Could not open log file"; // This will not be sent
goto err; goto err;
} }
...@@ -743,6 +751,9 @@ int reset_slave(THD *thd, MASTER_INFO* mi) ...@@ -743,6 +751,9 @@ int reset_slave(THD *thd, MASTER_INFO* mi)
//Clear master's log coordinates (only for good display of SHOW SLAVE STATUS) //Clear master's log coordinates (only for good display of SHOW SLAVE STATUS)
mi->master_log_name[0]= 0; mi->master_log_name[0]= 0;
mi->master_log_pos= BIN_LOG_HEADER_SIZE; mi->master_log_pos= BIN_LOG_HEADER_SIZE;
//Clear the errors displayed by SHOW SLAVE STATUS
mi->rli.last_slave_error[0]=0;
mi->rli.last_slave_errno=0;
//close master_info_file, relay_log_info_file, set mi->inited=rli->inited=0 //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 //and delete these two files
......
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