List:Commits« Previous MessageNext Message »
From:Mats Kindahl Date:April 12 2007 9:10am
Subject:bk commit into 5.1 tree (mats:1.2552)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of mats. When mats 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@stripped, 2007-04-12 09:10:45+02:00, mats@romeo.(none) +11 -0
  Merge romeo.(none):/home/bkroot/mysql-5.1-new-rpl
  into  romeo.(none):/home/bk/b25688-mysql-5.1-rpl
  MERGE: 1.2545.1.1

  sql/item_func.cc@stripped, 2007-04-12 09:10:34+02:00, mats@romeo.(none) +0 -0
    Auto merged
    MERGE: 1.367.4.1

  sql/log.cc@stripped, 2007-04-12 09:10:36+02:00, mats@romeo.(none) +0 -0
    Auto merged
    MERGE: 1.270.1.2

  sql/log_event.cc@stripped, 2007-04-12 09:10:37+02:00, mats@romeo.(none) +0 -0
    Auto merged
    MERGE: 1.271.1.5

  sql/mysqld.cc@stripped, 2007-04-12 09:10:37+02:00, mats@romeo.(none) +0 -0
    Auto merged
    MERGE: 1.628.1.1

  sql/repl_failsafe.cc@stripped, 2007-04-12 09:10:37+02:00, mats@romeo.(none) +0 -0
    Auto merged
    MERGE: 1.74.1.1

  sql/rpl_mi.h@stripped, 2007-04-12 09:10:37+02:00, mats@romeo.(none) +0 -0
    Auto merged
    MERGE: 1.2.1.1

  sql/set_var.cc@stripped, 2007-04-12 09:10:37+02:00, mats@romeo.(none) +0 -0
    Auto merged
    MERGE: 1.223.1.2

  sql/slave.cc@stripped, 2007-04-12 09:10:38+02:00, mats@romeo.(none) +0 -0
    Auto merged
    MERGE: 1.300.1.1

  sql/sql_class.cc@stripped, 2007-04-12 09:10:38+02:00, mats@romeo.(none) +0 -0
    Auto merged
    MERGE: 1.325.1.2

  sql/sql_insert.cc@stripped, 2007-04-12 09:10:38+02:00, mats@romeo.(none) +0 -0
    Auto merged
    MERGE: 1.257.1.1

  sql/sql_repl.cc@stripped, 2007-04-12 09:10:38+02:00, mats@romeo.(none) +0 -0
    Auto merged
    MERGE: 1.164.1.1

# 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:	mats
# Host:	romeo.(none)
# Root:	/home/bk/b25688-mysql-5.1-rpl/RESYNC

--- 1.377/sql/item_func.cc	2007-04-12 09:10:56 +02:00
+++ 1.378/sql/item_func.cc	2007-04-12 09:10:56 +02:00
@@ -22,6 +22,7 @@
 
 #include "mysql_priv.h"
 #include "slave.h"				// for wait_for_master_pos
+#include "rpl_mi.h"
 #include <m_ctype.h>
 #include <hash.h>
 #include <time.h>

--- 1.275/sql/log.cc	2007-04-12 09:10:56 +02:00
+++ 1.276/sql/log.cc	2007-04-12 09:10:56 +02:00
@@ -20,6 +20,7 @@
 #include "mysql_priv.h"
 #include "sql_repl.h"
 #include "rpl_filter.h"
+#include "rpl_rli.h"
 
 #include <my_dir.h>
 #include <stdarg.h>

--- 1.274/sql/log_event.cc	2007-04-12 09:10:56 +02:00
+++ 1.275/sql/log_event.cc	2007-04-12 09:10:56 +02:00
@@ -22,6 +22,8 @@
 
 #include "mysql_priv.h"
 #include "slave.h"
+#include "rpl_rli.h"
+#include "rpl_mi.h"
 #include "rpl_filter.h"
 #include "rpl_utility.h"
 #include <my_dir.h>
@@ -31,6 +33,8 @@
 
 #define log_cs	&my_charset_latin1
 
