List:Commits« Previous MessageNext Message »
From:tomas Date:June 18 2007 7:37am
Subject:bk commit into 5.1 tree (tomas:1.2547)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of tomas. When tomas 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-06-18 07:37:35+02:00, tomas@stripped +6 -0
  Merge whalegate.ndb.mysql.com:/home/tomas/mysql-5.1-new-ndb
  into  whalegate.ndb.mysql.com:/home/tomas/mysql-5.1-telco
  MERGE: 1.2506.1.19

  mysql-test/r/ndb_restore.result@stripped, 2007-06-18 07:37:30+02:00, tomas@stripped +0 -0
    Auto merged
    MERGE: 1.23.1.3

  mysql-test/t/ndb_restore.test@stripped, 2007-06-18 07:37:30+02:00, tomas@stripped +0 -0
    Auto merged
    MERGE: 1.26.1.3

  sql/ha_ndbcluster.cc@stripped, 2007-06-18 07:37:30+02:00, tomas@stripped +0 -0
    Auto merged
    MERGE: 1.408.1.50

  sql/ha_ndbcluster.h@stripped, 2007-06-18 07:37:30+02:00, tomas@stripped +0 -0
    Auto merged
    MERGE: 1.170.3.9

  sql/ha_ndbcluster_binlog.cc@stripped, 2007-06-18 07:37:30+02:00, tomas@stripped +0 -0
    Auto merged
    MERGE: 1.104.3.13

  sql/mysqld.cc@stripped, 2007-06-18 07:37:31+02:00, tomas@stripped +0 -0
    Auto merged
    MERGE: 1.636.1.10

# 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:	tomas
# Host:	whalegate.ndb.mysql.com
# Root:	/home/tomas/mysql-5.1-telco/RESYNC

--- 1.643/sql/mysqld.cc	2007-05-23 08:06:22 +02:00
+++ 1.644/sql/mysqld.cc	2007-06-18 07:37:31 +02:00
@@ -1145,13 +1145,14 @@
   if (cleanup_done++)
     return; /* purecov: inspected */
 
-  logger.cleanup_base();
-
   /*
     make sure that handlers finish up
     what they have that is dependent on the binlog
   */
   ha_binlog_end(current_thd);
+
+  logger.cleanup_base();
+
   injector::free_instance();
   mysql_bin_log.cleanup();
 

--- 1.473/sql/ha_ndbcluster.cc	2007-06-15 09:17:21 +02:00
+++ 1.474/sql/ha_ndbcluster.cc	2007-06-18 07:37:30 +02:00
@@ -124,14 +124,14 @@
 #define ERR_RETURN(err)                  \
 {                                        \
   const NdbError& tmp= err;              \
-  ERR_PRINT(tmp);                        \
+  set_ndb_err(current_thd, tmp);         \
   DBUG_RETURN(ndb_to_mysql_error(&tmp)); \
 }
 
 #define ERR_BREAK(err, code)             \
 {                                        \
   const NdbError& tmp= err;              \
-  ERR_PRINT(tmp);                        \
+  set_ndb_err(current_thd, tmp);         \
   code= ndb_to_mysql_error(&tmp);        \
   break;                                 \
 }
@@ -577,13 +577,51 @@
   DBUG_VOID_RETURN;
 }
 
