Commit 1282838d authored by monty@bitch.mysql.fi's avatar monty@bitch.mysql.fi

Merge hundin:/my/mysql-4.0 into bitch.mysql.fi:/my/mysql-4.0

parents b14f5e2b da96aaed
...@@ -215,7 +215,7 @@ if ($opt_stage <= 5 && !$opt_no_test && !$opt_no_mysqltest) ...@@ -215,7 +215,7 @@ if ($opt_stage <= 5 && !$opt_no_test && !$opt_no_mysqltest)
{ {
system("mkdir $bench_tmpdir") if (! -d $bench_tmpdir); system("mkdir $bench_tmpdir") if (! -d $bench_tmpdir);
safe_cd("${test_dir}/mysql-test"); safe_cd("${test_dir}/mysql-test");
check_system("./mysql-test-run --tmpdir=$bench_tmpdir --master_port=$mysql_tcp_port --slave_port=$slave_port --manager-port=$manager_port --sleep=10", "tests were successful"); check_system("./mysql-test-run --tmpdir=$bench_tmpdir --master_port=$mysql_tcp_port --slave_port=$slave_port --manager-port=$manager_port --no-manager --sleep=10", "tests were successful");
} }
# Start the server if we are going to run any of the benchmarks # Start the server if we are going to run any of the benchmarks
......
...@@ -2433,7 +2433,7 @@ mysql> SHOW STATUS; ...@@ -2433,7 +2433,7 @@ mysql> SHOW STATUS;
If a bug or problem occurs while running @strong{mysqld}, try to provide an If a bug or problem occurs while running @strong{mysqld}, try to provide an
input script that will reproduce the anomaly. This script should include any input script that will reproduce the anomaly. This script should include any
necessary source files. The more closely the script can reproduce your necessary source files. The more closely the script can reproduce your
situation, the better. If you can make a repeatable test case, you should situation, the better. If you can make a reproduceable test case, you should
post this to @email{bugs@@lists.mysql.com} for a high priority treatment! post this to @email{bugs@@lists.mysql.com} for a high priority treatment!
If you can't provide a script, you should at least include the output If you can't provide a script, you should at least include the output
...@@ -4786,7 +4786,7 @@ Included in the MySQL distribution are two different testing suites, ...@@ -4786,7 +4786,7 @@ Included in the MySQL distribution are two different testing suites,
@file{mysql-test-run} and @file{mysql-test-run} and
@uref{http://www.mysql.com/information/crash-me.php,crash-me}, as well @uref{http://www.mysql.com/information/crash-me.php,crash-me}, as well
as a benchmark suite. The test system is actively updated with code to as a benchmark suite. The test system is actively updated with code to
test each new feature and almost all repeatable bugs that have come to test each new feature and almost all reproduceable bugs that have come to
our attention. We test MySQL with these on a lot of platforms before our attention. We test MySQL with these on a lot of platforms before
every release. These tests are more sophisticated than anything we have every release. These tests are more sophisticated than anything we have
seen from PostgreSQL, and they ensures that the MySQL is kept to a high seen from PostgreSQL, and they ensures that the MySQL is kept to a high
...@@ -17,27 +17,15 @@ ...@@ -17,27 +17,15 @@
#define MANAGER_CLIENT_VERSION "1.0" #define MANAGER_CLIENT_VERSION "1.0"
#include <my_global.h> #include <my_global.h>
#include <my_sys.h>
#include <m_string.h>
#include <mysql.h> #include <mysql.h>
#include <mysql_version.h> #include <mysql_version.h>
#include <m_ctype.h>
#ifdef OS2
#include <config-os2.h>
#else
#include <my_config.h>
#endif
#include <my_dir.h>
#include <hash.h>
#include <mysqld_error.h> #include <mysqld_error.h>
#include <stdio.h> #include <my_sys.h>
#include <stdlib.h> #include <m_string.h>
#include <getopt.h> #include <getopt.h>
#include <stdarg.h> #include <stdarg.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
#include <errno.h>
#include <violite.h>
#ifndef MYSQL_MANAGER_PORT #ifndef MYSQL_MANAGER_PORT
#define MYSQL_MANAGER_PORT 23546 #define MYSQL_MANAGER_PORT 23546
......
...@@ -181,7 +181,7 @@ Q_PING, Q_EVAL, ...@@ -181,7 +181,7 @@ Q_PING, Q_EVAL,
Q_RPL_PROBE, Q_ENABLE_RPL_PARSE, Q_RPL_PROBE, Q_ENABLE_RPL_PARSE,
Q_DISABLE_RPL_PARSE, Q_EVAL_RESULT, Q_DISABLE_RPL_PARSE, Q_EVAL_RESULT,
Q_ENABLE_QUERY_LOG, Q_DISABLE_QUERY_LOG, Q_ENABLE_QUERY_LOG, Q_DISABLE_QUERY_LOG,
Q_SERVER_START, Q_SERVER_STOP, Q_SERVER_START, Q_SERVER_STOP,Q_REQUIRE_MANAGER,
Q_UNKNOWN, /* Unknown command. */ Q_UNKNOWN, /* Unknown command. */
Q_COMMENT, /* Comments, ignored. */ Q_COMMENT, /* Comments, ignored. */
Q_COMMENT_WITH_COMMAND Q_COMMENT_WITH_COMMAND
...@@ -215,6 +215,7 @@ const char *command_names[] = { ...@@ -215,6 +215,7 @@ const char *command_names[] = {
"disable_rpl_parse", "eval_result", "disable_rpl_parse", "eval_result",
"enable_query_log", "disable_query_log", "enable_query_log", "disable_query_log",
"server_start", "server_stop", "server_start", "server_stop",
"require_manager",
0 0
}; };
...@@ -640,6 +641,13 @@ int open_file(const char* name) ...@@ -640,6 +641,13 @@ int open_file(const char* name)
return 0; return 0;
} }
int do_require_manager(struct st_query* __attribute__((unused)) q)
{
if (!manager)
abort_not_supported_test();
return 0;
}
#ifndef EMBEDDED_LIBRARY #ifndef EMBEDDED_LIBRARY
int do_server_start(struct st_query* q) int do_server_start(struct st_query* q)
{ {
...@@ -1930,7 +1938,9 @@ int run_query(MYSQL* mysql, struct st_query* q, int flags) ...@@ -1930,7 +1938,9 @@ int run_query(MYSQL* mysql, struct st_query* q, int flags)
ds= &ds_res; ds= &ds_res;
if ((flags & QUERY_SEND) && mysql_send_query(mysql, query, query_len)) if ((flags & QUERY_SEND) && mysql_send_query(mysql, query, query_len))
die("At line %u: unable to send query '%s'", start_lineno, query); die("At line %u: unable to send query '%s'(mysql_errno=%d,errno=%d)",
start_lineno, query,
mysql_errno(mysql), errno);
if ((flags & QUERY_SEND) && !disable_query_log) if ((flags & QUERY_SEND) && !disable_query_log)
{ {
dynstr_append_mem(ds,query,query_len); dynstr_append_mem(ds,query,query_len);
...@@ -2236,6 +2246,7 @@ int main(int argc, char** argv) ...@@ -2236,6 +2246,7 @@ int main(int argc, char** argv)
case Q_DISABLE_QUERY_LOG: disable_query_log=1; break; case Q_DISABLE_QUERY_LOG: disable_query_log=1; break;
case Q_SOURCE: do_source(q); break; case Q_SOURCE: do_source(q); break;
case Q_SLEEP: do_sleep(q); break; case Q_SLEEP: do_sleep(q); break;
case Q_REQUIRE_MANAGER: do_require_manager(q); break;
#ifndef EMBEDDED_LIBRARY #ifndef EMBEDDED_LIBRARY
case Q_SERVER_START: do_server_start(q); break; case Q_SERVER_START: do_server_start(q); break;
case Q_SERVER_STOP: do_server_stop(q); break; case Q_SERVER_STOP: do_server_stop(q); break;
......
...@@ -16,31 +16,30 @@ ...@@ -16,31 +16,30 @@
MA 02111-1307, USA */ MA 02111-1307, USA */
#include <my_global.h> #include <my_global.h>
#if defined(__WIN__) || defined(_WIN32) || defined(_WIN64) #if defined(THREAD)
#include <winsock.h> #include <my_pthread.h> /* because of signal() */
#include <odbcinst.h>
#endif #endif
#include "mysql.h"
#include "mysql_version.h"
#include "mysqld_error.h"
#include <my_sys.h> #include <my_sys.h>
#include <mysys_err.h> #include <mysys_err.h>
#include <m_string.h> #include <m_string.h>
#include <m_ctype.h> #include <m_ctype.h>
#include "mysql.h" #include <my_net.h>
#include "mysql_version.h" #include <errmsg.h>
#include "mysqld_error.h"
#include "errmsg.h"
#include <violite.h> #include <violite.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <signal.h> #include <signal.h>
#include <time.h>
#include <errno.h> #include <errno.h>
#ifdef HAVE_PWD_H #if defined(OS2)
#include <pwd.h> # include <sys/un.h>
#elif !defined( __WIN__)
#include <sys/resource.h>
#ifdef HAVE_SYS_UN_H
# include <sys/un.h>
#endif #endif
#if !defined(MSDOS) && !defined(__WIN__)
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h> #include <netdb.h>
#ifdef HAVE_SELECT_H #ifdef HAVE_SELECT_H
# include <select.h> # include <select.h>
...@@ -48,18 +47,13 @@ ...@@ -48,18 +47,13 @@
#ifdef HAVE_SYS_SELECT_H #ifdef HAVE_SYS_SELECT_H
#include <sys/select.h> #include <sys/select.h>
#endif #endif
#endif #include <sys/utsname.h>
#ifdef HAVE_SYS_UN_H #endif /* __WIN__ */
# include <sys/un.h>
#endif
#if defined(THREAD) && !defined(__WIN__)
#include <my_pthread.h> /* because of signal() */
#endif
#ifndef INADDR_NONE #ifndef INADDR_NONE
#define INADDR_NONE -1 #define INADDR_NONE -1
#endif #endif
#define RES_BUF_SHIFT 5 #define RES_BUF_SHIFT 5
#define SOCKET_ERROR -1 #define SOCKET_ERROR -1
#define NET_BUF_SIZE 2048 #define NET_BUF_SIZE 2048
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
DB=test DB=test
DBPASSWD= DBPASSWD=
VERBOSE="" VERBOSE=""
USE_MANAGER=0
TZ=GMT-3; export TZ # for UNIX_TIMESTAMP tests to work TZ=GMT-3; export TZ # for UNIX_TIMESTAMP tests to work
#++ #++
...@@ -162,6 +163,8 @@ while test $# -gt 0; do ...@@ -162,6 +163,8 @@ while test $# -gt 0; do
--ssl-ca=$BASEDIR/SSL/cacert.pem \ --ssl-ca=$BASEDIR/SSL/cacert.pem \
--ssl-cert=$BASEDIR/SSL/server-cert.pem \ --ssl-cert=$BASEDIR/SSL/server-cert.pem \
--ssl-key=$BASEDIR/SSL/server-key.pem" ;; --ssl-key=$BASEDIR/SSL/server-key.pem" ;;
--no-manager | --skip-manager) USE_MANAGER=0 ;;
--manager) USE_MANAGER=1 ;;
--skip-innobase) --skip-innobase)
EXTRA_MASTER_MYSQLD_OPT="$EXTRA_MASTER_MYSQLD_OPT --skip-innobase" EXTRA_MASTER_MYSQLD_OPT="$EXTRA_MASTER_MYSQLD_OPT --skip-innobase"
EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT --skip-innobase" ;; EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT --skip-innobase" ;;
...@@ -476,6 +479,7 @@ mysql_install_db () { ...@@ -476,6 +479,7 @@ mysql_install_db () {
for slave_num in 1 2 ; for slave_num in 1 2 ;
do do
rm -rf var/slave$slave_num-data/
mkdir -p var/slave$slave_num-data/mysql mkdir -p var/slave$slave_num-data/mysql
mkdir -p var/slave$slave_num-data/test mkdir -p var/slave$slave_num-data/test
cp var/slave-data/mysql/* var/slave$slave_num-data/mysql cp var/slave-data/mysql/* var/slave$slave_num-data/mysql
...@@ -533,6 +537,12 @@ abort_if_failed() ...@@ -533,6 +537,12 @@ abort_if_failed()
start_manager() start_manager()
{ {
if [ $USE_MANAGER = 0 ] ; then
echo "Manager disabled, skipping manager start. Tests requiring manager will\
be skipped"
return
fi
$ECHO "Starting MySQL Manager"
MYSQL_MANAGER_PW=`$MYSQL_MANAGER_PWGEN -u $MYSQL_MANAGER_USER \ MYSQL_MANAGER_PW=`$MYSQL_MANAGER_PWGEN -u $MYSQL_MANAGER_USER \
-o $MYSQL_MANAGER_PW_FILE` -o $MYSQL_MANAGER_PW_FILE`
$MYSQL_MANAGER --log=$MYSQL_MANAGER_LOG --port=$MYSQL_MANAGER_PORT \ $MYSQL_MANAGER --log=$MYSQL_MANAGER_LOG --port=$MYSQL_MANAGER_PORT \
...@@ -550,6 +560,9 @@ start_manager() ...@@ -550,6 +560,9 @@ start_manager()
stop_manager() stop_manager()
{ {
if [ $USE_MANAGER = 0 ] ; then
return
fi
$MYSQL_MANAGER_CLIENT $MANAGER_QUIET_OPT -u$MYSQL_MANAGER_USER \ $MYSQL_MANAGER_CLIENT $MANAGER_QUIET_OPT -u$MYSQL_MANAGER_USER \
-p$MYSQL_MANAGER_PW -P $MYSQL_MANAGER_PORT <<EOF -p$MYSQL_MANAGER_PW -P $MYSQL_MANAGER_PORT <<EOF
shutdown shutdown
...@@ -560,6 +573,11 @@ manager_launch() ...@@ -560,6 +573,11 @@ manager_launch()
{ {
ident=$1 ident=$1
shift shift
if [ $USE_MANAGER = 0 ] ; then
$@ >$CUR_MYERR 2>&1 &
sleep 2 #hack
return
fi
$MYSQL_MANAGER_CLIENT $MANAGER_QUIET_OPT --user=$MYSQL_MANAGER_USER \ $MYSQL_MANAGER_CLIENT $MANAGER_QUIET_OPT --user=$MYSQL_MANAGER_USER \
--password=$MYSQL_MANAGER_PW --port=$MYSQL_MANAGER_PORT <<EOF --password=$MYSQL_MANAGER_PW --port=$MYSQL_MANAGER_PORT <<EOF
def_exec $ident $@ def_exec $ident $@
...@@ -575,6 +593,11 @@ manager_term() ...@@ -575,6 +593,11 @@ manager_term()
{ {
ident=$1 ident=$1
shift shift
if [ $USE_MANAGER = 0 ] ; then
$MYSQLADMIN --no-defaults -uroot --socket=$MYSQL_TMP_DIR/$ident.sock -O \
connect_timeout=5 shutdown >/dev/null 2>&1
return
fi
$MYSQL_MANAGER_CLIENT $MANAGER_QUIET_OPT --user=$MYSQL_MANAGER_USER \ $MYSQL_MANAGER_CLIENT $MANAGER_QUIET_OPT --user=$MYSQL_MANAGER_USER \
--password=$MYSQL_MANAGER_PW --port=$MYSQL_MANAGER_PORT <<EOF --password=$MYSQL_MANAGER_PW --port=$MYSQL_MANAGER_PORT <<EOF
stop_exec $ident $STOP_WAIT_TIMEOUT stop_exec $ident $STOP_WAIT_TIMEOUT
...@@ -841,7 +864,10 @@ run_testcase () ...@@ -841,7 +864,10 @@ run_testcase ()
slave_init_script=$TESTDIR/$tname-slave.sh slave_init_script=$TESTDIR/$tname-slave.sh
slave_master_info_file=$TESTDIR/$tname-slave-master-info.opt slave_master_info_file=$TESTDIR/$tname-slave-master-info.opt
SKIP_SLAVE=`$EXPR \( $tname : rpl \) = 0` SKIP_SLAVE=`$EXPR \( $tname : rpl \) = 0`
many_slaves=`$EXPR \( $tname : rpl_failsafe \) != 0` if [ $USE_MANAGER = 1 ] ; then
many_slaves=`$EXPR \( $tname : rpl_failsafe \) != 0`
fi
if [ -n "$SKIP_TEST" ] ; then if [ -n "$SKIP_TEST" ] ; then
SKIP_THIS_TEST=`$EXPR \( $tname : "$SKIP_TEST" \) != 0` SKIP_THIS_TEST=`$EXPR \( $tname : "$SKIP_TEST" \) != 0`
if [ x$SKIP_THIS_TEST = x1 ] ; if [ x$SKIP_THIS_TEST = x1 ] ;
...@@ -952,7 +978,12 @@ run_testcase () ...@@ -952,7 +978,12 @@ run_testcase ()
timestr="$USERT $SYST $REALT" timestr="$USERT $SYST $REALT"
pname=`$ECHO "$tname "|$CUT -c 1-24` pname=`$ECHO "$tname "|$CUT -c 1-24`
RES="$pname $timestr" RES="$pname $timestr"
if [ x$many_slaves = x1 ] ; then
stop_slave 1
stop_slave 2
fi
if [ $res = 0 ]; then if [ $res = 0 ]; then
total_inc total_inc
pass_inc pass_inc
...@@ -1009,7 +1040,6 @@ then ...@@ -1009,7 +1040,6 @@ then
$MYSQLADMIN --no-defaults --socket=$SLAVE_MYSOCK -u root -O connect_timeout=5 shutdown > /dev/null 2>&1 $MYSQLADMIN --no-defaults --socket=$SLAVE_MYSOCK -u root -O connect_timeout=5 shutdown > /dev/null 2>&1
$ECHO "Installing Test Databases" $ECHO "Installing Test Databases"
mysql_install_db mysql_install_db
$ECHO "Starting MySQL Manager"
start_manager start_manager
#do not automagically start deamons if we are in gdb or running only one test #do not automagically start deamons if we are in gdb or running only one test
#case #case
......
...@@ -9,21 +9,25 @@ rpl_recovery_rank 1 ...@@ -9,21 +9,25 @@ rpl_recovery_rank 1
show status like 'Rpl_status'; show status like 'Rpl_status';
Variable_name Value Variable_name Value
Rpl_status AUTH_MASTER Rpl_status AUTH_MASTER
create table t1(n int);
drop table t1;
show variables like 'rpl_recovery_rank'; show variables like 'rpl_recovery_rank';
Variable_name Value Variable_name Value
rpl_recovery_rank 2 rpl_recovery_rank 2
show status like 'Rpl_status'; show status like 'Rpl_status';
Variable_name Value Variable_name Value
Rpl_status IDLE_SLAVE Rpl_status ACTIVE_SLAVE
slave start;
show variables like 'rpl_recovery_rank'; show variables like 'rpl_recovery_rank';
Variable_name Value Variable_name Value
rpl_recovery_rank 3 rpl_recovery_rank 3
show status like 'Rpl_status'; show status like 'Rpl_status';
Variable_name Value Variable_name Value
Rpl_status IDLE_SLAVE Rpl_status ACTIVE_SLAVE
slave start;
show variables like 'rpl_recovery_rank'; show variables like 'rpl_recovery_rank';
Variable_name Value Variable_name Value
rpl_recovery_rank 4 rpl_recovery_rank 4
show status like 'Rpl_status'; show status like 'Rpl_status';
Variable_name Value Variable_name Value
Rpl_status IDLE_SLAVE Rpl_status ACTIVE_SLAVE
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);
server_stop master; server_stop master;
......
require_manager;
source include/master-slave.inc; source include/master-slave.inc;
connect (slave_sec,localhost,root,,test,0,slave.sock-1); connect (slave_sec,localhost,root,,test,0,slave.sock-1);
connect (slave_ter,localhost,root,,test,0,slave.sock-2); connect (slave_ter,localhost,root,,test,0,slave.sock-2);
connection master; connection master;
show variables like 'rpl_recovery_rank'; show variables like 'rpl_recovery_rank';
show status like 'Rpl_status'; show status like 'Rpl_status';
create table t1(n int);
drop table t1;
save_master_pos;
connection slave; connection slave;
sync_with_master;
show variables like 'rpl_recovery_rank'; show variables like 'rpl_recovery_rank';
show status like 'Rpl_status'; show status like 'Rpl_status';
connection slave_sec; connection slave_sec;
slave start;
sync_with_master;
show variables like 'rpl_recovery_rank'; show variables like 'rpl_recovery_rank';
show status like 'Rpl_status'; show status like 'Rpl_status';
connection slave_ter; connection slave_ter;
slave start;
sync_with_master;
show variables like 'rpl_recovery_rank'; show variables like 'rpl_recovery_rank';
show status like 'Rpl_status'; show status like 'Rpl_status';
...@@ -70,7 +70,7 @@ for i in extra/comp_err extra/replace extra/perror extra/resolveip \ ...@@ -70,7 +70,7 @@ for i in extra/comp_err extra/replace extra/perror extra/resolveip \
client/.libs/mysql client/.libs/mysqlshow client/.libs/mysqladmin \ client/.libs/mysql client/.libs/mysqlshow client/.libs/mysqladmin \
client/.libs/mysqldump client/.libs/mysqlimport client/.libs/mysqltest \ client/.libs/mysqldump client/.libs/mysqlimport client/.libs/mysqltest \
client/.libs/mysqlcheck \ client/.libs/mysqlcheck \
client/.libs/mysqlmanagerc client/libs/mysqlmanager-pwgen \ client/.libs/mysqlmanagerc client/.libs/mysqlmanager-pwgen \
tools/.libs/mysqlmanager tools/.libs/mysqlmanager
do do
if [ -f $i ] if [ -f $i ]
......
...@@ -77,9 +77,7 @@ extern "C" { // Because of SCO 3.2V4.2 ...@@ -77,9 +77,7 @@ extern "C" { // Because of SCO 3.2V4.2
#include <sys/select.h> #include <sys/select.h>
#endif #endif
#include <sys/utsname.h> #include <sys/utsname.h>
#else #endif /* __WIN__ */
#include <windows.h>
#endif // __WIN__
#ifdef HAVE_LIBWRAP #ifdef HAVE_LIBWRAP
#include <tcpd.h> #include <tcpd.h>
......
...@@ -33,4 +33,11 @@ const char* rpl_status_type[] = {"AUTH_MASTER","ACTIVE_SLAVE","IDLE_SLAVE", ...@@ -33,4 +33,11 @@ const char* rpl_status_type[] = {"AUTH_MASTER","ACTIVE_SLAVE","IDLE_SLAVE",
TYPELIB rpl_status_typelib= {array_elements(rpl_status_type)-1,"", TYPELIB rpl_status_typelib= {array_elements(rpl_status_type)-1,"",
rpl_status_type}; rpl_status_type};
void change_rpl_status(RPL_STATUS from_status, RPL_STATUS to_status)
{
pthread_mutex_lock(&LOCK_rpl_status);
if (rpl_status == from_status || rpl_status == RPL_ANY)
rpl_status = to_status;
pthread_mutex_unlock(&LOCK_rpl_status);
}
...@@ -3,11 +3,14 @@ ...@@ -3,11 +3,14 @@
typedef enum {RPL_AUTH_MASTER=0,RPL_ACTIVE_SLAVE,RPL_IDLE_SLAVE, typedef enum {RPL_AUTH_MASTER=0,RPL_ACTIVE_SLAVE,RPL_IDLE_SLAVE,
RPL_LOST_SOLDIER,RPL_TROOP_SOLDIER, RPL_LOST_SOLDIER,RPL_TROOP_SOLDIER,
RPL_RECOVERY_CAPTAIN,RPL_NULL} RPL_STATUS; RPL_RECOVERY_CAPTAIN,RPL_NULL /* inactive */,
RPL_ANY /* wild card used by change_rpl_status */ } RPL_STATUS;
extern RPL_STATUS rpl_status; extern RPL_STATUS rpl_status;
extern pthread_mutex_t LOCK_rpl_status; extern pthread_mutex_t LOCK_rpl_status;
extern pthread_cond_t COND_rpl_status; extern pthread_cond_t COND_rpl_status;
extern TYPELIB rpl_role_typelib, rpl_status_typelib; extern TYPELIB rpl_role_typelib, rpl_status_typelib;
extern const char* rpl_role_type[], *rpl_status_type[]; extern const char* rpl_role_type[], *rpl_status_type[];
void change_rpl_status(RPL_STATUS from_status, RPL_STATUS to_status);
#endif #endif
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "mini_client.h" #include "mini_client.h"
#include "slave.h" #include "slave.h"
#include "sql_repl.h" #include "sql_repl.h"
#include "repl_failsafe.h"
#include <thr_alarm.h> #include <thr_alarm.h>
#include <my_dir.h> #include <my_dir.h>
...@@ -1220,6 +1221,7 @@ position %s", ...@@ -1220,6 +1221,7 @@ position %s",
thd->proc_info = "Waiting for slave mutex on exit"; thd->proc_info = "Waiting for slave mutex on exit";
pthread_mutex_lock(&LOCK_slave); pthread_mutex_lock(&LOCK_slave);
slave_running = 0; slave_running = 0;
change_rpl_status(RPL_ACTIVE_SLAVE,RPL_IDLE_SLAVE);
abort_slave = 0; abort_slave = 0;
save_temporary_tables = thd->temporary_tables; save_temporary_tables = thd->temporary_tables;
thd->temporary_tables = 0; // remove tempation from destructor to close them thd->temporary_tables = 0; // remove tempation from destructor to close them
...@@ -1257,6 +1259,7 @@ static int safe_connect(THD* thd, MYSQL* mysql, MASTER_INFO* mi) ...@@ -1257,6 +1259,7 @@ static int safe_connect(THD* thd, MYSQL* mysql, MASTER_INFO* mi)
if(!slave_was_killed) if(!slave_was_killed)
{ {
change_rpl_status(RPL_IDLE_SLAVE,RPL_ACTIVE_SLAVE);
mysql_log.write(thd, COM_CONNECT_OUT, "%s@%s:%d", mysql_log.write(thd, COM_CONNECT_OUT, "%s@%s:%d",
mi->user, mi->host, mi->port); mi->user, mi->host, mi->port);
#ifdef SIGNAL_WITH_VIO_CLOSE #ifdef SIGNAL_WITH_VIO_CLOSE
...@@ -1298,9 +1301,15 @@ static int safe_reconnect(THD* thd, MYSQL* mysql, MASTER_INFO* mi) ...@@ -1298,9 +1301,15 @@ static int safe_reconnect(THD* thd, MYSQL* mysql, MASTER_INFO* mi)
mi->connect_retry); mi->connect_retry);
safe_sleep(thd, mi->connect_retry); safe_sleep(thd, mi->connect_retry);
} }
if (err_count++ == master_retry_count) /* by default we try forever. The reason is that failure will trigger
master election, so if the user did not set master_retry_count we
do not want to have electioin triggered on the first failure to
connect
*/
if (master_retry_count && err_count++ == master_retry_count)
{ {
slave_was_killed=1; slave_was_killed=1;
change_rpl_status(RPL_ACTIVE_SLAVE,RPL_LOST_SOLDIER);
break; break;
} }
} }
......
...@@ -88,6 +88,8 @@ ...@@ -88,6 +88,8 @@
#define MAX_LAUNCHER_MSG 256 #define MAX_LAUNCHER_MSG 256
#endif #endif
#define MAX_RETRY_COUNT 100
/* Variable naming convention - if starts with manager_, either is set /* Variable naming convention - if starts with manager_, either is set
directly by the user, or used closely in ocnjunction with a variable directly by the user, or used closely in ocnjunction with a variable
set by the user set by the user
...@@ -1161,10 +1163,15 @@ static char* read_line(struct manager_thd* thd) ...@@ -1161,10 +1163,15 @@ static char* read_line(struct manager_thd* thd)
{ {
int len,read_len; int len,read_len;
char *block_end,*p_back; char *block_end,*p_back;
uint retry_count=0;
read_len = min(NET_BLOCK,(uint)(buf_end-p)); read_len = min(NET_BLOCK,(uint)(buf_end-p));
if ((len=vio_read(thd->vio,p,read_len))<=0) while ((len=vio_read(thd->vio,p,read_len))<=0)
{ {
log_err("Error reading command from client"); if (vio_should_retry(thd->vio) && retry_count++ < MAX_RETRY_COUNT)
continue;
log_err("Error reading command from client (Error: %d)",
vio_errno(thd->vio));
thd->fatal=1; thd->fatal=1;
return 0; return 0;
} }
......
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