List:Commits« Previous MessageNext Message »
From:Tomas Ulin Date:December 11 2008 10:21am
Subject:bzr push into mysql-5.1 branch (tomas.ulin:2756 to 2769) Bug#41338
View as plain text  
 2769 Tomas Ulin	2008-12-11
      Bug #41338  Cluster makes substitution of "poll()" by "select()" visible
modified:
  mysql-test/suite/ndb/r/ndb_alter_table_online.result
  mysql-test/suite/ndb/t/ndb_alter_table_online.test

 2768 Tomas Ulin	2008-12-10
      correct so that errors get to log in run_query, and move reset main_da into run_query
modified:
  sql/ha_ndbcluster_binlog.cc

 2767 Tomas Ulin	2008-12-10 [merge]
      merge
modified:
  sql/sql_yacc.yy

 2766 Tomas Ulin	2008-12-10
      show tables should under no circumstances delete any ndb tables
modified:
  sql/ha_ndbcluster.cc
  sql/ha_ndbcluster.h

 2765 Tomas Ulin	2008-12-10
      remove disable of non-existant test
modified:
  mysql-test/suite/ndb/t/disabled.def

 2764 Jonas Oreland	2008-12-08
      ndb - bug#41295 bug#41296 bug#41297
modified:
  storage/ndb/src/kernel/blocks/ERROR_codes.txt
  storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp
  storage/ndb/src/kernel/blocks/dblqh/Dblqh.hpp
  storage/ndb/src/kernel/blocks/dblqh/DblqhInit.cpp
  storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp
  storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp
  storage/ndb/test/include/NdbRestarter.hpp
  storage/ndb/test/ndbapi/testNodeRestart.cpp
  storage/ndb/test/run-test/daily-basic-tests.txt
  storage/ndb/test/src/NdbRestarter.cpp

 2763 Jonas Oreland	2008-12-03
      ndb autotest - remove extra empty lines
modified:
  storage/ndb/test/run-test/daily-basic-tests.txt

 2762 Jonas Oreland	2008-12-03 [merge]
      merge with 5.1-telco-6.2-merge
modified:
  mysql-test/suite/ndb/t/ndb_dd_dump.test

 2761 Jonas Oreland	2008-12-03
      ndb - bug#41214 - incorrectly handled commit ack marker
        during TC-take-over could lead to subsequent api-failure-handling
        not completing
modified:
  storage/ndb/src/kernel/blocks/dbtc/Dbtc.hpp
  storage/ndb/src/kernel/blocks/dbtc/DbtcInit.cpp
  storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp
  storage/ndb/test/ndbapi/testNodeRestart.cpp
  storage/ndb/test/run-test/daily-devel-tests.txt

 2760 Guangbao Ni	2008-12-03
      BUG#39667 Starting phase is reported differently in cluster.log and ndb_mgm
modified:
  storage/ndb/src/mgmclient/CommandInterpreter.cpp

 2759 Jonas Oreland	2008-11-27
      ndb - fix operator precedence for batch size estimation of deletes
modified:
  sql/ha_ndbcluster.cc

 2758 Jonas Oreland	2008-11-27
      ndb - atrt - revert to starting nodes initial (to handle the trd setup)
modified:
  storage/ndb/test/run-test/command.cpp
  storage/ndb/test/run-test/setup.cpp

 2757 Tomas Ulin	2008-11-26 [merge]
      merge
modified:
  Makefile.am
  client/mysqlslap.c
  mysql-test/r/partition.result
  mysql-test/t/partition.test
  sql/ha_partition.cc
  storage/archive/archive_reader.c
  storage/ndb/test/tools/connect.cpp
  support-files/mysql.spec.sh

 2756 Tomas Ulin	2008-11-24
      post merge fixes: split test and do not run all in ndb
added:
  mysql-test/extra/rpl_tests/rpl_row_basic_no_pk.test
modified:
  mysql-test/extra/rpl_tests/rpl_row_basic.test
  mysql-test/suite/rpl/t/rpl_row_basic_2myisam.test
  mysql-test/suite/rpl/t/rpl_row_basic_3innodb.test
  mysql-test/suite/rpl_ndb/r/rpl_row_basic_7ndb.result
  mysql-test/suite/rpl_ndb/t/rpl_row_basic_7ndb.test

=== modified file 'Makefile.am'
--- a/Makefile.am	2008-11-21 16:13:14 +0000
+++ b/Makefile.am	2008-11-26 12:26:00 +0000
@@ -180,7 +180,7 @@ test-bt:
 test-bt-fast:
 	-cd mysql-test ; MTR_BUILD_THREAD=auto \
 	    @PERL@ ./mysql-test-run.pl  --comment=ps    --force --timer \
-	        --skip-ndbcluster --ps-protocol
+	        --skip-ndbcluster --ps-protocol --report-features
 	-if [ -e bin/ndbd -o -e storage/ndb/src/kernel/ndbd ] ; then \
 	  cd mysql-test ; \
 	    MTR_BUILD_THREAD=auto \

