List:Commits« Previous MessageNext Message »
From:Andrei Elkin Date:March 28 2011 1:19pm
Subject:bzr commit into mysql-trunk branch (andrei.elkin:3312) Bug#11748510
View as plain text  
#At file:///home/andrei/MySQL/BZR/2a-23May/FIXES/bug11748510_36524_less_drama/ based on revid:andrei.elkin@stripped

 3312 Andrei Elkin	2011-03-28
      bug#11748510
      
      post-review cleanup patch to relocate has_temporary_error() into 
      Slave_reporting_capability class.
     @ sql/rpl_reporting.cc
        the func is moved from rpl_slave.cc to be converted into a method.
     @ sql/rpl_reporting.h
        a new member is arrived. #if !defined(EMBEDDED_LIBRARY) is a work-around of
        a wrong choice for rpl_reporting to be compiled in embedded built in the first place.
        A memo to reshape dependencies for embedded is left.
     @ sql/rpl_slave.cc
        moved into rpl_reporting.
     @ sql/rpl_slave.h
        has_temporary_error() is turned into Slave_reporting_capability::has_temporary_error

    modified:
      sql/rpl_reporting.cc
      sql/rpl_reporting.h
      sql/rpl_slave.cc
      sql/rpl_slave.h
=== modified file 'sql/rpl_reporting.cc'
--- a/sql/rpl_reporting.cc	2011-03-27 18:16:32 +0000
+++ b/sql/rpl_reporting.cc	2011-03-28 13:19:08 +0000
@@ -26,6 +26,79 @@ Slave_reporting_capability::Slave_report
                    &err_lock, MY_MUTEX_INIT_FAST);
 }
 
+#if !defined(EMBEDDED_LIBRARY)
+/**
+  Check if the current error is of temporary nature or not.
+  Some errors are temporary in nature, such as
+  ER_LOCK_DEADLOCK and ER_LOCK_WAIT_TIMEOUT.  Ndb also signals
+  that the error is temporary by pushing a warning with the error code
+  ER_GET_TEMPORARY_ERRMSG, if the originating error is temporary.
+
+  @param      thd  a THD instance, typically of the slave SQL thread's.
+  @error_arg  the error code for assessment. 
+              defaults to zero which makes the function check the top
+              of the reported errors stack.
+
+  @return 1 as the positive and 0 as the negative verdict
+*/
+int Slave_reporting_capability::has_temporary_error(THD *thd, uint error_arg) const
+{
+  uint error;
+  DBUG_ENTER("has_temporary_error");
+
+  DBUG_EXECUTE_IF("all_errors_are_temporary_errors",
+                  if (thd->stmt_da->is_error())
+                  {
+                    thd->clear_error();
+                    my_error(ER_LOCK_DEADLOCK, MYF(0));
+                  });
+
+  /*
+    The state of the slave thread can't be regarded as
+    experiencing a temporary failure in cases of @c is_slave_error was set TRUE,
+    or if there is no message in THD, we can't say if it's a temporary
+    error or not. This is currently the case for Incident_log_event,
+    which sets no message.
+  */
+  if (thd->is_fatal_error || !thd->is_error())
+    DBUG_RETURN(0);
+
+  error= (error_arg == 0)? thd->stmt_da->sql_errno() : error_arg;
+
+  /*
+    Temporary error codes:
+    currently, InnoDB deadlock detected by InnoDB or lock
+    wait timeout (innodb_lock_wait_timeout exceeded).
+    Notice, the temporary error requires slave_trans_retries != 0)
+  */
+  if (slave_trans_retries &&
+      (error == ER_LOCK_DEADLOCK || error == ER_LOCK_WAIT_TIMEOUT))
+    DBUG_RETURN(1);
+
+#ifdef HAVE_NDB_BINLOG
+  /*
+    currently temporary error set in ndbcluster
+  */
+  List_iterator_fast<MYSQL_ERROR> it(thd->warning_info->warn_list());
+  MYSQL_ERROR *err;
+  while ((err= it++))
+  {
+    DBUG_PRINT("info", ("has condition %d %s", err->get_sql_errno(),
+                        err->get_message_text()));
+    switch (err->get_sql_errno())
+    {
+    case ER_GET_TEMPORARY_ERRMSG:
+      DBUG_RETURN(1);
+    default:
+      break;
+    }
+  }
+#endif
+  DBUG_RETURN(0);
+}
+#endif // EMBEDDED_LIBRARY
+
+
 void
 Slave_reporting_capability::report(loglevel level, int err_code,
                                    const char *msg, ...) const

=== modified file 'sql/rpl_reporting.h'
--- a/sql/rpl_reporting.h	2010-08-05 17:45:25 +0000
+++ b/sql/rpl_reporting.h	2011-03-28 13:19:08 +0000
@@ -23,6 +23,11 @@
  */
 #define MAX_SLAVE_ERRMSG      1024
 
