List:Commits« Previous MessageNext Message »
From:Alfranio Correia Date:October 27 2008 3:17am
Subject:bzr commit into mysql-5.0-bugteam branch (alfranio.correia:2704) Bug#40337
View as plain text  
#At file:///home/acorreia/workspace.sun/playground.mysql/mysql-5.0.68-custom_build/

 2704 Alfranio Correia	2008-10-27
      Introduced a recovery mechanism that throws away relay-log.bin* retrieved
      from a master. See BUG#40337.
modified:
  sql/mysql_priv.h
  sql/mysqld.cc
  sql/set_var.cc
  sql/slave.cc

per-file messages:
  sql/mysql_priv.h
    Created parameter --relay_log_throw, default = 0 thus keeping the original behavior.
  sql/mysqld.cc
    Created parameter --relay_log_throw, default = 0 thus keeping the original behavior.
  sql/set_var.cc
    Created parameter --relay_log_throw, default = 0 thus keeping the original behavior.
  sql/slave.cc
    Introduced the function init_recovery that is fired right after the startup and updates the master.info according to the relay-log.info and throws away (i.e. ignores) the old relay-log.bin.
=== modified file 'sql/mysql_priv.h'
--- a/sql/mysql_priv.h	2008-10-02 11:57:52 +0000
+++ b/sql/mysql_priv.h	2008-10-27 03:17:23 +0000
@@ -1313,7 +1313,7 @@ extern ulong specialflag, current_pid;
 extern ulong expire_logs_days, sync_binlog_period, sync_binlog_counter;
 extern ulong opt_tc_log_size, tc_log_max_pages_used, tc_log_page_size;
 extern ulong tc_log_page_waits;
-extern my_bool relay_log_purge, opt_innodb_safe_binlog, opt_innodb;
+extern my_bool relay_log_purge, relay_log_throw, opt_innodb_safe_binlog, opt_innodb;
 extern uint test_flags,select_errors,ha_open_options;
 extern uint protocol_version, mysqld_port, dropping_tables;
 extern uint delay_key_write_options, lower_case_table_names;

=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	2008-08-26 08:32:43 +0000
+++ b/sql/mysqld.cc	2008-10-27 03:17:23 +0000
@@ -404,7 +404,7 @@ ulong opt_ndb_cache_check_time;
 const char *opt_ndb_mgmd;
 ulong opt_ndb_nodeid;
 #endif
-my_bool opt_readonly, use_temp_pool, relay_log_purge;
+my_bool opt_readonly, use_temp_pool, relay_log_purge, relay_log_throw;
 my_bool opt_sync_frm, opt_allow_suspicious_udfs;
 my_bool opt_secure_auth= 0;
 char* opt_secure_file_priv= 0;
@@ -4918,6 +4918,7 @@ enum options_mysqld
   OPT_QUERY_CACHE_TYPE, OPT_QUERY_CACHE_WLOCK_INVALIDATE, OPT_RECORD_BUFFER,
   OPT_RECORD_RND_BUFFER, OPT_DIV_PRECINCREMENT, OPT_RELAY_LOG_SPACE_LIMIT,
   OPT_RELAY_LOG_PURGE,
+  OPT_RELAY_LOG_THROW,
   OPT_SLAVE_NET_TIMEOUT, OPT_SLAVE_COMPRESSED_PROTOCOL, OPT_SLOW_LAUNCH_TIME,
   OPT_SLAVE_TRANS_RETRIES, OPT_READONLY, OPT_DEBUGGING,
   OPT_SORT_BUFFER, OPT_TABLE_CACHE,
@@ -6302,6 +6303,11 @@ The minimum value for this variable is 4
    (gptr*) &relay_log_purge,
    (gptr*) &relay_log_purge, 0, GET_BOOL, NO_ARG,
    1, 0, 1, 0, 1, 0},
