From d90d3bcafc220ca9d2cb2c80ff2db62247bf3e69 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 15 Apr 2002 17:09:30 -0600 Subject: reckless slave option bison 1.34 yacc rule compliance more robust handling of relay log corruption mysql-test/r/rpl000014.result: updated result mysql-test/r/rpl_log.result: updated result sql/mysqld.cc: reckless slave option sql/slave.cc: reckless slave + more robust handling of relay log corruption sql/slave.h: reckless slave sql/sql_yacc.yy: brought the rules into compliance with bison 1.34 by adding ';' at the end of each rule --- sql/slave.cc | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) (limited to 'sql/slave.cc') diff --git a/sql/slave.cc b/sql/slave.cc index 25b29732000..045ba57d8c7 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -191,11 +191,22 @@ int init_relay_log_pos(RELAY_LOG_INFO* rli,const char* log, pos = rli->relay_log_pos; // already inited else rli->relay_log_pos = pos; - if (rli->relay_log.find_first_log(&rli->linfo,log)) + + // test to see if the previous run was with the skip of purging + // if yes, we do not purge when we restart + if (rli->relay_log.find_first_log(&rli->linfo,"")) { *errmsg="Could not find first log during relay log initialization"; goto err; } + if (strcmp(log,rli->linfo.log_file_name)) + rli->skip_log_purge=1; + + if (rli->relay_log.find_first_log(&rli->linfo,log)) + { + *errmsg="Could not find target log during relay log initialization"; + goto err; + } strnmov(rli->relay_log_name,rli->linfo.log_file_name, sizeof(rli->relay_log_name)); // to make end_io_cache(&rli->cache_buf) safe in all cases @@ -2497,6 +2508,15 @@ Log_event* next_event(RELAY_LOG_INFO* rli) return ev; } DBUG_ASSERT(thd==rli->sql_thd); + if (opt_reckless_slave) + cur_log->error = 0; + if ( cur_log->error < 0) + { + errmsg = "slave SQL thread aborted because of I/O error"; + goto err; + } + + if (!cur_log->error) /* EOF */ { /* @@ -2605,12 +2625,12 @@ event(errno=%d,cur_log->error=%d)", my_errno,cur_log->error); // set read position to the beginning of the event my_b_seek(cur_log,rli->relay_log_pos+rli->pending); - // no need to hog the mutex while we sleep - pthread_mutex_unlock(&rli->data_lock); - safe_sleep(rli->sql_thd,1,(CHECK_KILLED_FUNC)sql_slave_killed, - (void*)rli); - pthread_mutex_lock(&rli->data_lock); + /* otherwise, we have had a partial read */ + /* TODO; see if there is a way to do this without this goto */ + errmsg = "Aborting slave SQL thread because of partial event read"; + goto err; } + } if (!errmsg && was_killed) errmsg = "slave SQL thread was killed"; -- cgit v1.2.1 From ff924d239d2f849d11749f25c3df624f41a3937c Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 18 Apr 2002 18:41:45 -0600 Subject: fixed assertion failure on corrupted log in reckless slave mode --- sql/slave.cc | 2 ++ 1 file changed, 2 insertions(+) (limited to 'sql/slave.cc') diff --git a/sql/slave.cc b/sql/slave.cc index 045ba57d8c7..930155206c2 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -1115,6 +1115,7 @@ static inline int add_relay_log(RELAY_LOG_INFO* rli,LOG_INFO* linfo) static bool wait_for_relay_log_space(RELAY_LOG_INFO* rli) { bool slave_killed; + LINT_INIT(slave_killed); MASTER_INFO* mi = rli->mi; const char* save_proc_info; THD* thd = mi->io_thd; @@ -2579,6 +2580,7 @@ Log_event* next_event(RELAY_LOG_INFO* rli) goto err; } rli->relay_log_pos = 4; + rli->pending=0; strnmov(rli->relay_log_name,rli->linfo.log_file_name, sizeof(rli->relay_log_name)); flush_relay_log_info(rli); -- cgit v1.2.1 From f96c4216601ed7b8a48ab48b4435d3b6fe134dea Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 25 Apr 2002 07:33:02 -0600 Subject: replication bugfixes sql/slave.cc: removed buggy loop sql/slave.h: fixed uninited variable use --- sql/slave.cc | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) (limited to 'sql/slave.cc') diff --git a/sql/slave.cc b/sql/slave.cc index 930155206c2..0af3823c1e0 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -1568,9 +1568,6 @@ command"); static ulong read_event(MYSQL* mysql, MASTER_INFO *mi) { ulong len = packet_error; - // for convinience lets think we start by - // being in the interrupted state :-) - int read_errno = EINTR; // my_real_read() will time us out // we check if we were told to die, and if not, try reading again @@ -1579,27 +1576,21 @@ static ulong read_event(MYSQL* mysql, MASTER_INFO *mi) return packet_error; #endif - while (!abort_loop && !mi->abort_slave && len == packet_error && - read_errno == EINTR ) - { - len = mc_net_safe_read(mysql); - read_errno = errno; - } - if (abort_loop || mi->abort_slave) - return packet_error; + len = mc_net_safe_read(mysql); + if (len == packet_error || (long) len < 1) { - sql_print_error("Error reading packet from server: %s (read_errno %d,\ + sql_print_error("Error reading packet from server: %s (\ server_errno=%d)", - mc_mysql_error(mysql), read_errno, mc_mysql_errno(mysql)); + mc_mysql_error(mysql), mc_mysql_errno(mysql)); return packet_error; } if (len == 1) { sql_print_error("Slave: received 0 length packet from server, apparent\ - master shutdown: %s (%d)", - mc_mysql_error(mysql), read_errno); + master shutdown: %s", + mc_mysql_error(mysql)); return packet_error; } -- cgit v1.2.1 From f508ec93b167eaec951d196d51c59baadbdfc55b Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 28 Apr 2002 21:22:37 +0000 Subject: init_dynamic_array MyODBC compatibility fix --- sql/slave.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sql/slave.cc') diff --git a/sql/slave.cc b/sql/slave.cc index 930155206c2..6d61ad95475 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -514,7 +514,7 @@ void init_table_rule_hash(HASH* h, bool* h_inited) void init_table_rule_array(DYNAMIC_ARRAY* a, bool* a_inited) { - init_dynamic_array(a, sizeof(TABLE_RULE_ENT*), TABLE_RULE_ARR_SIZE, + my_init_dynamic_array(a, sizeof(TABLE_RULE_ENT*), TABLE_RULE_ARR_SIZE, TABLE_RULE_ARR_SIZE); *a_inited = 1; } -- cgit v1.2.1 From 4acaf126ac4b2489626577c92ab8cabd52f35986 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 30 Apr 2002 16:40:46 +0300 Subject: Portability fix --- sql/slave.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'sql/slave.cc') diff --git a/sql/slave.cc b/sql/slave.cc index 956f21593e5..b473d8ab1e3 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -246,9 +246,10 @@ err: } /* called from get_options() in mysqld.cc on start-up */ -void init_slave_skip_errors(char* arg) + +void init_slave_skip_errors(const char* arg) { - char* p; + const char *p; my_bool last_was_digit = 0; if (bitmap_init(&slave_error_mask,MAX_SLAVE_ERROR,0)) { @@ -275,8 +276,11 @@ void init_slave_skip_errors(char* arg) } } -// we assume we have a run lock on rli and that the both slave thread -// are not running +/* + We assume we have a run lock on rli and that the both slave thread + are not running +*/ + int purge_relay_logs(RELAY_LOG_INFO* rli, bool just_reset, const char** errmsg) { DBUG_ENTER("purge_relay_logs"); -- cgit v1.2.1 From a19a2d95bfa6c006da364110603122c1f4d8290e Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 29 May 2002 15:20:36 +0300 Subject: Fixed a bug in make test, non-debug version. sql/slave.cc: Released some variables in non-debug version. These are needed in mysqld.cc my_getopt struct, which defines some options, which are used by mysql_test in a non-debug version. sql/sql_repl.cc: Released some variables in non-debug version. These are needed in mysqld.cc my_getopt struct, which defines some options, which are used by mysql_test in a non-debug version. --- sql/slave.cc | 2 -- 1 file changed, 2 deletions(-) (limited to 'sql/slave.cc') diff --git a/sql/slave.cc b/sql/slave.cc index b473d8ab1e3..8a0c95ba49c 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -48,12 +48,10 @@ ulong relay_log_space_limit = 0; /* TODO: fix variables to access ulonglong // can re-use them on slave start // TODO: move the vars below under MASTER_INFO -#ifndef DBUG_OFF int disconnect_slave_event_count = 0, abort_slave_event_count = 0; static int events_till_disconnect = -1; int events_till_abort = -1; static int stuck_count = 0; -#endif typedef enum { SLAVE_THD_IO, SLAVE_THD_SQL} SLAVE_THD_TYPE; -- cgit v1.2.1 From f1444392d887d9e9a7131911817814828562705e Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 2 Jun 2002 17:04:16 +0300 Subject: Fixed bug in wait_for_relay_log_space() Added checking of sem_init() in configure. client/mysqltest.c: Cleanup configure.in: Added checking of sem_init sql/hostname.cc: Portability fix sql/slave.cc: Fixed bug in wait_for_relay_log_space() --- sql/slave.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sql/slave.cc') diff --git a/sql/slave.cc b/sql/slave.cc index b473d8ab1e3..19e093a75d2 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -1118,11 +1118,11 @@ static inline int add_relay_log(RELAY_LOG_INFO* rli,LOG_INFO* linfo) static bool wait_for_relay_log_space(RELAY_LOG_INFO* rli) { - bool slave_killed; - LINT_INIT(slave_killed); + bool slave_killed=0; MASTER_INFO* mi = rli->mi; const char* save_proc_info; THD* thd = mi->io_thd; + DBUG_ENTER("wait_for_relay_log_space"); pthread_mutex_lock(&rli->log_space_lock); save_proc_info = thd->proc_info; -- cgit v1.2.1