+/*
+  Sets the latest ndb error code on the thd_ndb object such that it
+  can be retrieved later to know which ndb error caused the handler
+  error.
+*/
+static void set_ndb_err(THD *thd, const NdbError &err)
+{
+  DBUG_ENTER("set_ndb_err");
+  ERR_PRINT(err);
+
+  Thd_ndb *thd_ndb= get_thd_ndb(thd);
+  if (thd_ndb == NULL)
+    DBUG_VOID_RETURN;
+#ifdef NOT_YET
+  /*
+    Check if error code is overwritten, in this case the original
+    failure cause will be lost.  E.g. if 4350 error is given. So
+    push a warning so that it can be detected which is the root
+    error cause.
+  */
+  if (thd_ndb->m_query_id == thd->query_id &&
+      thd_ndb->m_error_code != 0 &&
+      thd_ndb->m_error_code != err.code)
+  {
+    char buf[FN_REFLEN];
+    ndb_error_string(thd_ndb->m_error_code, buf, sizeof(buf));
+    push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
+			ER_GET_ERRMSG, ER(ER_GET_ERRMSG),
+			thd_ndb->m_error_code, buf, "NDB");
+  }
+#endif
+  thd_ndb->m_query_id= thd->query_id;
+  thd_ndb->m_error_code= err.code;
+  DBUG_VOID_RETURN;
+}
+
 int ha_ndbcluster::ndb_err(NdbTransaction *trans)
 {
+  THD *thd= current_thd;
   int res;
   NdbError err= trans->getNdbError();
   DBUG_ENTER("ndb_err");
   
-  ERR_PRINT(err);
+  set_ndb_err(thd, err);
+
   switch (err.classification) {
   case NdbError::SchemaError:
   {
@@ -594,7 +632,7 @@
     bzero((char*) &table_list,sizeof(table_list));
     table_list.db= m_dbname;
     table_list.alias= table_list.table_name= m_tabname;
-    close_cached_tables(current_thd, 0, &table_list);
+    close_cached_tables(thd, 0, &table_list);
     break;
   }
   default:
@@ -5145,7 +5183,7 @@
   {
     const NdbError err= trans->getNdbError();
     const NdbOperation *error_op= trans->getNdbErrorOperation();
-    ERR_PRINT(err);
+    set_ndb_err(thd, err);
     res= ndb_to_mysql_error(&err);
     if (res != -1)
       ndbcluster_print_error(res, error_op);
@@ -5196,7 +5234,7 @@
   {
     const NdbError err= trans->getNdbError();
     const NdbOperation *error_op= trans->getNdbErrorOperation();
-    ERR_PRINT(err);     
+    set_ndb_err(thd, err);
     res= ndb_to_mysql_error(&err);
     if (res != -1) 
       ndbcluster_print_error(res, error_op);
@@ -5792,7 +5830,7 @@
   if (dict->createTable(tab) != 0) 
   {
     const NdbError err= dict->getNdbError();
-    ERR_PRINT(err);
+    set_ndb_err(thd, err);
     my_errno= ndb_to_mysql_error(&err);
     DBUG_RETURN(my_errno);
   }
@@ -5806,7 +5844,7 @@
   {
     /* purecov: begin deadcode */
     const NdbError err= dict->getNdbError();
-    ERR_PRINT(err);
+    set_ndb_err(thd, err);
     my_errno= ndb_to_mysql_error(&err);
     DBUG_RETURN(my_errno);
     /* purecov: end */
@@ -5978,6 +6016,7 @@
     new_tab.setFrm(pack_data, pack_length);
     if (dict->alterTableGlobal(*tab, new_tab))
     {
+      set_ndb_err(current_thd, dict->getNdbError());
       error= ndb_to_mysql_error(&dict->getNdbError());
     }
     my_free((char*)data, MYF(MY_ALLOW_ZERO_PTR));
@@ -6453,6 +6492,7 @@
         default:
           break;
       }
+      set_ndb_err(thd, dict->getNdbError());
       res= ndb_to_mysql_error(&dict->getNdbError());
       DBUG_PRINT("info", ("error(1) %u", res));
     }
@@ -6492,6 +6532,7 @@
           }
         }
       }
+      set_ndb_err(thd, dict->getNdbError());
       res= ndb_to_mysql_error(&dict->getNdbError());
       DBUG_PRINT("info", ("error(2) %u", res));
       break;
@@ -6878,6 +6919,7 @@
     Ndb *ndb= get_ndb();
     if (ndb->setDatabaseName(m_dbname))
     {
+      set_ndb_err(current_thd, ndb->getNdbError());
       res= ndb_to_mysql_error(&ndb->getNdbError());
       break;
     }
@@ -7239,7 +7281,7 @@
       const NdbError err= dict->getNdbError();
       if (err.code != 709 && err.code != 723)
       {
-        ERR_PRINT(err);
+        set_ndb_err(thd, err);
         ret= ndb_to_mysql_error(&err);
       }
     }
@@ -9259,6 +9301,7 @@
       my_sleep(retry_sleep);
       continue;
     }