+// todo: consider to remove rpl_reporting.cc,h from building embedded
+#if !defined(EMBEDDED_LIBRARY)
+class THD;
+#endif
+
 /**
    Mix-in to handle the message logging and reporting for relay log
    info and master log info structures.
@@ -65,6 +70,13 @@ public:
     mysql_mutex_unlock(&err_lock);
   }
 
+#if !defined(EMBEDDED_LIBRARY)
+  /**
+     Check if the current error is of temporary nature or not.
+  */
+  int has_temporary_error(THD *thd, uint error_arg= 0) const;
+#endif // EMBEDDED_LIBRARY
+  
   /**
      Error information structure.
    */

=== modified file 'sql/rpl_slave.cc'
--- a/sql/rpl_slave.cc	2011-03-27 18:16:32 +0000
+++ b/sql/rpl_slave.cc	2011-03-28 13:19:08 +0000
@@ -2514,76 +2514,6 @@ static ulong read_event(MYSQL* mysql, Ma
   DBUG_RETURN(len - 1);
 }
 
-/**
-  Check if the current error is of temporary nature or not.
-  Some errors are temporary in nature, such as
-  ER_LOCK_DEADLOCK and ER_LOCK_WAIT_TIMEOUT.  Ndb also signals
-  that the error is temporary by pushing a warning with the error code
-  ER_GET_TEMPORARY_ERRMSG, if the originating error is temporary.
-
-  @param      thd  a THD instance, typically of the slave SQL thread's.
-  @error_arg  the error code for assessment. 
-              defaults to zero which makes the function check the top
-              of the reported errors stack.
-
-  @return 1 as the positive and 0 as the negative verdict
-*/
-int has_temporary_error(THD *thd, uint error_arg)
-{
-  uint error;
-  DBUG_ENTER("has_temporary_error");
-
-  DBUG_EXECUTE_IF("all_errors_are_temporary_errors",
-                  if (thd->stmt_da->is_error())
-                  {
-                    thd->clear_error();
-                    my_error(ER_LOCK_DEADLOCK, MYF(0));
-                  });
-
-  /*
-    The state of the slave thread can't be regarded as
-    experiencing a temporary failure in cases of @c is_slave_error was set TRUE,
-    or if there is no message in THD, we can't say if it's a temporary
-    error or not. This is currently the case for Incident_log_event,
-    which sets no message.
-  */
-  if (thd->is_fatal_error || !thd->is_error())
-    DBUG_RETURN(0);
-
-  error= (error_arg == 0)? thd->stmt_da->sql_errno() : error_arg;
-
-  /*
-    Temporary error codes:
-    currently, InnoDB deadlock detected by InnoDB or lock
-    wait timeout (innodb_lock_wait_timeout exceeded).
-    Notice, the temporary error requires slave_trans_retries != 0)
-  */
-  if (slave_trans_retries &&
-      (error == ER_LOCK_DEADLOCK || error == ER_LOCK_WAIT_TIMEOUT))
-    DBUG_RETURN(1);
-
-#ifdef HAVE_NDB_BINLOG
-  /*
-    currently temporary error set in ndbcluster
-  */
-  List_iterator_fast<MYSQL_ERROR> it(thd->warning_info->warn_list());
-  MYSQL_ERROR *err;
-  while ((err= it++))
-  {
-    DBUG_PRINT("info", ("has condition %d %s", err->get_sql_errno(),
-                        err->get_message_text()));
-    switch (err->get_sql_errno())
-    {
-    case ER_GET_TEMPORARY_ERRMSG:
-      DBUG_RETURN(1);
-    default:
-      break;
-    }
-  }
-#endif
-  DBUG_RETURN(0);
-}
-
 
 /**
   If this is a lagging slave (specified with CHANGE MASTER TO MASTER_DELAY = X), delays accordingly. Also unlocks rli->data_lock.
@@ -2974,7 +2904,7 @@ static int exec_relay_log_event(THD* thd
     if (slave_trans_retries)
     {
       int UNINIT_VAR(temp_err);
-      if (exec_res && (temp_err= has_temporary_error(thd)))
+      if (exec_res && (temp_err= rli->has_temporary_error(thd)))
       {
         const char *errmsg;
         /*

=== modified file 'sql/rpl_slave.h'
--- a/sql/rpl_slave.h	2011-03-27 18:16:32 +0000
+++ b/sql/rpl_slave.h	2011-03-28 13:19:08 +0000
@@ -213,7 +213,6 @@ void set_slave_thread_options(THD* thd);
 void set_slave_thread_default_charset(THD *thd, Relay_log_info const *rli);
 int apply_event_and_update_pos(Log_event* ev, THD* thd, Relay_log_info* rli);
 int rotate_relay_log(Master_info* mi);
-int has_temporary_error(THD *thd, uint err= 0);
 
 pthread_handler_t handle_slave_io(void *arg);
 pthread_handler_t handle_slave_sql(void *arg);


Attachment: [text/bzr-bundle] bzr/andrei.elkin@oracle.com-20110328131908-lw1qxs0ivrd0zr5h.bundle
Thread
bzr commit into mysql-trunk branch (andrei.elkin:3312) Bug#11748510Andrei Elkin28 Mar