List:Internals« Previous MessageNext Message »
From:guilhem Date:October 11 2005 8:31am
Subject:bk commit into 5.0 tree (guilhem:1.2031) BUG#2122
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of guilhem. When guilhem does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.2031 05/10/11 10:31:32 guilhem@stripped +5 -0
  To help people avoid BUG#2122 "changing hostname confuses master or slave" until it's fixed,
  we now issue a warning (at slave's server startup only) when a relay log is named
  using the implicit hostname-relay-bin naming. Like we already do for binlogs.

  sql/sql_repl.cc
    1.143 05/10/11 10:31:28 guilhem@stripped +2 -2
    update for new prototype

  sql/slave.h
    1.91 05/10/11 10:31:28 guilhem@stripped +1 -1
    update for new prototype

  sql/slave.cc
    1.260 05/10/11 10:31:27 guilhem@stripped +20 -6
    To help people avoid BUG#2122 "changing hostname confuses master or slave" until it's fixed,
    we now issue a warning (at slave's server startup only) when a relay log is named
    using the implicit hostname-relay-bin naming. Like I had already added a similar startup warning
    when a binlog is named using the implicit hostname-bin naming.
    The want_warnings argument is because init_relay_log_info(), where the warning is issued (and that's
    the only good place for that, because we have 'ln' there), is called at startup and after RESET SLAVE
    (and user does not want to see a warning every time he does RESET SLAVE; one warning at startup
    is not obnoxious and is in line with the binlog warning).

  sql/repl_failsafe.cc
    1.58 05/10/11 10:31:27 guilhem@stripped +1 -1
    update for new prototype

  sql/mysqld.cc
    1.511 05/10/11 10:31:27 guilhem@stripped +4 -4
    fixing comment (back in time I had hope that the fix would be in 5.0...)

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	guilhem
# Host:	gbichot3.local
# Root:	/home/mysql_src/mysql-5.0

--- 1.510/sql/mysqld.cc	2005-10-09 12:44:57 +02:00
+++ 1.511/sql/mysqld.cc	2005-10-11 10:31:27 +02:00
@@ -2897,10 +2897,10 @@
     {
       /*
         User didn't give us info to name the binlog index file.
-        Picking `hostname`-bin.index like did in 4.x, causes replication to
-        fail if the hostname is changed later. So, we would like to instead
-        require a name. But as we don't want to break many existing setups, we
-        only give warning, not error.
+        Picking `hostname`-bin.index like we do, causes replication to
+        fail if this master's hostname is changed later. So, we would like to
+        instead require a name. But as we don't want to break many existing
+        setups, we only give warning, not error.
       */
       sql_print_warning("No argument was provided to --log-bin, and "
                         "--log-bin-index was not used; so replication "

--- 1.259/sql/slave.cc	2005-10-08 16:39:40 +02:00
+++ 1.260/sql/slave.cc	2005-10-11 10:31:27 +02:00
@@ -162,7 +162,7 @@
   }
 
   if (init_master_info(active_mi,master_info_file,relay_log_info_file,
-		       !master_host, (SLAVE_IO | SLAVE_SQL)))
+		       !master_host, (SLAVE_IO | SLAVE_SQL), 1))
   {
     sql_print_error("Failed to initialize the master info structure");
     goto err;
@@ -1685,7 +1685,7 @@
 
 
 static int init_relay_log_info(RELAY_LOG_INFO* rli,
-                               const char* info_fname)
+                               const char* info_fname, bool want_warnings)
 {
   char fname[FN_REFLEN+128];
   int info_fd;
@@ -1724,7 +1724,21 @@
     const char *ln;
     ln= rli->relay_log.generate_name(opt_relay_logname, "-relay-bin",
                                      1, buf);
-
+    if (!opt_relay_logname && !opt_relaylog_index_name && want_warnings)
+    {
+      /*
+        User didn't give us info to name the relay log index file.
+        Picking `hostname`-relay-bin.index like we do, causes replication to
+        fail if this slave's hostname is changed later. So, we would like to
+        instead require a name. But as we don't want to break many existing
+        setups, we only give warning, not error.
+      */
+      sql_print_warning("Neither --relay-log nor --relay-log-index were used;"
+                        " so replication "
+                        "may break when this MySQL server acts as a "
+                        "slave and has his hostname changed!! Please "
+                        "use '--relay-log=%s' to avoid this problem.", ln);
+    }
     /*
       note, that if open() fails, we'll still have index file open
       but a destructor will take care of that
@@ -2002,7 +2016,7 @@
 int init_master_info(MASTER_INFO* mi, const char* master_info_fname,
                      const char* slave_info_fname,
                      bool abort_if_no_master_info_file,
-                     int thread_mask)
+                     int thread_mask, bool want_warnings)
 {
   int fd,error;
   char fname[FN_REFLEN+128];
@@ -2191,7 +2205,7 @@
 			    (ulong) mi->master_log_pos));
 
   mi->rli.mi = mi;
-  if (init_relay_log_info(&mi->rli, slave_info_fname))
+  if (init_relay_log_info(&mi->rli, slave_info_fname, want_warnings))
     goto err;
 
   mi->inited = 1;
@@ -3273,7 +3287,7 @@
         */
         if (rli->trans_retries < slave_trans_retries)
         {
-          if (init_master_info(rli->mi, 0, 0, 0, SLAVE_SQL))
+          if (init_master_info(rli->mi, 0, 0, 0, SLAVE_SQL, 0))
             sql_print_error("Failed to initialize the master info structure");
           else if (init_relay_log_pos(rli,
                                       rli->group_relay_log_name,

--- 1.90/sql/slave.h	2005-10-08 16:39:41 +02:00
+++ 1.91/sql/slave.h	2005-10-11 10:31:28 +02:00
@@ -556,7 +556,7 @@
 int init_master_info(MASTER_INFO* mi, const char* master_info_fname,
 		     const char* slave_info_fname,
 		     bool abort_if_no_master_info_file,
-		     int thread_mask);
+		     int thread_mask, bool want_warnings);
 void end_master_info(MASTER_INFO* mi);
 void end_relay_log_info(RELAY_LOG_INFO* rli);
 void lock_slave_threads(MASTER_INFO* mi);

--- 1.57/sql/repl_failsafe.cc	2005-10-08 16:39:40 +02:00
+++ 1.58/sql/repl_failsafe.cc	2005-10-11 10:31:27 +02:00
@@ -916,7 +916,7 @@
         int error;
 
         if (init_master_info(active_mi, master_info_file, relay_log_info_file, 
-			     0, (SLAVE_IO | SLAVE_SQL)))
+			     0, (SLAVE_IO | SLAVE_SQL), 0))
           my_message(ER_MASTER_INFO, ER(ER_MASTER_INFO), MYF(0));
 	strmake(active_mi->master_log_name, row[0],
 		sizeof(active_mi->master_log_name));

--- 1.142/sql/sql_repl.cc	2005-09-13 13:06:27 +02:00
+++ 1.143/sql/sql_repl.cc	2005-10-11 10:31:28 +02:00
@@ -785,7 +785,7 @@
   if (thread_mask) //some threads are stopped, start them
   {
     if (init_master_info(mi,master_info_file,relay_log_info_file, 0,
-			 thread_mask))
+			 thread_mask, 0))
       slave_errno=ER_MASTER_INFO;
     else if (server_id_supplied && *mi->host)
     {
@@ -1083,7 +1083,7 @@
   LEX_MASTER_INFO* lex_mi= &thd->lex->mi;
   // TODO: see if needs re-write
   if (init_master_info(mi, master_info_file, relay_log_info_file, 0,
-		       thread_mask))
+		       thread_mask, 0))
   {
     my_message(ER_MASTER_INFO, ER(ER_MASTER_INFO), MYF(0));
     unlock_slave_threads(mi);
Thread
bk commit into 5.0 tree (guilhem:1.2031) BUG#2122guilhem11 Oct