+#define FLAGSTR(V,F) ((V)&(F)?#F" ":"")
+
 /*
   Cache that will automatically be written to a dedicated file on
   destruction.
@@ -547,49 +551,7 @@
     Matz: I don't think we will need this check with this refactoring.
   */
   if (rli)
-  {
-    /*
-      If in a transaction, and if the slave supports transactions, just
-      inc_event_relay_log_pos(). We only have to check for OPTION_BEGIN
-      (not OPTION_NOT_AUTOCOMMIT) as transactions are logged with
-      BEGIN/COMMIT, not with SET AUTOCOMMIT= .
-
-      CAUTION: opt_using_transactions means
-      innodb || bdb ; suppose the master supports InnoDB and BDB,
-      but the slave supports only BDB, problems
-      will arise:
-      - suppose an InnoDB table is created on the master,
-      - then it will be MyISAM on the slave
-      - but as opt_using_transactions is true, the slave will believe he
-      is transactional with the MyISAM table. And problems will come
-      when one does START SLAVE; STOP SLAVE; START SLAVE; (the slave
-      will resume at BEGIN whereas there has not been any rollback).
-      This is the problem of using opt_using_transactions instead of a
-      finer "does the slave support
-      _the_transactional_handler_used_on_the_master_".
-
-      More generally, we'll have problems when a query mixes a
-      transactional handler and MyISAM and STOP SLAVE is issued in the
-      middle of the "transaction". START SLAVE will resume at BEGIN
-      while the MyISAM table has already been updated.
-    */
-    if ((thd->options & OPTION_BEGIN) && opt_using_transactions)
-      rli->inc_event_relay_log_pos();
-    else
-    {
-      rli->inc_group_relay_log_pos(log_pos);
-      flush_relay_log_info(rli);
-      /*
-         Note that Rotate_log_event::do_apply_event() does not call
-         this function, so there is no chance that a fake rotate event
-         resets last_master_timestamp.  Note that we update without
-         mutex (probably ok - except in some very rare cases, only
-         consequence is that value may take some time to display in
-         Seconds_Behind_Master - not critical).
-      */
-      rli->last_master_timestamp= when;
-    }
-  }
+    rli->stmt_done(log_pos, when);
 
   return 0;                                   // Cannot fail currently
 }
@@ -1039,6 +1001,10 @@
     break;
   }
 