+    set_ndb_err(current_thd, error);
     break;
   } while(1);
   DBUG_PRINT("exit", ("failed, reterr: %u, NdbError %u(%s)", reterr,
@@ -10941,7 +10984,7 @@
 ndberror:
   err= dict->getNdbError();
 ndberror2:
-  ERR_PRINT(err);
+  set_ndb_err(thd, err);
   ndb_to_mysql_error(&err);
   
   my_error(error, MYF(0), errmsg);

--- 1.182/sql/ha_ndbcluster.h	2007-05-14 14:46:20 +02:00
+++ 1.183/sql/ha_ndbcluster.h	2007-06-18 07:37:30 +02:00
@@ -218,6 +218,8 @@
   NdbTransaction *stmt;
   bool m_error;
   bool m_slow_path;
+  int m_error_code;
+  uint32 m_query_id; /* query id whn m_error_code was set */
   uint32 options;
   uint32 trans_options;
   List<NDB_SHARE> changed_tables;

--- 1.120/sql/ha_ndbcluster_binlog.cc	2007-05-23 08:06:22 +02:00
+++ 1.121/sql/ha_ndbcluster_binlog.cc	2007-06-18 07:37:30 +02:00
@@ -81,6 +81,20 @@
 static Ndb *schema_ndb= 0;
 
 static int ndbcluster_binlog_inited= 0;
+/*
+  Flag "ndbcluster_binlog_terminating" set when shutting down mysqld.
+  Server main loop should call handlerton function:
+
+  ndbcluster_hton->binlog_func ==
+  ndbcluster_binlog_func(...,BFN_BINLOG_END,...) ==
+  ndbcluster_binlog_end
+
+  at shutdown, which sets the flag. And then server needs to wait for it
+  to complete.  Otherwise binlog will not be complete.
+
+  ndbcluster_hton->panic == ndbcluster_end() will not return until
+  ndb binlog is completed
+*/
 static int ndbcluster_binlog_terminating= 0;
 
 /*
@@ -242,7 +256,7 @@
   - creating the ndb_apply_status table
 */
 static void run_query(THD *thd, char *buf, char *end,
-                      my_bool print_error, my_bool disable_binlog)
+                      const int *no_print_error, my_bool disable_binlog)
 {
   ulong save_query_length= thd->query_length;
   char *save_query= thd->query;
@@ -262,11 +276,18 @@
   DBUG_PRINT("query", ("%s", thd->query));
   mysql_parse(thd, thd->query, thd->query_length, &found_semicolon);
 
-  if (print_error && thd->query_error)
+  if (no_print_error && thd->query_error)
   {
-    sql_print_error("NDB: %s: error %s %d %d %d",
-                    buf, thd->net.last_error, thd->net.last_errno,
-                    thd->net.report_error, thd->query_error);
+    int i;
+    Thd_ndb *thd_ndb= get_thd_ndb(thd);
+    for (i= 0; no_print_error[i]; i++)
+      if (thd_ndb->m_error == no_print_error[i])
+        break;
+    if (!no_print_error[i])
+      sql_print_error("NDB: %s: error %s %d(ndb: %d) %d %d",
+                      buf, thd->net.last_error, thd->net.last_errno,
+                      thd_ndb->m_error,
+                      thd->net.report_error, thd->query_error);
   }
 
   thd->options= save_thd_options;
@@ -508,7 +529,7 @@
   char buf[1024];
   char *end= strmov(buf, "DELETE FROM " NDB_REP_DB "." NDB_REP_TABLE);
 
-  run_query(thd, buf, end, FALSE, TRUE);
+  run_query(thd, buf, end, NULL, TRUE);
 
   DBUG_RETURN(0);
 }
@@ -533,7 +554,7 @@
                                   NDB_REP_DB "." NDB_REP_TABLE
                                   " WHERE File='"), file), "'");
 
-  run_query(thd, buf, end, FALSE, TRUE);
+  run_query(thd, buf, end, NULL, TRUE);
 
   DBUG_RETURN(0);
 }
@@ -650,7 +671,7 @@
   DBUG_ENTER("ndbcluster_reset_slave");
   char buf[1024];
   char *end= strmov(buf, "DELETE FROM " NDB_REP_DB "." NDB_APPLY_TABLE);
-  run_query(thd, buf, end, FALSE, TRUE);
+  run_query(thd, buf, end, NULL, TRUE);
   DBUG_VOID_RETURN;
 }
 
@@ -775,7 +796,8 @@
                    " end_pos BIGINT UNSIGNED NOT NULL, "
                    " PRIMARY KEY USING HASH (server_id) ) ENGINE=NDB");
 
-  run_query(thd, buf, end, TRUE, TRUE);
+  const int no_print_error[2]= {701, 0}; // do not print error 701
+  run_query(thd, buf, end, no_print_error, TRUE);
 
   DBUG_RETURN(0);
 }
@@ -831,7 +853,8 @@
                    " type INT UNSIGNED NOT NULL,"
                    " PRIMARY KEY USING HASH (db,name) ) ENGINE=NDB");
 
-  run_query(thd, buf, end, TRUE, TRUE);
+  const int no_print_error[2]= {701, 0}; // do not print error 701
+  run_query(thd, buf, end, no_print_error, TRUE);
 
   DBUG_RETURN(0);
 }
@@ -1940,9 +1963,10 @@
           /* Drop the database locally if it only contains ndb tables */
           if (! ndbcluster_check_if_local_tables_in_db(thd, schema->db))
           {
+            const int no_print_error[1]= {0};
             run_query(thd, schema->query,
                       schema->query + schema->query_length,
-                      TRUE,    /* print error */
+                      no_print_error,    /* print error */
                       TRUE);   /* don't binlog the query */
             /* binlog dropping database after any table operations */
             post_epoch_log_list->push_back(schema, mem_root);
@@ -1962,12 +1986,15 @@
         case SOT_CREATE_DB:
           /* fall through */
         case SOT_ALTER_DB:
+        {
+          const int no_print_error[1]= {0};
           run_query(thd, schema->query,
                     schema->query + schema->query_length,
-                    TRUE,    /* print error */
+                    no_print_error,    /* print error */
                     TRUE);   /* don't binlog the query */
           log_query= 1;
           break;
+        }
         case SOT_TABLESPACE:
         case SOT_LOGFILE_GROUP:
           log_query= 1;
Thread
bk commit into 5.1 tree (tomas:1.2547)tomas18 Jun