=== modified file 'client/mysqlslap.c'
--- a/client/mysqlslap.c	2008-02-08 11:13:33 +0000
+++ b/client/mysqlslap.c	2008-11-25 02:04:58 +0000
@@ -688,9 +688,7 @@ static void usage(void)
 {
   print_version();
   puts("Copyright (C) 2005 MySQL AB");
-  puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,\
-       \nand you are welcome to modify and redistribute it under the GPL \
-       license\n");
+  puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,\nand you are welcome to modify and redistribute it under the GPL license\n");
   puts("Run a query multiple times against the server\n");
   printf("Usage: %s [OPTIONS]\n",my_progname);
   print_defaults("my",load_default_groups);

=== modified file 'mysql-test/r/partition.result'
--- a/mysql-test/r/partition.result	2008-11-05 14:53:28 +0000
+++ b/mysql-test/r/partition.result	2008-11-25 02:04:58 +0000
@@ -1,4 +1,16 @@
 drop table if exists t1, t2;
+CREATE TABLE t1 (
+pk INT NOT NULL AUTO_INCREMENT,
+PRIMARY KEY (pk)
+)
+/*!50100 PARTITION BY HASH (pk)
+PARTITIONS 2 */;
+INSERT INTO t1 VALUES (NULL);
+INSERT INTO t1 VALUES (NULL);
+INSERT INTO t1 VALUES (NULL);
+SELECT * FROM t1 WHERE pk < 0 ORDER BY pk;
+pk
+DROP TABLE t1;
 CREATE TABLE t1 (a INT NOT NULL, KEY(a))
 PARTITION BY RANGE(a)
 (PARTITION p1 VALUES LESS THAN (200), PARTITION pmax VALUES LESS THAN MAXVALUE);

=== modified file 'mysql-test/suite/ndb/r/ndb_alter_table_online.result'
--- a/mysql-test/suite/ndb/r/ndb_alter_table_online.result	2008-08-08 08:41:32 +0000
+++ b/mysql-test/suite/ndb/r/ndb_alter_table_online.result	2008-12-11 10:20:34 +0000
@@ -672,62 +672,14 @@ CREATE TABLE t1
 ENGINE=NDB;
 Warnings:
 Warning	1478	Row format FIXED incompatible with dynamic attribute b
--- t1 --
-Version: #
-Fragment type: 5
-K Value: 6
-Min load factor: 78
-Max load factor: 80
-Temporary table: no
-Number of attributes: 2
-Number of primary keys: 1
-Length of frm data: 257
-Row Checksum: 1
-Row GCI: 1
-SingleUserMode: 0
-ForceVarPart: 0
-TableStatus: Retrieved
--- Attributes -- 
 pk1 Int PRIMARY KEY DISTRIBUTION KEY AT=FIXED ST=MEMORY
 b Int NULL AT=FIXED ST=MEMORY DYNAMIC
-
--- Indexes -- 
-PRIMARY KEY(pk1) - UniqueHashIndex
-PRIMARY(pk1) - OrderedIndex
-
-
-NDBT_ProgramExit: 0 - OK
-
 DROP TABLE t1;
 CREATE TABLE t1
 (pk1 INT NOT NULL COLUMN_FORMAT FIXED PRIMARY KEY, 
 b INT COLUMN_FORMAT FIXED)ROW_FORMAT=DYNAMIC ENGINE=NDB;
--- t1 --
-Version: #
-Fragment type: 5
-K Value: 6
-Min load factor: 78
-Max load factor: 80
-Temporary table: no
-Number of attributes: 2
-Number of primary keys: 1
-Length of frm data: 257
-Row Checksum: 1
-Row GCI: 1
-SingleUserMode: 0
-ForceVarPart: 1
-TableStatus: Retrieved
--- Attributes -- 
 pk1 Int PRIMARY KEY DISTRIBUTION KEY AT=FIXED ST=MEMORY
 b Int NULL AT=FIXED ST=MEMORY
-
--- Indexes -- 
-PRIMARY KEY(pk1) - UniqueHashIndex
-PRIMARY(pk1) - OrderedIndex
-
-
-NDBT_ProgramExit: 0 - OK
-
 ********************
 * Cleanup Section
 ********************

=== modified file 'mysql-test/suite/ndb/t/disabled.def'
--- a/mysql-test/suite/ndb/t/disabled.def	2008-10-28 14:02:09 +0000
+++ b/mysql-test/suite/ndb/t/disabled.def	2008-12-10 10:05:54 +0000
@@ -9,7 +9,6 @@
 #  Do not use any TAB characters for whitespace.
 #
 ##############################################################################
-partition_03ndb          : BUG#16385 2006-03-24 mikael Partitions: crash when updating a range partitioned NDB table
 
 ndb_partition_error2	 : HF is not sure if the test can work as internded on all the platforms
 

=== modified file 'mysql-test/suite/ndb/t/ndb_alter_table_online.test'
--- a/mysql-test/suite/ndb/t/ndb_alter_table_online.test	2008-03-12 19:00:49 +0000
+++ b/mysql-test/suite/ndb/t/ndb_alter_table_online.test	2008-12-11 10:20:34 +0000
@@ -708,8 +708,7 @@ CREATE TABLE t1
 (pk1 INT NOT NULL PRIMARY KEY, b INT COLUMN_FORMAT DYNAMIC)ROW_FORMAT=FIXED
 ENGINE=NDB;
 
---replace_regex /Version: [0-9]+/Version: #/
---exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d test t1
+--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d test t1 | grep 'AT='
 
 DROP TABLE t1;
 
@@ -717,8 +716,7 @@ CREATE TABLE t1
 (pk1 INT NOT NULL COLUMN_FORMAT FIXED PRIMARY KEY, 
 b INT COLUMN_FORMAT FIXED)ROW_FORMAT=DYNAMIC ENGINE=NDB;
 
---replace_regex /Version: [0-9]+/Version: #/
---exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d test t1
+--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d test t1 | grep 'AT='
 
 --echo ********************
 --echo * Cleanup Section

=== modified file 'mysql-test/suite/ndb/t/ndb_dd_dump.test'
--- a/mysql-test/suite/ndb/t/ndb_dd_dump.test	2007-08-21 19:22:35 +0000
+++ b/mysql-test/suite/ndb/t/ndb_dd_dump.test	2008-12-03 14:59:44 +0000
@@ -258,6 +258,7 @@ CREATE TABLE test.t (
 
  SELECT count(*) FROM test.t;
  LOAD DATA INFILE 't_backup' INTO TABLE test.t;
+ --remove_file $MYSQLTEST_VARDIR/master-data/test/t_backup
 
  SELECT * FROM test.t order by a;
 

=== modified file 'mysql-test/t/partition.test'
--- a/mysql-test/t/partition.test	2008-11-05 14:53:28 +0000
+++ b/mysql-test/t/partition.test	2008-11-25 02:04:58 +0000
@@ -15,6 +15,21 @@ drop table if exists t1, t2;
 --enable_warnings
 
 #
+# Bug#40954: Crash if range search and order by.
+#
+CREATE TABLE t1 (
+  pk INT NOT NULL AUTO_INCREMENT,
+  PRIMARY KEY (pk)
+)
+/*!50100 PARTITION BY HASH (pk)
+PARTITIONS 2 */;
+INSERT INTO t1 VALUES (NULL);
+INSERT INTO t1 VALUES (NULL);
+INSERT INTO t1 VALUES (NULL);
+SELECT * FROM t1 WHERE pk < 0 ORDER BY pk;
+DROP TABLE t1;
+
+#
 # Bug#40494: Crash MYSQL server crashes on range access with partitioning
 #            and order by
 #

=== modified file 'sql/ha_ndbcluster.cc'
--- a/sql/ha_ndbcluster.cc	2008-11-24 17:57:50 +0000
+++ b/sql/ha_ndbcluster.cc	2008-12-10 10:08:04 +0000
@@ -3456,7 +3456,7 @@ int ha_ndbcluster::ndb_delete_row(const 
     /*
       Poor approx. let delete ~ tabsize / 4
     */
-    uint delete_size= 12 + m_bytes_per_write >> 2;
+    uint delete_size= 12 + (m_bytes_per_write >> 2);
     bool need_flush= add_row_check_if_batch_full_size(thd_ndb, delete_size);
     if ( (thd->options & OPTION_ALLOW_BATCH) &&
          table_share->primary_key != MAX_KEY &&
@@ -6445,18 +6445,20 @@ retry_temporary_error1:
 int ha_ndbcluster::delete_table(const char *name)
 {
   THD *thd= current_thd;
+  Thd_ndb *thd_ndb= get_thd_ndb(thd);
   Ndb *ndb;
   int error= 0;
   DBUG_ENTER("ha_ndbcluster::delete_table");
   DBUG_PRINT("enter", ("name: %s", name));
 
-  if (thd == injector_thd)
+  if ((thd == injector_thd) ||
+      (thd_ndb->options & TNO_NO_NDB_DROP_TABLE))
   {
     /*
       Table was dropped remotely is already
       dropped inside ndb.
       Just drop local files.
-     */
+    */
     DBUG_RETURN(handler::delete_table(name));
   }
 
@@ -6482,10 +6484,10 @@ int ha_ndbcluster::delete_table(const ch
     goto err;
   }
 
-  ndb= get_ndb(thd);
+  ndb= thd_ndb->ndb;
 
 #ifdef HAVE_NDB_BINLOG
-  if (!ndbcluster_has_global_schema_lock(get_thd_ndb(thd)))
+  if (!ndbcluster_has_global_schema_lock(thd_ndb))
     DBUG_RETURN(ndbcluster_no_global_schema_lock_abort
                 (thd, "ha_ndbcluster::delete_table"));
 #endif
@@ -7370,6 +7372,7 @@ int ndbcluster_find_files(handlerton *ht
   DBUG_PRINT("enter", ("db: %s", db));
   { // extra bracket to avoid gcc 2.95.3 warning
   uint i;
+  Thd_ndb *thd_ndb;
   Ndb* ndb;
   char name[FN_REFLEN];
   HASH ndb_tables, ok_tables;
@@ -7377,6 +7380,7 @@ int ndbcluster_find_files(handlerton *ht
 
   if (!(ndb= check_ndb_in_thd(thd)))
     DBUG_RETURN(HA_ERR_NO_CONNECTION);
+  thd_ndb= get_thd_ndb(thd);
 
   if (dir)
     DBUG_RETURN(0); // Discover of databases not yet supported
@@ -7557,12 +7561,17 @@ int ndbcluster_find_files(handlerton *ht
       bzero((char*) &table_list,sizeof(table_list));
       table_list.db= (char*) db;
       table_list.alias= table_list.table_name= (char*)file_name_str;
+      /*
+        set TNO_NO_NDB_DROP_TABLE flag to not drop ndb table.
+        it should not exist anyways
+      */
+      thd_ndb->options|= TNO_NO_NDB_DROP_TABLE;
       (void)mysql_rm_table_part2(thd, &table_list,
                                  FALSE,   /* if_exists */
                                  FALSE,   /* drop_temporary */ 
                                  FALSE,   /* drop_view */
                                  TRUE     /* dont_log_query*/);
-
+      thd_ndb->options&= ~TNO_NO_NDB_DROP_TABLE;
       /* Clear error message that is returned when table is deleted */
       thd->clear_error();
     }

=== modified file 'sql/ha_ndbcluster.h'
--- a/sql/ha_ndbcluster.h	2008-11-24 17:57:50 +0000
+++ b/sql/ha_ndbcluster.h	2008-12-10 10:08:04 +0000
@@ -242,6 +242,13 @@ enum THD_NDB_OPTIONS
     lock, as one other mysqld already has the lock.
   */
   TNO_NO_LOCK_SCHEMA_OP= 1 << 1
+  /*
+    Skip drop of ndb table in delete_table.  Used when calling
+    mysql_rm_table_part2 in "show tables", as we do not want to
+    remove ndb tables "by mistake".  The table should not exist
+    in ndb in the first place.
+  */
+  ,TNO_NO_NDB_DROP_TABLE=    1 << 2
 };
 
 enum THD_NDB_TRANS_OPTIONS

=== modified file 'sql/ha_ndbcluster_binlog.cc'
--- a/sql/ha_ndbcluster_binlog.cc	2008-11-21 14:32:18 +0000
+++ b/sql/ha_ndbcluster_binlog.cc	2008-12-10 12:17:23 +0000
@@ -245,7 +245,8 @@ static void dbug_print_table(const char 
   - creating the ndb_apply_status table
 */
 static void run_query(THD *thd, char *buf, char *end,
-                      const int *no_print_error, my_bool disable_binlog)
+                      const int *no_print_error, my_bool disable_binlog,
+                      my_bool reset_error)
 {
   ulong save_thd_query_length= thd->query_length;
   char *save_thd_query= thd->query;
@@ -273,7 +274,7 @@ static void run_query(THD *thd, char *bu
 
   mysql_parse(thd, thd->query, thd->query_length, &found_semicolon);
 
-  if (no_print_error && thd->is_slave_error)
+  if (no_print_error && thd->main_da.is_error())
   {
     int i;
     Thd_ndb *thd_ndb= get_thd_ndb(thd);
@@ -300,7 +301,7 @@ static void run_query(THD *thd, char *bu
     is called from ndbcluster_reset_logs(), which is called from
     mysql_flush().
   */
-  if (!thd->main_da.is_error())
+  if (!thd->main_da.is_error() || reset_error)
   {
     thd->main_da.reset_diagnostics_area();
   }
@@ -575,7 +576,7 @@ ndbcluster_binlog_index_purge_file(THD *
                                   NDB_REP_DB "." NDB_REP_TABLE
                                   " WHERE File='"), file), "'");
 
-  run_query(thd, buf, end, NULL, TRUE);
+  run_query(thd, buf, end, NULL, TRUE, FALSE);
   if (thd->main_da.is_error() &&
       thd->main_da.sql_errno() == ER_NO_SUCH_TABLE)
   {
@@ -701,7 +702,7 @@ static void ndbcluster_reset_slave(THD *
   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, NULL, TRUE);
+  run_query(thd, buf, end, NULL, TRUE, FALSE);
   if (thd->main_da.is_error() &&
       ((thd->main_da.sql_errno() == ER_NO_SUCH_TABLE) ||
        (thd->main_da.sql_errno() == ER_OPEN_AS_READONLY && ndbcluster_silent)))
@@ -1080,9 +1081,7 @@ static int ndbcluster_create_ndb_apply_s
 
       end= strmov(buf, "FLUSH TABLE " NDB_REP_DB "." NDB_APPLY_TABLE);
       const int no_print_error[1]= {0};
-      run_query(thd, buf, end, no_print_error, TRUE);
-      /* always reset here */
-      thd->main_da.reset_diagnostics_area();
+      run_query(thd, buf, end, no_print_error, TRUE, TRUE);
     }
   }
 
@@ -1104,9 +1103,7 @@ static int ndbcluster_create_ndb_apply_s
                                 721, // Table already exist
                                 4009,
                                 0}; // do not print error 701 etc
-  run_query(thd, buf, end, no_print_error, TRUE);
-  /* always reset here */
-  thd->main_da.reset_diagnostics_area();
+  run_query(thd, buf, end, no_print_error, TRUE, TRUE);
 
   DBUG_RETURN(0);
 }
@@ -1157,9 +1154,7 @@ static int ndbcluster_create_schema_tabl
 
       end= strmov(buf, "FLUSH TABLE " NDB_REP_DB "." NDB_SCHEMA_TABLE);
       const int no_print_error[1]= {0};
-      run_query(thd, buf, end, no_print_error, TRUE);
-      /* always reset here */
-      thd->main_da.reset_diagnostics_area();
+      run_query(thd, buf, end, no_print_error, TRUE, TRUE);
     }
   }
 
@@ -1185,9 +1180,7 @@ static int ndbcluster_create_schema_tabl
                                 721, // Table already exist
                                 4009,
                                 0}; // do not print error 701 etc
-  run_query(thd, buf, end, no_print_error, TRUE);
-  /* always reset here */
-  thd->main_da.reset_diagnostics_area();
+  run_query(thd, buf, end, no_print_error, TRUE, TRUE);
 
   DBUG_RETURN(0);
 }
@@ -1304,9 +1297,8 @@ static int ndbcluster_find_all_databases
             const int no_print_error[1]= {0};
             run_query(thd, query, query + query_length,
                       no_print_error,    /* print error */
-                      TRUE);   /* don't binlog the query */
-            /* always reset here */
-            thd->main_da.reset_diagnostics_area();
+                      TRUE,   /* don't binlog the query */
+                      TRUE);  /* reset error */
           }
         }
         else if (strncasecmp("ALTER", query, 5) == 0)