+  DBUG_PRINT("read_event", ("%s(type_code: %d; event_len: %d)",
+                            ev ? ev->get_type_str() : "<unknown>",
+                            buf[EVENT_TYPE_OFFSET],
+                            event_len));
   /*
     is_valid() are small event-specific sanity tests which are
     important; for example there are some my_malloc() in constructors
@@ -3593,17 +3559,6 @@
 }
 #endif
 
-/**
-   Helper function to detect if the event is inside a group.
- */
-#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
-static bool is_in_group(THD *const thd, RELAY_LOG_INFO *const rli)
-{
-  return (thd->options & OPTION_BEGIN) != 0 ||
-         (rli->last_event_start_time > 0);
-}
-#endif
-
 
 /*
   Rotate_log_event::do_apply_event()
@@ -3654,7 +3609,7 @@
     relay log, which shall not change the group positions.
   */
   if ((server_id != ::server_id || rli->replicate_same_server_id) &&
-      !is_in_group(thd, rli))
+      !rli->is_in_group())
   {
     DBUG_PRINT("info", ("old group_master_log_name: '%s'  "
                         "old group_master_log_pos: %lu",
@@ -3821,6 +3776,12 @@
 #if defined(HAVE_REPLICATION)&& !defined(MYSQL_CLIENT)
 int Intvar_log_event::do_apply_event(RELAY_LOG_INFO const *rli)
 {
+  /*
+    We are now in a statement until the associated query log event has
+    been processed.
+   */
+  const_cast<RELAY_LOG_INFO*>(rli)->set_flag(RELAY_LOG_INFO::IN_STMT);
+
   switch (type) {
   case LAST_INSERT_ID_EVENT:
     thd->stmt_depends_on_first_successful_insert_id_in_prev_stmt= 1;
@@ -3921,6 +3882,12 @@
 #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
 int Rand_log_event::do_apply_event(RELAY_LOG_INFO const *rli)
 {
+  /*
+    We are now in a statement until the associated query log event has
+    been processed.
+   */
+  const_cast<RELAY_LOG_INFO*>(rli)->set_flag(RELAY_LOG_INFO::IN_STMT);
+
   thd->rand.seed1= (ulong) seed1;
   thd->rand.seed2= (ulong) seed2;
   return 0;
@@ -4315,6 +4282,12 @@
   double real_val;
   longlong int_val;
 
+  /*
+    We are now in a statement until the associated query log event has
+    been processed.
+   */
+  const_cast<RELAY_LOG_INFO*>(rli)->set_flag(RELAY_LOG_INFO::IN_STMT);
+
   if (is_null)
   {
     it= new Item_null();
@@ -6189,6 +6162,17 @@
     /* A small test to verify that objects have consistent types */
     DBUG_ASSERT(sizeof(thd->options) == sizeof(OPTION_RELAXED_UNIQUE_CHECKS));
 
+    /*
+      Now we are in a statement and will stay in a statement until we
+      see a STMT_END_F.
+
+      We set this flag here, before actually applying any rows, in
+      case the SQL thread is stopped and we need to detect that we're
+      inside a statement and halting abruptly might cause problems
+      when restarting.
+     */
+    const_cast<RELAY_LOG_INFO*>(rli)->set_flag(RELAY_LOG_INFO::IN_STMT);
+
     error= do_before_row_operations(table);
     while (error == 0 && row_start < (const char*) m_rows_end)
     {
@@ -6261,6 +6245,45 @@
     DBUG_RETURN(error);
   }
 
+  /*
+    This code would ideally be placed in do_update_pos() instead, but
+    since we have no access to table there, we do the setting of
+    last_event_start_time here instead.
+  */
+  if (table && (table->s->primary_key == MAX_KEY) &&
+      !cache_stmt && get_flags(STMT_END_F) == RLE_NO_FLAGS)
+  {
+    /*
+      ------------ Temporary fix until WL#2975 is implemented ---------
+
+      This event is not the last one (no STMT_END_F). If we stop now
+      (in case of terminate_slave_thread()), how will we restart? We
+      have to restart from Table_map_log_event, but as this table is
+      not transactional, the rows already inserted will still be
+      present, and idempotency is not guaranteed (no PK) so we risk
+      that repeating leads to double insert. So we desperately try to
+      continue, hope we'll eventually leave this buggy situation (by
+      executing the final Rows_log_event). If we are in a hopeless
+      wait (reached end of last relay log and nothing gets appended
+      there), we timeout after one minute, and notify DBA about the
+      problem.  When WL#2975 is implemented, just remove the member
+      st_relay_log_info::last_event_start_time and all its occurences.
+    */
+    const_cast<RELAY_LOG_INFO*>(rli)->last_event_start_time= time(0);
+  }
+
+  DBUG_RETURN(0);
+}
+
+int
+Rows_log_event::do_update_pos(RELAY_LOG_INFO *rli)
+{
+  DBUG_ENTER("Rows_log_event::do_update_pos");
+  int error= 0;
+
+  DBUG_PRINT("info", ("flags: %s",
+                      get_flags(STMT_END_F) ? "STMT_END_F " : ""));
+
   if (get_flags(STMT_END_F))
   {
     /*
@@ -6279,6 +6302,7 @@
       replicate-ignore rules).
     */
     thd->binlog_flush_pending_rows_event(true);
+
     /*
       If this event is not in a transaction, the call below will, if some
       transactional storage engines are involved, commit the statement into
@@ -6289,6 +6313,7 @@
       binlog.
     */
     error= ha_autocommit_or_rollback(thd, 0);
+
     /*
       Now what if this is not a transactional engine? we still need to
       flush the pending event to the binlog; we did it with
@@ -6300,11 +6325,17 @@
     */
 
     thd->reset_current_stmt_binlog_row_based();
-    const_cast<RELAY_LOG_INFO*>(rli)->cleanup_context(thd, 0);
-
+    rli->cleanup_context(thd, 0);
     if (error == 0)
     {
       /*
+        Indicate that a statement is finished.
+        Step the group log position if we are not in a transaction,
+        otherwise increase the event log position.
+       */
+      rli->stmt_done(log_pos, when);
+
+      /*
         Clear any errors pushed in thd->net.last_err* if for example "no key
         found" (as this is allowed). This is a safety measure; apparently
         those errors (e.g. when executing a Delete_rows_log_event of a
@@ -6316,38 +6347,15 @@
     }
     else
       slave_print_msg(ERROR_LEVEL, rli, error,
-                      "Error in %s event: commit of row events failed, "
-                      "table `%s`.`%s`",
-                      get_type_str(), table->s->db.str, 
-                      table->s->table_name.str);
-    DBUG_RETURN(error);
+                      "Error in %s event: commit of row events failed",
+                      get_type_str());
   }
-
-  if (table && (table->s->primary_key == MAX_KEY) && !cache_stmt)
+  else
   {
-    /*
-      ------------ Temporary fix until WL#2975 is implemented ---------
-
-      This event is not the last one (no STMT_END_F). If we stop now
-      (in case of terminate_slave_thread()), how will we restart? We
-      have to restart from Table_map_log_event, but as this table is
-      not transactional, the rows already inserted will still be
-      present, and idempotency is not guaranteed (no PK) so we risk
-      that repeating leads to double insert. So we desperately try to
-      continue, hope we'll eventually leave this buggy situation (by
-      executing the final Rows_log_event). If we are in a hopeless
-      wait (reached end of last relay log and nothing gets appended
-      there), we timeout after one minute, and notify DBA about the
-      problem.  When WL#2975 is implemented, just remove the member
-      st_relay_log_info::last_event_start_time and all its occurences.
-    */
-    const_cast<RELAY_LOG_INFO*>(rli)->last_event_start_time= time(0);
+    rli->inc_event_relay_log_pos();
   }
 
-  DBUG_ASSERT(error == 0);
-  thd->clear_error();
-
-  DBUG_RETURN(0);
+  DBUG_RETURN(error);
 }
 
 #endif /* !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) */
@@ -6431,7 +6439,9 @@
   {
     bool const last_stmt_event= get_flags(STMT_END_F);
     print_header(head, print_event_info, !last_stmt_event);
-    my_b_printf(head, "\t%s: table id %lu\n", name, m_table_id);
+    my_b_printf(head, "\t%s: table id %lu%s\n",
+                name, m_table_id,
+                last_stmt_event ? " flags: STMT_END_F" : "");
     print_base64(body, print_event_info, !last_stmt_event);
   }
 

--- 1.631/sql/mysqld.cc	2007-04-12 09:10:56 +02:00
+++ 1.632/sql/mysqld.cc	2007-04-12 09:10:56 +02:00
@@ -17,6 +17,7 @@
 #include <m_ctype.h>
 #include <my_dir.h>
 #include "slave.h"
+#include "rpl_mi.h"
 #include "sql_repl.h"
 #include "rpl_filter.h"
 #include "repl_failsafe.h"

--- 1.301/sql/slave.cc	2007-04-12 09:10:56 +02:00
+++ 1.302/sql/slave.cc	2007-04-12 09:10:56 +02:00
@@ -17,8 +17,9 @@
 
 #include <mysql.h>
 #include <myisam.h>
-#include "rpl_rli.h"
 #include "slave.h"
+#include "rpl_mi.h"
+#include "rpl_rli.h"
 #include "sql_repl.h"
 #include "rpl_filter.h"
 #include "repl_failsafe.h"
@@ -1736,11 +1737,12 @@
     /*
     */
 
-    DBUG_PRINT("info",("type_code=%d (%s), server_id=%d",
-                       type_code, ev->get_type_str(), ev->server_id));
-    DBUG_PRINT("info", ("thd->options={ %s%s}",
+    DBUG_PRINT("exec_event",("%s(type_code: %d; server_id: %d)",
+                       ev->get_type_str(), type_code, ev->server_id));
+    DBUG_PRINT("info", ("thd->options: %s%s; rli->last_event_start_time: %lu",
                         FLAGSTR(thd->options, OPTION_NOT_AUTOCOMMIT),
-                        FLAGSTR(thd->options, OPTION_BEGIN)));
+                        FLAGSTR(thd->options, OPTION_BEGIN),
+                        rli->last_event_start_time));
 
 
 
@@ -1782,21 +1784,21 @@
     if (reason == Log_event::EVENT_SKIP_NOT)
       exec_res= ev->apply_event(rli);
 #ifndef DBUG_OFF
-    else
-    {
-      /*
-        This only prints information to the debug trace.
+    /*
+      This only prints information to the debug trace.
 
-        TODO: Print an informational message to the error log?
-       */
-      static const char *const explain[] = {
-        "event was not skipped",                  // EVENT_SKIP_NOT,
-        "event originated from this server",      // EVENT_SKIP_IGNORE,
-        "event skip counter was non-zero"         // EVENT_SKIP_COUNT
-      };
-      DBUG_PRINT("info", ("%s was skipped because %s",
-                          ev->get_type_str(), explain[reason]));
-    }
+      TODO: Print an informational message to the error log?
+    */
+    static const char *const explain[] = {
+      // EVENT_SKIP_NOT,
+      "not skipped",
+      // EVENT_SKIP_IGNORE,
+      "skipped because event originated from this server",
+      // EVENT_SKIP_COUNT
+      "skipped because event skip counter was non-zero"
+    };
+    DBUG_PRINT("skip_event", ("%s event was %s",
+                              ev->get_type_str(), explain[reason]));
 #endif
 
     DBUG_PRINT("info", ("apply_event error = %d", exec_res));

--- 1.327/sql/sql_class.cc	2007-04-12 09:10:56 +02:00
+++ 1.328/sql/sql_class.cc	2007-04-12 09:10:56 +02:00
@@ -26,6 +26,7 @@
 #endif
 
 #include "mysql_priv.h"
+#include "rpl_rli.h"
 #include <my_bitmap.h>
 #include "log_event.h"
 #include <m_ctype.h>

--- 1.259/sql/sql_insert.cc	2007-04-12 09:10:56 +02:00
+++ 1.260/sql/sql_insert.cc	2007-04-12 09:10:56 +02:00
@@ -60,6 +60,7 @@
 #include "sql_select.h"
 #include "sql_show.h"
 #include "slave.h"
+#include "rpl_mi.h"
 
 #ifndef EMBEDDED_LIBRARY
 static TABLE *delayed_get_table(THD *thd,TABLE_LIST *table_list);

--- 1.3/sql/rpl_mi.h	2007-04-12 09:10:56 +02:00
+++ 1.4/sql/rpl_mi.h	2007-04-12 09:10:56 +02:00
@@ -18,6 +18,9 @@
 
 #ifdef HAVE_REPLICATION
 
+#include "rpl_rli.h"
+
+
 /*****************************************************************************
 
   Replication IO Thread

--- 1.228/sql/set_var.cc	2007-04-12 09:10:56 +02:00
+++ 1.229/sql/set_var.cc	2007-04-12 09:10:56 +02:00
@@ -51,6 +51,7 @@
 #include "mysql_priv.h"
 #include <mysql.h>
 #include "slave.h"
+#include "rpl_mi.h"
 #include <my_getopt.h>
 #include <thr_alarm.h>
 #include <myisam.h>

--- 1.75/sql/repl_failsafe.cc	2007-04-12 09:10:56 +02:00
+++ 1.76/sql/repl_failsafe.cc	2007-04-12 09:10:56 +02:00
@@ -19,6 +19,7 @@
 #include "repl_failsafe.h"
 #include "sql_repl.h"
 #include "slave.h"
+#include "rpl_mi.h"
 #include "rpl_filter.h"
 #include "log_event.h"
 #include <mysql.h>

--- 1.165/sql/sql_repl.cc	2007-04-12 09:10:56 +02:00
+++ 1.166/sql/sql_repl.cc	2007-04-12 09:10:56 +02:00
@@ -16,6 +16,7 @@
 #include "mysql_priv.h"
 #ifdef HAVE_REPLICATION
 
+#include "rpl_mi.h"
 #include "sql_repl.h"
 #include "log_event.h"
 #include "rpl_filter.h"
Thread
bk commit into 5.1 tree (mats:1.2552)Mats Kindahl12 Apr