MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:He Zhenxing Date:November 19 2009 9:14am
Subject:bzr commit into mysql-5.1-telco-6.2 branch (zhenxing.he:3038) Bug#37148
View as plain text  
#At file:///media/sdb2/hezx/work/mysql/bzrwork/b37148/5.1-telco-6.2/ based on revid:pekka@stripped

 3038 He Zhenxing	2009-11-19
      BUG#37148 Most callers of mysql_bin_log.write ignore the return result
      
      This is the ndb part of the patch.
      
      The return value of mysql_bin_log.write was ignored by most callers,
      which may lead to inconsistent on master and slave if the transaction
      was committed while the binlog was not correctly written. If
      my_error() is call in mysql_bin_log.write, this could also lead to
      assertion issue if my_ok() or my_error() is called after.
      
      This fixed the problem by let the caller to check and handle the
      return value of mysql_bin_log.write. This patch only adresses the
      simple cases.
     @ sql/ha_ndbcluster_binlog.cc
        Changed ndb_binlog_query to return int instead of void, and return 1 if there is error writing the binlog

    M  sql/ha_ndbcluster_binlog.cc
=== modified file 'sql/ha_ndbcluster_binlog.cc'
--- a/sql/ha_ndbcluster_binlog.cc	2009-10-23 17:49:51 +0000
+++ b/sql/ha_ndbcluster_binlog.cc	2009-11-19 09:14:20 +0000
@@ -2279,7 +2279,7 @@ ndb_handle_schema_change(THD *thd, Ndb *
   DBUG_RETURN(0);
 }
 
-static void ndb_binlog_query(THD *thd, Cluster_schema *schema)
+static int ndb_binlog_query(THD *thd, Cluster_schema *schema)
 {
   /* any_value == 0 means local cluster sourced change that
    * should be logged
@@ -2293,7 +2293,7 @@ static void ndb_binlog_query(THD *thd, C
         sql_print_warning("NDB: unknown value for binlog signalling 0x%X, "
                           "query not logged",
                           schema->any_value);
-      return;
+      return 0;
     }
     else 
     {
@@ -2304,7 +2304,7 @@ static void ndb_binlog_query(THD *thd, C
       if (! g_ndb_log_slave_updates)
       {
         /* This MySQLD does not log slave updates */
-        return;
+        return 0;
       }
     }
   }
@@ -2318,12 +2318,13 @@ static void ndb_binlog_query(THD *thd, C
     thd->server_id= schema->any_value;
   thd->db= schema->db;
   int errcode = query_error_code(thd, thd->killed == THD::NOT_KILLED);
-  thd->binlog_query(THD::STMT_QUERY_TYPE, schema->query,
-                    schema->query_length, FALSE,
-                    schema->name[0] == 0 || thd->db[0] == 0,
-                    errcode);
+  int error= thd->binlog_query(THD::STMT_QUERY_TYPE, schema->query,
+                               schema->query_length, FALSE,
+                               schema->name[0] == 0 || thd->db[0] == 0,
+                               errcode);
   thd->server_id= thd_server_id_save;
   thd->db= thd_db_save;
+  return error;
 }
 
 static int
@@ -2562,8 +2563,9 @@ ndb_binlog_thread_handle_schema_event(TH
         case SOT_CLEAR_SLOCK:
           abort();
         }
-        if (log_query && ndb_binlog_running)
-          ndb_binlog_query(thd, schema);
+        if (log_query && ndb_binlog_running &&
+            ndb_binlog_query(thd, schema))
+          DBUG_RETURN(1);
         /* signal that schema operation has been handled */
         DBUG_DUMP("slock", (uchar*) schema->slock, schema->slock_length);
         if (bitmap_is_set(&slock, node_id))
@@ -2688,7 +2690,7 @@ ndb_binlog_thread_handle_schema_event(TH
   process any operations that should be done after
   the epoch is complete
 */
-static void
+static int
 ndb_binlog_thread_handle_schema_event_post_epoch(THD *thd,
                                                  List<Cluster_schema>
                                                  *post_epoch_log_list,
@@ -2696,7 +2698,7 @@ ndb_binlog_thread_handle_schema_event_po
                                                  *post_epoch_unlock_list)
 {
   if (post_epoch_log_list->elements == 0)
-    return;
+    return 0;
   DBUG_ENTER("ndb_binlog_thread_handle_schema_event_post_epoch");
   Cluster_schema *schema;
   Thd_ndb *thd_ndb= get_thd_ndb(thd);
@@ -3046,14 +3048,15 @@ ndb_binlog_thread_handle_schema_event_po
         share= 0;
       }
     }
-    if (ndb_binlog_running && log_query)
-      ndb_binlog_query(thd, schema);
+    if (ndb_binlog_running && log_query &&
+        ndb_binlog_query(thd, schema))
+      DBUG_RETURN(1);
   }
   while ((schema= post_epoch_unlock_list->pop()))
   {
     ndbcluster_update_slock(thd, schema->db, schema->name);
   }
-  DBUG_VOID_RETURN;
+  DBUG_RETURN(0);
 }
 
 /*
@@ -5126,10 +5129,11 @@ restart:
       {
         if (!pOp->hasError())
         {
-          ndb_binlog_thread_handle_schema_event(thd, s_ndb, pOp,
-                                                &post_epoch_log_list,
-                                                &post_epoch_unlock_list,
-                                                &mem_root);
+          if (ndb_binlog_thread_handle_schema_event(thd, s_ndb, pOp,
+                                                    &post_epoch_log_list,
+                                                    &post_epoch_unlock_list,
+                                                    &mem_root))
+            goto err;
           DBUG_PRINT("info", ("s_ndb first: %s", s_ndb->getEventOperation() ?
                               s_ndb->getEventOperation()->getEvent()->getTable()->getName() :
                               "<empty>"));
@@ -5355,11 +5359,12 @@ restart:
             field->store((longlong)gci);
             field->move_field_offset(-row_offset);
 
-            trans.write_row(::server_id,
-                            injector::transaction::table(apply_status_table, TRUE),
-                            &apply_status_table->s->all_set,
-                            apply_status_table->s->fields,
-                            apply_status_buf);
+            IF_DBUG(ret=) trans.write_row(::server_id,
+                                          injector::transaction::table(apply_status_table, TRUE),
+                                          &apply_status_table->s->all_set,
+                                          apply_status_table->s->fields,
+                                          apply_status_buf);
+            DBUG_ASSERT(ret == 0);
           }
           else
           {
@@ -5520,9 +5525,10 @@ restart:
       }
     }
 
-    ndb_binlog_thread_handle_schema_event_post_epoch(thd,
-                                                     &post_epoch_log_list,
-                                                     &post_epoch_unlock_list);
+    if (ndb_binlog_thread_handle_schema_event_post_epoch(thd,
+                                                         &post_epoch_log_list,
+                                                         &post_epoch_unlock_list))
+      goto err;
     free_root(&mem_root, MYF(0));
     *root_ptr= old_root;
     ndb_latest_handled_binlog_epoch= ndb_latest_received_binlog_epoch;


Attachment: [text/bzr-bundle] bzr/zhenxing.he@sun.com-20091119091420-dv49ux8tfq9p7koy.bundle
Thread
bzr commit into mysql-5.1-telco-6.2 branch (zhenxing.he:3038) Bug#37148He Zhenxing19 Nov