@@ -1320,13 +1312,12 @@ static int ndbcluster_find_all_databases
             name_len= my_snprintf(name, sizeof(name), "CREATE DATABASE %s", db);
             run_query(thd, name, name + name_len,
                       no_print_error,    /* print error */
-                      TRUE);   /* don't binlog the query */
-            thd->main_da.reset_diagnostics_area();
+                      TRUE,   /* don't binlog the query */
+                      TRUE);  /* reset error */
             run_query(thd, query, query + query_length,
                       no_print_error,    /* print error */
-                      TRUE);   /* don't binlog the query */
-            /* always reset here */
-            thd->main_da.reset_diagnostics_area();
+                      TRUE,   /* don't binlog the query */
+                      TRUE);  /* reset error */
           }
         }
         else if (strncasecmp("DROP", query, 4) == 0)
@@ -2366,15 +2357,13 @@ ndb_binlog_thread_handle_schema_event(TH
           if (! ndbcluster_check_if_local_table(schema->db, schema->name))
           {
             thd_ndb_options.set(TNO_NO_LOCK_SCHEMA_OP);
-            const int no_print_error[1]=
-              {ER_BAD_TABLE_ERROR}; /* ignore missing table */
+            const int no_print_error[2]=
+              {ER_BAD_TABLE_ERROR, 0}; /* ignore missing table */
             run_query(thd, schema->query,
                       schema->query + schema->query_length,
                       no_print_error, //   /* don't print error */
-                      TRUE); //  /* don't binlog the query */
-            /* always reset here */
-            thd->main_da.reset_diagnostics_area();
-
+                      TRUE,   /* don't binlog the query */
+                      TRUE);  /* reset error */
             /* binlog dropping table after any table operations */
             post_epoch_log_list->push_back(schema, mem_root);
             /* acknowledge this query _after_ epoch completion */
@@ -2462,9 +2451,8 @@ ndb_binlog_thread_handle_schema_event(TH
             run_query(thd, schema->query,
                       schema->query + schema->query_length,
                       no_print_error,    /* print error */
-                      TRUE);   /* don't binlog the query */
-            /* always reset here */
-            thd->main_da.reset_diagnostics_area();
+                      TRUE,   /* don't binlog the query */
+                      TRUE);  /* reset error */
             /* binlog dropping database after any table operations */
             post_epoch_log_list->push_back(schema, mem_root);
             /* acknowledge this query _after_ epoch completion */
@@ -2492,9 +2480,8 @@ ndb_binlog_thread_handle_schema_event(TH
           run_query(thd, schema->query,
                     schema->query + schema->query_length,
                     no_print_error,    /* print error */
-                    TRUE);   /* don't binlog the query */
-          /* always reset here */
-          thd->main_da.reset_diagnostics_area();
+                    TRUE,   /* don't binlog the query */
+                    TRUE);  /* reset error */
           log_query= 1;
           break;
         }

=== modified file 'sql/ha_partition.cc'
--- a/sql/ha_partition.cc	2008-11-21 16:13:14 +0000
+++ b/sql/ha_partition.cc	2008-11-26 12:26:00 +0000
@@ -4429,7 +4429,8 @@ int ha_partition::handle_ordered_index_s
         This can only read record to table->record[0], as it was set when
         the table was being opened. We have to memcpy data ourselves.
       */
-      error= file->read_range_first(&m_start_key, end_range, eq_range, TRUE);
+      error= file->read_range_first(m_start_key.key? &m_start_key: NULL,
+                                    end_range, eq_range, TRUE);
       memcpy(rec_buf_ptr, table->record[0], m_rec_length);
       reverse_order= FALSE;
       break;

=== modified file 'sql/sql_yacc.yy'
--- a/sql/sql_yacc.yy	2008-11-21 16:13:14 +0000
+++ b/sql/sql_yacc.yy	2008-12-10 07:02:14 +0000
@@ -3617,7 +3617,7 @@ ts_wait:
         ;
 
 size_number:
-          real_ulong_num { $$= $1;}
+          real_ulonglong_num { $$= $1;}
         | IDENT
           {
             ulonglong number;

=== modified file 'storage/archive/archive_reader.c'
--- a/storage/archive/archive_reader.c	2008-11-14 16:29:38 +0000
+++ b/storage/archive/archive_reader.c	2008-11-25 02:04:58 +0000
@@ -375,9 +375,7 @@ static void usage(void)
 {
   print_version();
   puts("Copyright 2007-2008 MySQL AB, 2008 Sun Microsystems, Inc.");
-  puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,\
-       \nand you are welcome to modify and redistribute it under the GPL \
-       license\n");
+  puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,\nand you are welcome to modify and redistribute it under the GPL license\n");
   puts("Read and modify Archive files directly\n");
   printf("Usage: %s [OPTIONS] file_to_be_looked_at [file_for_backup]\n", my_progname);
   print_defaults("my", load_default_groups);

=== modified file 'storage/ndb/src/kernel/blocks/ERROR_codes.txt'
--- a/storage/ndb/src/kernel/blocks/ERROR_codes.txt	2008-08-11 10:41:11 +0000
+++ b/storage/ndb/src/kernel/blocks/ERROR_codes.txt	2008-12-08 12:35:55 +0000
@@ -6,7 +6,7 @@ Next DBTUP 4029
 Next DBLQH 5051
 Next DBDICT 6008
 Next DBDIH 7215
-Next DBTC 8064
+Next DBTC 8074
 Next CMVMI 9000
 Next BACKUP 10041
 Next DBUTIL 11002

=== modified file 'storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp'
--- a/storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp	2008-08-11 10:41:11 +0000
+++ b/storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp	2008-12-08 12:35:55 +0000
@@ -5188,16 +5188,32 @@ void Dbdih::checkGcpOutstanding(Signal* 
                GCPPrepareConf::SignalLength, JBB);
   }//if
 
-  if (c_GCP_COMMIT_Counter.isWaitingFor(failedNodeId)) {
+  if (c_GCP_COMMIT_Counter.isWaitingFor(failedNodeId)) 
+  {
     jam();
-    GCPNodeFinished* conf = (GCPNodeFinished*)signal->getDataPtrSend();
-    conf->nodeId = failedNodeId;
-    conf->gci_hi = Uint32(m_micro_gcp.m_old_gci >> 32);
-    conf->gci_lo = Uint32(m_micro_gcp.m_old_gci);
-    conf->failno = cfailurenr;
-    sendSignal(reference(), GSN_GCP_NODEFINISH, signal, 
-               GCPNodeFinished::SignalLength, JBB);
-  }//if
+    
+    /**
+     * Waiting for GSN_GCP_NODEFINISH
+     *   TC-take-over can generate new transactions
+     *   that will be in this epoch
+     *   re-run GCP_NOMORETRANS to master-TC (self) that will run
+     *   take-over
+     */
+    c_GCP_COMMIT_Counter.clearWaitingFor(failedNodeId);
+    if (!c_GCP_COMMIT_Counter.isWaitingFor(getOwnNodeId()))
+    {
+      jam();
+      c_GCP_COMMIT_Counter.setWaitingFor(getOwnNodeId());
+      m_micro_gcp.m_state = MicroGcp::M_GCP_COMMIT;
+    }
+     
+    GCPNoMoreTrans* req = (GCPNoMoreTrans*)signal->getDataPtrSend();
+    req->senderData = m_micro_gcp.m_master_ref;
+    req->gci_hi = m_micro_gcp.m_old_gci >> 32;
+    req->gci_lo = m_micro_gcp.m_old_gci & 0xFFFFFFFF;
+    sendSignal(clocaltcblockref, GSN_GCP_NOMORETRANS, signal,
+               GCPNoMoreTrans::SignalLength, JBB);
+  }
 
   if (c_GCP_SAVEREQ_Counter.isWaitingFor(failedNodeId)) {
     jam();
@@ -15589,7 +15605,6 @@ Dbdih::execDUMP_STATE_ORD(Signal* signal
     SET_ERROR_INSERT_VALUE2(7214, signal->theData[1]);
     return;
   }
-
 }//Dbdih::execDUMP_STATE_ORD()
 
 void

=== modified file 'storage/ndb/src/kernel/blocks/dblqh/Dblqh.hpp'
--- a/storage/ndb/src/kernel/blocks/dblqh/Dblqh.hpp	2008-11-14 11:17:53 +0000
+++ b/storage/ndb/src/kernel/blocks/dblqh/Dblqh.hpp	2008-12-08 12:35:55 +0000
@@ -944,7 +944,9 @@ public:
   typedef Ptr<GcpRecord> GcpRecordPtr;
 
   struct HostRecord {
-    bool inPackedList;
+    Uint8 inPackedList;
+    Uint8 nodestatus;
+    Uint8 _unused[2];
     UintR noOfPackedWordsLqh;
     UintR packedWordsLqh[30];
     UintR noOfPackedWordsTc;

=== modified file 'storage/ndb/src/kernel/blocks/dblqh/DblqhInit.cpp'
--- a/storage/ndb/src/kernel/blocks/dblqh/DblqhInit.cpp	2007-11-19 10:04:24 +0000
+++ b/storage/ndb/src/kernel/blocks/dblqh/DblqhInit.cpp	2008-12-08 12:35:55 +0000
@@ -63,6 +63,10 @@ void Dblqh::initData() 
   m_backup_ptr = RNIL;
   clogFileSize = 16;
   cmaxLogFilesInPageZero = 40;
+
+  for (Uint32 i = 0; i < 1024; i++) {
+    ctransidHash[i] = RNIL;
+  }//for
 }//Dblqh::initData()
 
 void Dblqh::initRecords() 

=== modified file 'storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp'
--- a/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp	2008-11-14 11:17:53 +0000
+++ b/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp	2008-12-08 12:35:55 +0000
@@ -496,6 +496,14 @@ void Dblqh::execINCL_NODEREQ(Signal* sig
       cnodeStatus[i] = ZNODE_UP;
     }//if
   }//for
+
+  {
+    HostRecordPtr Thostptr;
+    Thostptr.i = nodeId;
+    ptrCheckGuard(Thostptr, chostFileSize, hostRecord);
+    Thostptr.p->nodestatus = ZNODE_UP;
+  }
+
   signal->theData[0] = nodeId;
   signal->theData[1] = cownref; 
   sendSignal(retRef, GSN_INCL_NODECONF, signal, 2, JBB);
@@ -712,6 +720,7 @@ void Dblqh::startphase1Lab(Signal* signa
     ThostPtr.p->inPackedList = false;
     ThostPtr.p->noOfPackedWordsLqh = 0;
     ThostPtr.p->noOfPackedWordsTc  = 0;
+    ThostPtr.p->nodestatus = ZNODE_DOWN;
   }//for
   cpackedListIndex = 0;
   sendNdbSttorryLab(signal);
