summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <sasha@mysql.sashanet.com>2001-10-11 13:54:06 -0600
committerunknown <sasha@mysql.sashanet.com>2001-10-11 13:54:06 -0600
commit56303b0383da01a94293927c209a962effd930d0 (patch)
treed2e073808531804402cf154ac12d525851282b35 /sql
parent2f4e168159e72028633fe5005dd3e85211fc476e (diff)
downloadmariadb-git-56303b0383da01a94293927c209a962effd930d0.tar.gz
fixes for mysql-test to run without manager
a bit more work on failsafe replication client/mysqltest.c: added require_manager support mysql-test/mysql-test-run.sh: added --no-manager mysql-test/r/rpl_failsafe.result: updated result mysql-test/t/rpl000018.test: must have manager mysql-test/t/rpl_failsafe.test: must have manager sql/repl_failsafe.cc: more work sql/repl_failsafe.h: more work sql/slave.cc: update replication status for fail-safe replication on different events
Diffstat (limited to 'sql')
-rw-r--r--sql/repl_failsafe.cc7
-rw-r--r--sql/repl_failsafe.h5
-rw-r--r--sql/slave.cc11
3 files changed, 21 insertions, 2 deletions
diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc
index bdd63bd9a10..40eb3b8bb7c 100644
--- a/sql/repl_failsafe.cc
+++ b/sql/repl_failsafe.cc
@@ -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,"",
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);
+}
diff --git a/sql/repl_failsafe.h b/sql/repl_failsafe.h
index 95069404acb..42b386e6255 100644
--- a/sql/repl_failsafe.h
+++ b/sql/repl_failsafe.h
@@ -3,11 +3,14 @@
typedef enum {RPL_AUTH_MASTER=0,RPL_ACTIVE_SLAVE,RPL_IDLE_SLAVE,
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 pthread_mutex_t LOCK_rpl_status;
extern pthread_cond_t COND_rpl_status;
extern TYPELIB rpl_role_typelib, rpl_status_typelib;
extern const char* rpl_role_type[], *rpl_status_type[];
+
+void change_rpl_status(RPL_STATUS from_status, RPL_STATUS to_status);
#endif
diff --git a/sql/slave.cc b/sql/slave.cc
index d2e038bef88..7c065a89c9d 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -21,6 +21,7 @@
#include "mini_client.h"
#include "slave.h"
#include "sql_repl.h"
+#include "repl_failsafe.h"
#include <thr_alarm.h>
#include <my_dir.h>
@@ -1220,6 +1221,7 @@ position %s",
thd->proc_info = "Waiting for slave mutex on exit";
pthread_mutex_lock(&LOCK_slave);
slave_running = 0;
+ change_rpl_status(RPL_ACTIVE_SLAVE,RPL_IDLE_SLAVE);
abort_slave = 0;
save_temporary_tables = thd->temporary_tables;
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)
if(!slave_was_killed)
{
+ change_rpl_status(RPL_IDLE_SLAVE,RPL_ACTIVE_SLAVE);
mysql_log.write(thd, COM_CONNECT_OUT, "%s@%s:%d",
mi->user, mi->host, mi->port);
#ifdef SIGNAL_WITH_VIO_CLOSE
@@ -1298,9 +1301,15 @@ static int safe_reconnect(THD* thd, MYSQL* mysql, MASTER_INFO* mi)
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;
+ change_rpl_status(RPL_ACTIVE_SLAVE,RPL_LOST_SOLDIER);
break;
}
}