+  {"relay_log_throw", OPT_RELAY_LOG_THROW,
+   "0 = do not ignore retrieved relay logs. 1 = ignore retrieved relay logs.",
+   (gptr*) &relay_log_throw,
+   (gptr*) &relay_log_throw, 0, GET_BOOL, NO_ARG,
+   0, 0, 1, 0, 1, 0},
   {"relay_log_space_limit", OPT_RELAY_LOG_SPACE_LIMIT,
    "Maximum space to use for all relay logs.",
    (gptr*) &relay_log_space_limit,

=== modified file 'sql/set_var.cc'
--- a/sql/set_var.cc	2008-08-25 12:11:59 +0000
+++ b/sql/set_var.cc	2008-10-27 03:17:23 +0000
@@ -323,6 +323,8 @@ sys_var_thd_ulong	sys_div_precincrement(
 #ifdef HAVE_REPLICATION
 sys_var_bool_ptr	sys_relay_log_purge("relay_log_purge",
                                             &relay_log_purge);
+sys_var_bool_ptr	sys_relay_log_throw("relay_log_throw",
+                                            &relay_log_throw);
 #endif
 sys_var_long_ptr	sys_rpl_recovery_rank("rpl_recovery_rank",
 					      &rpl_recovery_rank);
@@ -733,6 +735,7 @@ sys_var *sys_variables[]=
   &sys_read_rnd_buff_size,
 #ifdef HAVE_REPLICATION
   &sys_relay_log_purge,
+  &sys_relay_log_throw,
 #endif
   &sys_rpl_recovery_rank,
   &sys_safe_updates,
@@ -1052,6 +1055,7 @@ struct show_var_st init_vars[]= {
   {"relay_log_index", (char*) &opt_relaylog_index_name, SHOW_CHAR_PTR},
   {"relay_log_info_file", (char*) &relay_log_info_file, SHOW_CHAR_PTR},
   {sys_relay_log_purge.name,  (char*) &sys_relay_log_purge,         SHOW_SYS},
+  {sys_relay_log_throw.name,  (char*) &sys_relay_log_throw,         SHOW_SYS},
   {"relay_log_space_limit",  (char*) &relay_log_space_limit,        SHOW_LONGLONG},
 #endif
   {sys_rpl_recovery_rank.name,(char*) &sys_rpl_recovery_rank,       SHOW_SYS},

=== modified file 'sql/slave.cc'
--- a/sql/slave.cc	2008-03-28 20:01:05 +0000
+++ b/sql/slave.cc	2008-10-27 03:17:23 +0000
@@ -66,6 +66,7 @@ static bool wait_for_relay_log_space(REL
 static inline bool io_slave_killed(THD* thd,MASTER_INFO* mi);
 static inline bool sql_slave_killed(THD* thd,RELAY_LOG_INFO* rli);
 static int count_relay_log_space(RELAY_LOG_INFO* rli);
+static int init_recovery(MASTER_INFO* mi);
 static int init_slave_thread(THD* thd, SLAVE_THD_TYPE thd_type);
 static int safe_connect(THD* thd, MYSQL* mysql, MASTER_INFO* mi);
 static int safe_reconnect(THD* thd, MYSQL* mysql, MASTER_INFO* mi,
@@ -174,6 +175,9 @@ int init_slave()
   if (server_id && !master_host && active_mi->host[0])
     master_host= active_mi->host;
 
+  if (init_recovery(active_mi))
+    goto err;
+
   /* If server id is not set, start_slave_thread() will say it */
 
   if (master_host && !opt_skip_slave_start)
@@ -197,6 +201,48 @@ err:
   DBUG_RETURN(1);
 }
 
+static int init_recovery(MASTER_INFO* mi)
+{
+  const char* errmsg=0;
+  DBUG_ENTER("recovery_init");
+
+  RELAY_LOG_INFO* rli = &mi->rli;
+  if (relay_log_throw && rli->group_master_log_name[0])
+  {
+    mi->master_log_pos = max(BIN_LOG_HEADER_SIZE,
+                              rli->group_master_log_pos);
+    strmake(mi->master_log_name, rli->group_master_log_name,
+      sizeof(mi->master_log_name)-1);
+
+    strmake(rli->group_relay_log_name, rli->relay_log.get_log_fname(),
+            sizeof(rli->group_relay_log_name)-1);
+    strmake(rli->event_relay_log_name, rli->relay_log.get_log_fname(),
+            sizeof(mi->rli.event_relay_log_name)-1);
+
+    rli->group_relay_log_pos = rli->group_relay_log_pos = BIN_LOG_HEADER_SIZE;
+
+    if (init_relay_log_pos(rli,
+                           rli->group_relay_log_name,
+                           rli->group_relay_log_pos,
+                           0 /*no data lock*/,
+                           &errmsg, 0))
+      DBUG_RETURN(1);
+
+    if (flush_master_info(mi, 0))
+    {
+      sql_print_error("Failed to flush master info file");
+      DBUG_RETURN(1);
+    }
+    if (flush_relay_log_info(rli))
+    {
+       sql_print_error("Failed to flush master info file");
+       DBUG_RETURN(1);
+    }
+  }
+
+  DBUG_RETURN(0);
+}
+
 
 static void free_table_ent(TABLE_RULE_ENT* e)
 {

Thread
bzr commit into mysql-5.0-bugteam branch (alfranio.correia:2704) Bug#40337Alfranio Correia27 Oct
Re: bzr commit into mysql-5.0-bugteam branch (alfranio.correia:2704)Bug#40337alfranio correia28 Oct