@@ -898,6 +907,14 @@ void Dblqh::execREAD_NODESCONF(Signal* s
       jam();
       cnodeData[ind]    = i;
       cnodeStatus[ind]  = NdbNodeBitmask::get(readNodes->inactiveNodes, i);
+
+      {
+        HostRecordPtr Thostptr;
+        Thostptr.i = i;
+        ptrCheckGuard(Thostptr, chostFileSize, hostRecord);
+        Thostptr.p->nodestatus = cnodeStatus[ind];
+      }
+
       //readNodes->getVersionId(i, readNodes->theVersionIds) not used
       if (!NodeBitmask::get(readNodes->inactiveNodes, i))
       {
@@ -2280,7 +2297,9 @@ void Dblqh::noFreeRecordLab(Signal* sign
   const Uint32 reqInfo   = lqhKeyReq->requestInfo;
   
   if(errCode == ZNO_FREE_MARKER_RECORDS_ERROR ||
-     errCode == ZNODE_SHUTDOWN_IN_PROGESS){
+     errCode == ZNODE_SHUTDOWN_IN_PROGESS ||
+     errCode == ZNODE_FAILURE_ERROR){
+    jam();
     releaseTcrec(signal, tcConnectptr);
   }
 
@@ -3503,6 +3522,17 @@ void Dblqh::execLQHKEYREQ(Signal* signal
     noFreeRecordLab(signal, lqhKeyReq, ZNODE_SHUTDOWN_IN_PROGESS);
     return;
   }
+
+  {
+    HostRecordPtr Thostptr;
+    Thostptr.i = refToNode(sig5); // TC-ref
+    ptrCheckGuard(Thostptr, chostFileSize, hostRecord);
+    if (unlikely(Thostptr.p->nodestatus != ZNODE_UP))
+    {
+      noFreeRecordLab(signal, lqhKeyReq, ZNODE_FAILURE_ERROR);
+      return;
+    }
+  }
   
   Uint32 senderVersion = getNodeInfo(refToNode(senderRef)).m_version;
 
@@ -7468,6 +7498,22 @@ void Dblqh::continueAbortLab(Signal* sig
 void Dblqh::continueAfterLogAbortWriteLab(Signal* signal) 
 {
   TcConnectionrec * const regTcPtr = tcConnectptr.p;
+
+  const Uint32 commitAckMarker = regTcPtr->commitAckMarker;
+  if(commitAckMarker != RNIL)
+  {
+    jam();
+#ifdef MARKER_TRACE
+    {
+      CommitAckMarkerPtr tmp;
+      m_commitAckMarkerHash.getPtr(tmp, commitAckMarker);
+      ndbout_c("Ab2 marker[%.8x %.8x]", tmp.p->transid1, tmp.p->transid2);
+    }
+#endif
+    m_commitAckMarkerHash.release(commitAckMarker);
+    regTcPtr->commitAckMarker = RNIL;
+  }
+
   if (regTcPtr->operation == ZREAD && regTcPtr->dirtyOp)
   {
     jam();
@@ -7591,6 +7637,14 @@ void Dblqh::execNODE_FAILREP(Signal* sig
   ndbrequire(cnoOfNodes - 1 < MAX_NDB_NODES);
   for (i = 0; i < TnoOfNodes; i++) {
     const Uint32 nodeId = Tdata[i];
+
+    {
+      HostRecordPtr Thostptr;
+      Thostptr.i = nodeId;
+      ptrCheckGuard(Thostptr, chostFileSize, hostRecord);
+      Thostptr.p->nodestatus = ZNODE_DOWN;
+    }
+
     lcpPtr.p->m_EMPTY_LCP_REQ.clear(nodeId);
     
     for (Uint32 j = 0; j < cnoOfNodes; j++) {
@@ -17196,9 +17250,6 @@ void Dblqh::initialiseRecordsLab(Signal*
     m_sr_nodes.clear();
     m_sr_exec_sr_req.clear();
     m_sr_exec_sr_conf.clear();
-    for (i = 0; i < 1024; i++) {
-      ctransidHash[i] = RNIL;
-    }//for
     for (i = 0; i < 4; i++) {
       cactiveCopy[i] = RNIL;
     }//for
@@ -18493,6 +18544,18 @@ void Dblqh::sendLqhTransconf(Signal* sig
   signal->theData[0] = ZLQH_TRANS_NEXT;
   signal->theData[1] = tcNodeFailptr.i;
   sendSignal(cownref, GSN_CONTINUEB, signal, 2, JBB);
+
+  if (0)
+  {
+    ndbout_c("sending LQH_TRANSCONF %u transid: H'%.8x, H'%.8x op: %u state: %u(%u) marker: %u",
+             tcConnectptr.i, 
+             tcConnectptr.p->transid[0],
+             tcConnectptr.p->transid[1],
+             tcConnectptr.p->operation,           
+             tcConnectptr.p->transactionState,
+             stat,
+             tcConnectptr.p->commitAckMarker);
+  }
 }//Dblqh::sendLqhTransconf()
 
 /* --------------------------------------------------------------------------
@@ -18887,7 +18950,10 @@ Dblqh::validate_filter(Signal* signal)
   if (start == end)
   {
     infoEvent("No filter specified, not listing...");
-    return false;
+    if (!ERROR_INSERTED(4002))
+      return false;
+    else
+      return true;
   }
 
   while(start < end)
@@ -19079,7 +19145,7 @@ Dblqh::match_and_print(Signal* signal, P
   char buf[100];
   BaseString::snprintf(buf, sizeof(buf),
 		       "OP[%u]: Tab: %d frag: %d TC: %u API: %d(0x%x)"
-		       "transid: 0x%x 0x%x op: %s state: %s",
+		       "transid: H'%.8x H'%.8x op: %s state: %s",
 		       tcRec.i,
 		       tcRec.p->tableref, 
 		       tcRec.p->fragmentid,
@@ -19090,7 +19156,10 @@ Dblqh::match_and_print(Signal* signal, P
 		       op,
 		       state);
   
-  infoEvent(buf);
+  if (!ERROR_INSERTED(4002))
+    infoEvent(buf);
+  else
+    ndbout_c(buf);
   
   memcpy(signal->theData, temp, 4*len);
   return true;
@@ -19115,7 +19184,7 @@ Dblqh::execDUMP_STATE_ORD(Signal* signal
     CommitAckMarkerIterator iter;
     for(m_commitAckMarkerHash.first(iter); iter.curr.i != RNIL;
 	m_commitAckMarkerHash.next(iter)){
-      infoEvent("CommitAckMarker: i = %d (0x%x, 0x%x)"
+      infoEvent("CommitAckMarker: i = %d (H'%.8x, H'%.8x)"
 		" ApiRef: 0x%x apiOprec: 0x%x TcNodeId: %d",
 		iter.curr.i,
 		iter.curr.p->transid1,
@@ -19636,7 +19705,9 @@ Dblqh::execDUMP_STATE_ORD(Signal* signal
       else
       {
 	jam();
-	infoEvent("End of operation dump");
+        infoEvent("End of operation dump");
+        if (ERROR_INSERTED(4002))
+          ndbrequire(false);
       }
 
       return;
@@ -19677,7 +19748,9 @@ Dblqh::execDUMP_STATE_ORD(Signal* signal
       else
       {
 	jam();
-	infoEvent("End of operation dump");
+        infoEvent("End of operation dump");
+        if (ERROR_INSERTED(4002))
+          ndbrequire(false);
       }
       
       return;
@@ -19742,6 +19815,50 @@ Dblqh::execDUMP_STATE_ORD(Signal* signal
   {
     RSS_AP_SNAPSHOT_CHECK(c_fragment_pool);
     return;
+  }
+
+  if (arg == 4002)
+  {
+    bool ops = false;
+    for (Uint32 i = 0; i<1024; i++)
+    {
+      if (ctransidHash[i] != RNIL)
+      {
+        jam();
+        ops = true;
+        break;
+      }
+    }
+
+    bool markers = m_commitAckMarkerPool.getNoOfFree() != 
+      m_commitAckMarkerPool.getSize();
+    if (unlikely(ops || markers))
+    {
+
+      if (markers)
+      {
+        ndbout_c("LQH: m_commitAckMarkerPool: %d free size: %d",
+                 m_commitAckMarkerPool.getNoOfFree(),
+                 m_commitAckMarkerPool.getSize());
+        
+        CommitAckMarkerIterator iter;
+        for(m_commitAckMarkerHash.first(iter); iter.curr.i != RNIL;
+            m_commitAckMarkerHash.next(iter))
+        {
+          ndbout_c("CommitAckMarker: i = %d (H'%.8x, H'%.8x)"
+                   " ApiRef: 0x%x apiOprec: 0x%x TcNodeId: %d",
+                   iter.curr.i,
+                   iter.curr.p->transid1,
+                   iter.curr.p->transid2,
+                   iter.curr.p->apiRef,
+                   iter.curr.p->apiOprec,
+                   iter.curr.p->tcNodeId);
+        }
+      }
+      SET_ERROR_INSERT_VALUE(4002);
+      signal->theData[0] = 2350;
+      EXECUTE_DIRECT(DBLQH, GSN_DUMP_STATE_ORD, signal, 1);
+    }
   }
 }//Dblqh::execDUMP_STATE_ORD()
 

=== modified file 'storage/ndb/src/kernel/blocks/dbtc/Dbtc.hpp'
--- a/storage/ndb/src/kernel/blocks/dbtc/Dbtc.hpp	2008-09-19 21:49:00 +0000
+++ b/storage/ndb/src/kernel/blocks/dbtc/Dbtc.hpp	2008-12-03 19:44:54 +0000
@@ -1394,7 +1394,7 @@ private:
                      TcConnectRecord * const regTcPtr);
   void sendCompleteLqh(Signal* signal,
                        TcConnectRecord * const regTcPtr);
-  void sendTCKEY_FAILREF(Signal* signal, const ApiConnectRecord *);
+  void sendTCKEY_FAILREF(Signal* signal, ApiConnectRecord *);
   void sendTCKEY_FAILCONF(Signal* signal, ApiConnectRecord *);
   void routeTCKEY_FAILREFCONF(Signal* signal, const ApiConnectRecord *, 
 			      Uint32 gsn, Uint32 len);

=== modified file 'storage/ndb/src/kernel/blocks/dbtc/DbtcInit.cpp'
--- a/storage/ndb/src/kernel/blocks/dbtc/DbtcInit.cpp	2008-08-11 10:41:11 +0000
+++ b/storage/ndb/src/kernel/blocks/dbtc/DbtcInit.cpp	2008-12-03 19:44:54 +0000
@@ -297,14 +297,15 @@ Dbtc::Dbtc(Block_context& ctx):
 #ifdef VM_TRACE
   {
     void* tmp[] = { &apiConnectptr, 
-		    &tcConnectptr,
-		    &cachePtr,
-		    &attrbufptr,
-		    &hostptr,
-		    &timeOutptr,
-		    &scanFragptr,
-		    &databufptr,
-		    &tmpDatabufptr }; 
+                    &tcConnectptr,
+                    &cachePtr,
+                    &attrbufptr,
+                    &hostptr,
+                    &timeOutptr,
+                    &scanFragptr,
+                    &databufptr,
+                    &tmpDatabufptr, 
+                    &tcNodeFailptr }; 
     init_globals_list(tmp, sizeof(tmp)/sizeof(tmp[0]));
   }
 #endif

=== modified file 'storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp'
--- a/storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp	2008-11-13 13:15:56 +0000
+++ b/storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp	2008-12-08 12:35:55 +0000
@@ -3302,6 +3302,8 @@ void Dbtc::sendlqhkeyreq(Signal* signal,
   const Uint32 noOfLqhs = regTcPtr->noOfNodes;
   if(commitAckMarker != RNIL){
     jam();
+    ndbassert(regApiPtr->commitAckMarker == commitAckMarker);
+
     LqhKeyReq::setMarkerFlag(Tdata10, 1);
 
     CommitAckMarker * tmp = m_commitAckMarkerHash.getPtr(commitAckMarker);
@@ -3594,6 +3596,7 @@ void Dbtc::releaseTcCon() 
   UintR TconcurrentOp = c_counters.cconcurrentOp;
   UintR TtcConnectptrIndex = tcConnectptr.i;
 
+  ndbrequire(regTcPtr->commitAckMarker == RNIL);
   regTcPtr->tcConnectstate = OS_CONNECTED;
   regTcPtr->nextTcConnect = TfirstfreeTcConnect;
   regTcPtr->apiConnect = RNIL;
@@ -3786,6 +3789,7 @@ void Dbtc::execLQHKEYCONF(Signal* signal
   regTcPtr->lastLqhCon = tlastLqhConnect;
   regTcPtr->lastLqhNodeId = refToNode(tlastLqhBlockref);
   regTcPtr->noFiredTriggers = noFired;
+  regTcPtr->commitAckMarker = RNIL;
 
   UintR Ttckeyrec = (UintR)regApiPtr.p->tckeyrec;
   UintR TclientData = regTcPtr->clientData;
@@ -4519,7 +4523,7 @@ void Dbtc::commit020Lab(Signal* signal) 
 
     if (localTcConnectptr.i != RNIL) {
       Tcount = Tcount + 1;
-      if (Tcount < 16 && !ERROR_INSERTED(8057)) {
+      if (Tcount < 16 && !ERROR_INSERTED(8057) && !ERROR_INSERTED(8073)) {
         ptrCheckGuard(localTcConnectptr,
                       TtcConnectFilesize, localTcConnectRecord);
         jam();
@@ -4530,6 +4534,14 @@ void Dbtc::commit020Lab(Signal* signal) 
           CLEAR_ERROR_INSERT_VALUE;
           return;
         }//if
+        
+        if (ERROR_INSERTED(8073))
+        {
+          execSEND_PACKED(signal);
+          signal->theData[0] = 9999;
+          sendSignalWithDelay(CMVMI_REF, GSN_NDB_TAMPER, signal, 100, 1);
+          return;
+        }
         signal->theData[0] = TcContinueB::ZSEND_COMMIT_LOOP;
         signal->theData[1] = apiConnectptr.i;
         signal->theData[2] = localTcConnectptr.i;
@@ -4796,7 +4808,6 @@ void Dbtc::copyApi(ApiConnectRecordPtr c
   UintR Tlqhkeyconfrec = regApiPtr.p->lqhkeyconfrec;
   UintR TgcpPointer = regApiPtr.p->gcpPointer;
   UintR TgcpFilesize = cgcpFilesize;
-  UintR TcommitAckMarker = regApiPtr.p->commitAckMarker;
   NdbNodeBitmask Tnodes = regApiPtr.p->m_transaction_nodes;
   GcpRecord *localGcpRecord = gcpRecord;
 
@@ -4807,7 +4818,7 @@ void Dbtc::copyApi(ApiConnectRecordPtr c
   copyPtr.p->transid[0] = Ttransid1;
   copyPtr.p->transid[1] = Ttransid2;
   copyPtr.p->lqhkeyconfrec = Tlqhkeyconfrec;
-  copyPtr.p->commitAckMarker = TcommitAckMarker;
+  copyPtr.p->commitAckMarker = RNIL;
   copyPtr.p->m_transaction_nodes = Tnodes;
   copyPtr.p->singleUserMode = 0;
 
@@ -5134,6 +5145,7 @@ void Dbtc::releaseApiConCopy(Signal* sig
   regApiPtr->nextApiConnect = TfirstfreeApiConnectCopyOld;
   setApiConTimer(apiConnectptr.i, 0, __LINE__);
   regApiPtr->apiConnectstate = CS_RESTART;
+  ndbrequire(regApiPtr->commitAckMarker == RNIL);
 }//Dbtc::releaseApiConCopy()
 
 /* ========================================================================= */
@@ -5372,8 +5384,10 @@ void Dbtc::clearCommitAckMarker(ApiConne
   if (regApiPtr->commitAckMarker == RNIL)
     ndbassert(commitAckMarker == RNIL);
   if (commitAckMarker != RNIL)
-    ndbassert(regApiPtr->commitAckMarker != RNIL);
-  if(commitAckMarker != RNIL){
+    ndbassert(regApiPtr->commitAckMarker == commitAckMarker);
+  
+  if(commitAckMarker != RNIL)
+  {
     jam();
     m_commitAckMarkerHash.release(commitAckMarker);
     regTcPtr->commitAckMarker = RNIL;
@@ -7494,6 +7508,10 @@ void Dbtc::execTAKE_OVERTCCONF(Signal* s
   if (signal->getSendersBlockRef() != reference())
   {
     jam();
+
+    tcNodeFailptr.i = 0;
+    ptrAss(tcNodeFailptr, tcFailRecord);
+
     /**
      * Node should be in queue
      */
@@ -7918,7 +7936,7 @@ void Dbtc::completeTransAtTakeOverDoOne(
 }//Dbtc::completeTransAtTakeOverDoOne()
 
 void 
-Dbtc::sendTCKEY_FAILREF(Signal* signal, const ApiConnectRecord * regApiPtr){
+Dbtc::sendTCKEY_FAILREF(Signal* signal, ApiConnectRecord * regApiPtr){
   jam();
 
   const Uint32 ref = regApiPtr->ndbapiBlockref;
@@ -7941,6 +7959,14 @@ Dbtc::sendTCKEY_FAILREF(Signal* signal, 
       routeTCKEY_FAILREFCONF(signal, regApiPtr, GSN_TCKEY_FAILREF, 3);
     }
   }
+
+  const Uint32 marker = regApiPtr->commitAckMarker;
+  if(marker != RNIL)
+  {
+    jam();
+    m_commitAckMarkerHash.release(marker);
+    regApiPtr->commitAckMarker = RNIL;
+  }
 }
 
 void 
@@ -7953,7 +7979,7 @@ Dbtc::sendTCKEY_FAILCONF(Signal* signal,
   const Uint32 nodeId = refToNode(ref);
   if(ref != 0)
   {
-    jam()
+    jam();
     failConf->apiConnectPtr = regApiPtr->ndbapiConnect | (marker != RNIL);
     failConf->transId1 = regApiPtr->transid[0];
     failConf->transId2 = regApiPtr->transid[1];
@@ -8168,17 +8194,6 @@ void Dbtc::toAbortHandlingLab(Signal* si
         if (apiConnectptr.p->takeOverRec != (Uint8)Z8NIL) {
           jam();
 	  sendTCKEY_FAILREF(signal, apiConnectptr.p);
-	  const Uint32 marker = apiConnectptr.p->commitAckMarker;
-          if(marker != RNIL){
-	    jam();
-
-            CommitAckMarkerPtr tmp;
-            tmp.i = marker;
-            tmp.p = m_commitAckMarkerHash.getPtr(tmp.i);
-            
-            m_commitAckMarkerHash.release(tmp);
-            apiConnectptr.p->commitAckMarker = RNIL;
-          }
           
 	  /*------------------------------------------------------------*/
 	  /*       WE HAVE COMPLETED THIS TRANSACTION NOW AND CAN       */
@@ -8799,6 +8814,7 @@ void Dbtc::updateApiStateFail(Signal* si
       tmp.p->noOfLqhs      = 1;
       tmp.p->lqhNodeId[0]  = tnodeid;
       tmp.p->apiConnectPtr = apiConnectptr.i;
+
 #if defined VM_TRACE || defined ERROR_INSERT
       {
 	CommitAckMarkerPtr check;
@@ -8813,10 +8829,23 @@ void Dbtc::updateApiStateFail(Signal* si
       tmp.i = marker;
       tmp.p = m_commitAckMarkerHash.getPtr(marker);
 
+      ndbassert(tmp.p->transid1 == ttransid1);
+      ndbassert(tmp.p->transid2 == ttransid2);
+
       const Uint32 noOfLqhs = tmp.p->noOfLqhs;
+      for (Uint32 i = 0; i<noOfLqhs && i < MAX_REPLICAS; i++)
+      {
+        if (tmp.p->lqhNodeId[i] == tnodeid)
+        {
+          jam();
+          goto found;
+        }
+      }
       ndbrequire(noOfLqhs < MAX_REPLICAS);
       tmp.p->lqhNodeId[noOfLqhs] = tnodeid;
       tmp.p->noOfLqhs = (noOfLqhs + 1);
+  found:
+      (void)1;
     }
   }
 
@@ -10808,6 +10837,7 @@ void Dbtc::initialiseTcConnect(Signal* s
     tcConnectptr.p->apiConnect = RNIL;
     tcConnectptr.p->noOfNodes = 0;
     tcConnectptr.p->nextTcConnect = tcConnectptr.i + 1;
+    tcConnectptr.p->commitAckMarker = RNIL;
   }//for
   tcConnectptr.i = titcTmp - 1;
   ptrAss(tcConnectptr, tcConnectRecord);
@@ -10824,6 +10854,7 @@ void Dbtc::initialiseTcConnect(Signal* s
     tcConnectptr.p->apiConnect = RNIL;
     tcConnectptr.p->noOfNodes = 0;
     tcConnectptr.p->nextTcConnect = tcConnectptr.i + 1;
+    tcConnectptr.p->commitAckMarker = RNIL;
   }//for
   tcConnectptr.i = ctcConnectFilesize - 1;
   ptrAss(tcConnectptr, tcConnectRecord);
@@ -10917,6 +10948,15 @@ void Dbtc::releaseAbortResources(Signal*
     releaseTcCon();
     tcConnectptr.i = rarTcConnectptr.i;
   }//while
+
+  Uint32 marker = apiConnectptr.p->commitAckMarker;
+  if (marker != RNIL)
+  {
+    jam();
+    m_commitAckMarkerHash.release(marker);
+    apiConnectptr.p->commitAckMarker = RNIL;
+  }
+
   apiConnectptr.p->firstTcConnect = RNIL;
   apiConnectptr.p->lastTcConnect = RNIL;
   apiConnectptr.p->m_transaction_nodes.clear();
@@ -11007,6 +11047,7 @@ void Dbtc::releaseApiConnectFail(Signal*
   setApiConTimer(apiConnectptr.i, 0, __LINE__);
   apiConnectptr.p->nextApiConnect = cfirstfreeApiConnectFail;
   cfirstfreeApiConnectFail = apiConnectptr.i;
+  ndbrequire(apiConnectptr.p->commitAckMarker == RNIL);
 }//Dbtc::releaseApiConnectFail()
 
 void Dbtc::releaseKeys() 
@@ -11617,6 +11658,12 @@ Dbtc::execDUMP_STATE_ORD(Signal* signal)
       sendSignal(reference(), GSN_DUMP_STATE_ORD, signal, len, JBB);
     }
     return;
+  }
+
+  if (arg == 4002)
+  {
+    ndbrequire(m_commitAckMarkerPool.getNoOfFree() == 
+               m_commitAckMarkerPool.getSize());
   }
 }//Dbtc::execDUMP_STATE_ORD()
 

=== modified file 'storage/ndb/src/mgmclient/CommandInterpreter.cpp'
--- a/storage/ndb/src/mgmclient/CommandInterpreter.cpp	2008-03-14 13:32:49 +0000
+++ b/storage/ndb/src/mgmclient/CommandInterpreter.cpp	2008-12-03 13:49:39 +0000
@@ -2236,10 +2236,10 @@ print_status(const ndb_mgm_node_state * 
          << ": " << status_string(state->node_status);
   switch(state->node_status){
   case NDB_MGM_NODE_STATUS_STARTING:
-    ndbout << " (Phase " << state->start_phase << ")";
+    ndbout << " (Last completed phase " << state->start_phase << ")";
     break;
   case NDB_MGM_NODE_STATUS_SHUTTING_DOWN:
-    ndbout << " (Phase " << state->start_phase << ")";
+    ndbout << " (Last completed phase " << state->start_phase << ")";
     break;
   default:
     break;

=== modified file 'storage/ndb/test/include/NdbRestarter.hpp'
--- a/storage/ndb/test/include/NdbRestarter.hpp	2008-02-21 13:57:42 +0000
+++ b/storage/ndb/test/include/NdbRestarter.hpp	2008-12-08 12:35:55 +0000
@@ -69,6 +69,7 @@ public:
   int waitNodesNoStart(const int * _nodes, int _num_nodes,
 		       unsigned int _timeout = 120); 
 
+  int checkClusterAlive(const int * deadnodes, int num_nodes);
 
   int getNumDbNodes();
   int insertErrorInNode(int _nodeId, int error);

=== modified file 'storage/ndb/test/ndbapi/testNodeRestart.cpp'
--- a/storage/ndb/test/ndbapi/testNodeRestart.cpp	2008-08-20 20:29:47 +0000
+++ b/storage/ndb/test/ndbapi/testNodeRestart.cpp	2008-12-08 12:35:55 +0000
@@ -264,6 +264,9 @@ int runRestarter(NDBT_Context* ctx, NDBT
   int result = NDBT_OK;
   int loops = ctx->getNumLoops();
   int sync_threads = ctx->getProperty("SyncThreads", (unsigned)0);
+  int sleep0 = ctx->getProperty("Sleep0", (unsigned)0);
+  int sleep1 = ctx->getProperty("Sleep1", (unsigned)0);
+  int randnode = ctx->getProperty("RandNode", (unsigned)0);
   NdbRestarter restarter;
   int i = 0;
   int lastId = 0;
@@ -282,6 +285,10 @@ int runRestarter(NDBT_Context* ctx, NDBT
   while(i<loops && result != NDBT_FAILED && !ctx->isTestStopped()){
 
     int id = lastId % restarter.getNumDbNodes();
+    if (randnode == 1)
+    {
+      id = rand() % restarter.getNumDbNodes();
+    }
     int nodeId = restarter.getDbNodeId(id);
     ndbout << "Restart node " << nodeId << endl; 
     if(restarter.restartOneDbNode(nodeId, false, true, true) != 0){
@@ -297,6 +304,9 @@ int runRestarter(NDBT_Context* ctx, NDBT
       break;
     }
 
+    if (sleep1)
+      NdbSleep_MilliSleep(sleep1);
+
     if (restarter.startNodes(&nodeId, 1))
     {
       g_err << "Failed to start node" << endl;
@@ -310,6 +320,9 @@ int runRestarter(NDBT_Context* ctx, NDBT
       break;
     }
 
+    if (sleep0)
+      NdbSleep_MilliSleep(sleep0);
+
     ctx->sync_up_and_wait("PauseThreads", sync_threads);
 
     lastId++;
@@ -2913,6 +2926,197 @@ loop2:
   return NDBT_OK;
 }
 
+int 
+runHammer(NDBT_Context* ctx, NDBT_Step* step)
+{ 
+  int records = ctx->getNumRecords();
+  Ndb* pNdb = GETNDB(step);
+  HugoOperations hugoOps(*ctx->getTab());
+  while (!ctx->isTestStopped())
+  {
+    int r = rand() % records;
+    if (hugoOps.startTransaction(pNdb) != 0)
+      continue;
+    
+    if ((rand() % 100) < 50)
+    {
+      if (hugoOps.pkUpdateRecord(pNdb, r, 1, rand()) != 0)
+        goto err;
+    }
+    else
+    {
+      if (hugoOps.pkWriteRecord(pNdb, r, 1, rand()) != 0)
+        goto err;
+    }
+    
+    if (hugoOps.execute_NoCommit(pNdb) != 0)
+      goto err;
+    
+    if (hugoOps.pkDeleteRecord(pNdb, r, 1) != 0)
+      goto err;
+    
+    if (hugoOps.execute_NoCommit(pNdb) != 0)
+      goto err;
+    
+    if ((rand() % 100) < 50)
+    {
+      if (hugoOps.pkInsertRecord(pNdb, r, 1, rand()) != 0)
+        goto err;
+    }
+    else
+    {
+      if (hugoOps.pkWriteRecord(pNdb, r, 1, rand()) != 0)
+        goto err;
+    }
+    
+    if ((rand() % 100) < 90)
+    {
+      hugoOps.execute_Commit(pNdb);
+    }
+    else
+    {
+  err:
+      hugoOps.execute_Rollback(pNdb);
+    }
+    
+    hugoOps.closeTransaction(pNdb);
+  }
+  return NDBT_OK;
+}
+
+int 
+runMixedLoad(NDBT_Context* ctx, NDBT_Step* step)
+{ 
+  int res = 0;
+  int records = ctx->getNumRecords();
+  Ndb* pNdb = GETNDB(step);
+  HugoOperations hugoOps(*ctx->getTab());
+  unsigned id = (unsigned)rand();
+  while (!ctx->isTestStopped())
+  {
+    if (ctx->getProperty("Pause", (Uint32)0))
+    {
+      ndbout_c("thread %u stopped", id);
+      ctx->sync_down("WaitThreads");
+      while (ctx->getProperty("Pause", (Uint32)0) && !ctx->isTestStopped())
+        NdbSleep_MilliSleep(15);
+      
+      if (ctx->isTestStopped())
+        break;
+      ndbout_c("thread %u continue", id);
+    }
+
+    if ((res = hugoOps.startTransaction(pNdb)) != 0)
+    {
+      if (res == 4009)
+        return NDBT_FAILED;
+      continue;
+    }
+    
+    for (int i = 0; i < 10; i++)
+    {
+      int r = rand() % records;
+      if ((rand() % 100) < 50)
+      {
+        if (hugoOps.pkUpdateRecord(pNdb, r, 1, rand()) != 0)
+          goto err;
+      }
+      else
+      {
+        if (hugoOps.pkWriteRecord(pNdb, r, 1, rand()) != 0)
+          goto err;
+      }
+    }      
+    
+    if ((rand() % 100) < 90)
+    {
+      res = hugoOps.execute_Commit(pNdb);
+    }
+    else
+    {
+  err:
+      res = hugoOps.execute_Rollback(pNdb);
+    }
+    
+    hugoOps.closeTransaction(pNdb);
+
+    if (res == 4009)
+    {
+      return NDBT_FAILED;
+    }
+  }
+  return NDBT_OK;
+}
+
+int
+runBug41295(NDBT_Context* ctx, NDBT_Step* step)
+{
+  NdbRestarter res;
+
+  if (res.getNumDbNodes() < 2)
+  {
+    ctx->stopTest();
+    return NDBT_OK;
+  }
+
+
+  int leak = 4002;
+  const int cases = 1;
+  int loops = ctx->getNumLoops();
+  if (loops <= cases)
+    loops = cases + 1;
+
+  for (int i = 0; i<loops; i++)
+  {
+    int master = res.getMasterNodeId();
+    int next = res.getNextMasterNodeId(master);
+    
+    int val2[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert, 1 };
+    if (res.dumpStateOneNode(next, val2, 2))
+      return NDBT_FAILED;
+    
+    ndbout_c("stopping %u, err 8073", next);
+    res.insertErrorInNode(next, 8073);
+    ndbout_c("waiting for %u", next);
+    res.waitNodesNoStart(&next, 1);
+    
+    ndbout_c("pausing all threads");
+    ctx->setProperty("Pause", 1);
+    ctx->sync_up_and_wait("WaitThreads", ctx->getProperty("Threads", 1));
+    ndbout_c("all threads paused");
+    NdbSleep_MilliSleep(5000);
+    res.dumpStateAllNodes(&leak, 1);
+    NdbSleep_MilliSleep(1000);
+    if (res.checkClusterAlive(&next, 1))
+    {
+      return NDBT_FAILED;
+    }
+    ndbout_c("restarting threads");
+    ctx->setProperty("Pause", (Uint32)0);
+    
+    ndbout_c("starting %u", next);
+    res.startNodes(&next, 1);
+    ndbout_c("waiting for cluster started");
+    if (res.waitClusterStarted())
+    {
+      return NDBT_FAILED;
+    }
+
+    ndbout_c("pausing all threads");
+    ctx->setProperty("Pause", 1);
+    ctx->sync_up_and_wait("WaitThreads", ctx->getProperty("Threads", 1));
+    ndbout_c("all threads paused");
+    NdbSleep_MilliSleep(5000);
+    res.dumpStateAllNodes(&leak, 1);
+    NdbSleep_MilliSleep(1000);
+    ndbout_c("restarting threads");
+    ctx->setProperty("Pause", (Uint32)0);
+  }
+  
+  ctx->stopTest();
+  return NDBT_OK;
+}
+
 NDBT_TESTSUITE(testNodeRestart);
 TESTCASE("NoLoad", 
 	 "Test that one node at a time can be stopped and then restarted "\
@@ -3342,6 +3546,23 @@ TESTCASE("Bug36245", ""){
   INITIALIZER(runLoadTable);
   STEP(runBug36245);
   VERIFIER(runClearTable);
+}
+TESTCASE("NF_Hammer", ""){
+  TC_PROPERTY("Sleep0", 9000);
+  TC_PROPERTY("Sleep1", 3000);
+  TC_PROPERTY("Rand", 1);
+  INITIALIZER(runLoadTable);
+  STEPS(runHammer, 25);
+  STEP(runRestarter);
+  VERIFIER(runClearTable);
+}
+TESTCASE("Bug41295", "")
+{
+  TC_PROPERTY("Threads", 25);
+  INITIALIZER(runLoadTable);
+  STEPS(runMixedLoad, 25);
+  STEP(runBug41295);
+  FINALIZER(runClearTable);
 }
 NDBT_TESTSUITE_END(testNodeRestart);
 

=== modified file 'storage/ndb/test/run-test/command.cpp'
--- a/storage/ndb/test/run-test/command.cpp	2008-02-21 13:57:42 +0000
+++ b/storage/ndb/test/run-test/command.cpp	2008-11-27 18:03:09 +0000
@@ -66,6 +66,9 @@ static
 bool
 do_change_version(atrt_config& config, SqlResultSet& command,
                   AtrtClient& atrtdb){
+  /**
+   * TODO make option to restart "not" initial
+   */
   uint process_id= command.columnAsInt("process_id");
   const char* process_args= command.column("process_args");
 

=== modified file 'storage/ndb/test/run-test/daily-basic-tests.txt'
--- a/storage/ndb/test/run-test/daily-basic-tests.txt	2008-11-08 21:08:06 +0000
+++ b/storage/ndb/test/run-test/daily-basic-tests.txt	2008-12-08 12:35:55 +0000
@@ -1157,22 +1157,22 @@ cmd: testNdbApi
 args: -l 100 -n Bug37158
 
 # EOF 2008-06-03
-
 max-time: 500
 cmd: test_event
 args -n bug37672 T1
 
 #EOF 2008-07-04
-
 max-time: 500
 cmd: testScanFilter
 args: 
 
 #EOF 2008-07-09
-
 max-time: 600
 cmd: test_event
 args -r 5000 -n Bug30780 T1
 
 #EOF 2008-08-11
+max-time: 1200
+cmd: testNodeRestart
+args -n Bug41295 T1
 

=== modified file 'storage/ndb/test/run-test/daily-devel-tests.txt'
--- a/storage/ndb/test/run-test/daily-devel-tests.txt	2008-08-30 05:13:47 +0000
+++ b/storage/ndb/test/run-test/daily-devel-tests.txt	2008-12-03 19:44:54 +0000
@@ -133,6 +133,10 @@ max-time: 2500
 cmd: testNodeRestart
 args: -n FiftyPercentStopAndWait T6 T13 
 
+max-time: 2500
+cmd: testNodeRestart
+args: -n NF_Hammer -r 5 T1
+
 #max-time: 500
 #cmd: testNodeRestart
 #args: -n StopOnError T1 

=== modified file 'storage/ndb/test/run-test/setup.cpp'
--- a/storage/ndb/test/run-test/setup.cpp	2008-10-08 21:05:55 +0000
+++ b/storage/ndb/test/run-test/setup.cpp	2008-11-27 18:03:09 +0000
@@ -309,7 +309,7 @@ load_process(atrt_config& config, atrt_c
 			      proc.m_host->m_basedir.c_str());
     proc.m_proc.m_args.appfmt(" --defaults-group-suffix=%s",
 			      cluster.m_name.c_str());
-    proc.m_proc.m_args.append(" --nodaemon -n");
+    proc.m_proc.m_args.append(" --nodaemon --initial -n");
     if (g_fix_nodeid)
       proc.m_proc.m_args.appfmt(" --ndb-nodeid=%d", proc.m_nodeid);
     proc.m_proc.m_cwd.assfmt("%sndbd.%d", dir.c_str(), proc.m_index);

=== modified file 'storage/ndb/test/src/NdbRestarter.cpp'
--- a/storage/ndb/test/src/NdbRestarter.cpp	2008-03-26 14:34:39 +0000
+++ b/storage/ndb/test/src/NdbRestarter.cpp	2008-12-08 12:35:55 +0000
@@ -22,6 +22,7 @@
 #include <random.h>
 #include <kernel/ndb_limits.h>
 #include <ndb_version.h>
+#include <NodeBitmask.hpp>
 
 #define MGMERR(h) \
   ndbout << "latest_error="<<ndb_mgm_get_latest_error(h) \
@@ -541,7 +542,7 @@ NdbRestarter::getStatus(){
         }
       }
       const int err = ndb_mgm_get_latest_error(handle);
-      ndbout << "status==NULL, retries="<<retries<<endl;
+      ndbout << "status==NULL, retries="<<retries<< " err=" << err << endl;
       MGMERR(handle);
       retries++;
       continue;
@@ -802,5 +803,26 @@ NdbRestarter::setReconnect(bool val){
   m_reconnect= val;
 }
 
+int
+NdbRestarter::checkClusterAlive(const int * deadnodes, int num_nodes)
+{
+  if (getStatus() != 0)
+    return -1;
+  
+  NdbNodeBitmask mask;
+  for (int i = 0; i<num_nodes; i++)
+    mask.set(deadnodes[i]);
+  
+  for (size_t n = 0; n < ndbNodes.size(); n++)
+  {
+    if (mask.get(ndbNodes[n].node_id))
+      continue;
+
+    if (ndbNodes[n].node_status != NDB_MGM_NODE_STATUS_STARTED)
+      return ndbNodes[n].node_id;
+  }
+  
+  return 0;
+}
 
 template class Vector<ndb_mgm_node_state>;

=== modified file 'storage/ndb/test/tools/connect.cpp'
--- a/storage/ndb/test/tools/connect.cpp	2008-02-20 09:04:29 +0000
+++ b/storage/ndb/test/tools/connect.cpp	2008-11-26 12:26:00 +0000
@@ -2,8 +2,7 @@
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
-   (at your option) any later version.
+   the Free Software Foundation; version 2 of the License.
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of

=== modified file 'support-files/mysql.spec.sh'
--- a/support-files/mysql.spec.sh	2008-11-14 16:29:38 +0000
+++ b/support-files/mysql.spec.sh	2008-11-25 02:04:58 +0000
@@ -41,6 +41,7 @@
 %else
 %define release 0.glibc23
 %endif
+%define license GPL
 %define mysqld_user	mysql
 %define mysqld_group	mysql
 %define server_suffix -standard
@@ -74,7 +75,7 @@ Summary:	MySQL: a very fast and reliable
 Group:		Applications/Databases
 Version:	@MYSQL_NO_DASH_VERSION@
 Release:	%{release}
-License:	Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc.  All rights reserved.  Use is subject to license terms.  Under GPL license as shown in the Description field.
+License:	Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc.  All rights reserved.  Use is subject to license terms.  Under %{license} license as shown in the Description field.
 Source:		http://www.mysql.com/Downloads/MySQL-@MYSQL_BASE_VERSION@/mysql-%{mysql_version}.tar.gz
 URL:		http://www.mysql.com/
 Packager:	Sun Microsystems, Inc. Product Engineering Team <build@stripped>
@@ -361,7 +362,7 @@ CFLAGS="$CFLAGS" \
 CXXFLAGS="$CXXFLAGS" \
 BuildMySQL "\
 		--with-debug \
-		--with-comment=\"MySQL Community Server - Debug (GPL)\"")
+		--with-comment=\"MySQL Community Server - Debug (%{license})\"")
 
 # We might want to save the config log file
 if test -n "$MYSQL_DEBUGCONFLOG_DEST"
@@ -382,7 +383,7 @@ CFLAGS="$CFLAGS" \
 CXXFLAGS="$CXXFLAGS" \
 BuildMySQL "\
 		--with-embedded-server \
-		--with-comment=\"MySQL Community Server (GPL)\"")
+		--with-comment=\"MySQL Community Server (%{license})\"")
 # We might want to save the config log file
 if test -n "$MYSQL_CONFLOG_DEST"
 then

Thread
bzr push into mysql-5.1 branch (tomas.ulin:2756 to 2769) Bug#41338Tomas Ulin11 Dec