List:Commits« Previous MessageNext Message »
From:Jonas Oreland Date:November 10 2009 11:50am
Subject:bzr push into mysql-5.1-telco-7.1 branch (jonas:3148 to 3149)
View as plain text  
 3149 Jonas Oreland	2009-11-10 [merge]
      merge 70 to 71

    modified:
      mysql-test/suite/ndb/r/ndbinfo.result
      mysql-test/suite/ndb/t/ndbinfo.test
      mysql-test/suite/ndb/t/test_ndbinfo.test
      storage/ndb/src/cw/cpcd/Process.cpp
      storage/ndb/src/kernel/blocks/dbinfo/Dbinfo.cpp
      storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp
      storage/ndb/src/kernel/blocks/lgman.cpp
      storage/ndb/src/kernel/blocks/lgman.hpp
      storage/ndb/test/run-test/files.cpp
      storage/ndb/tools/ndbinfo_sql.cpp
 3148 Jonas Oreland	2009-11-09
      ndb - fix bad merge

    modified:
      storage/ndb/test/ndbapi/CMakeLists.txt
=== modified file 'mysql-test/suite/ndb/r/ndbinfo.result'
--- a/mysql-test/suite/ndb/r/ndbinfo.result	2009-11-08 14:17:04 +0000
+++ b/mysql-test/suite/ndb/r/ndbinfo.result	2009-11-09 18:52:53 +0000
@@ -159,5 +159,9 @@ ERROR HY000: Variable 'ndbinfo_table_pre
 set @@ndbinfo_database="somethingelse";
 ERROR HY000: Variable 'ndbinfo_database' is a read only variable
 
+SELECT count(*) >= 20 FROM block;
+count(*) >= 20
+1
+
 ## Cleanup
 DROP DATABASE ndbinfo;

=== modified file 'mysql-test/suite/ndb/t/ndbinfo.test'
--- a/mysql-test/suite/ndb/t/ndbinfo.test	2009-11-08 21:16:50 +0000
+++ b/mysql-test/suite/ndb/t/ndbinfo.test	2009-11-09 18:52:53 +0000
@@ -80,5 +80,8 @@ set @@ndbinfo_table_prefix="somethingels
 --error ER_INCORRECT_GLOBAL_LOCAL_VAR
 set @@ndbinfo_database="somethingelse";
 
+# Check that block table has been created and contain data
+SELECT count(*) >= 20 FROM block;
+
 ## Cleanup
 DROP DATABASE ndbinfo;

=== modified file 'mysql-test/suite/ndb/t/test_ndbinfo.test'
--- a/mysql-test/suite/ndb/t/test_ndbinfo.test	2009-11-08 19:47:39 +0000
+++ b/mysql-test/suite/ndb/t/test_ndbinfo.test	2009-11-09 16:24:10 +0000
@@ -1,4 +1,3 @@
---result_format 2
 --perl
 use strict;
 
@@ -38,14 +37,7 @@ EOF
 --source $MYSQLTEST_VARDIR/tmp/test_ndbinfo.inc
 
 let $log_file=$MYSQLTEST_VARDIR/tmp/test_ndbinfo.log;
-
---exec $TEST_NDBINFO -n Ndbinfo > $log_file 2>&1
---exec $TEST_NDBINFO -n Ndbinfo10 > $log_file 2>&1
---exec $TEST_NDBINFO -n ScanAll > $log_file 2>&1
---exec $TEST_NDBINFO -n ScanStop > $log_file 2>&1
-## Disable RateLimit temporarily, it hangs when scanning log_space
-#--exec $TEST_NDBINFO -n RateLimit > $log_file 2>&1
---exec $TEST_NDBINFO -n TestTable > $log_file 2>&1
+--exec $TEST_NDBINFO > $log_file 2>&1
 
 echo Sucessfully executed $TEST_NDBINFO;
 

=== modified file 'storage/ndb/src/cw/cpcd/Process.cpp'
--- a/storage/ndb/src/cw/cpcd/Process.cpp	2009-11-06 10:13:20 +0000
+++ b/storage/ndb/src/cw/cpcd/Process.cpp	2009-11-10 03:57:55 +0000
@@ -338,6 +338,7 @@ CPCD::Process::do_exec() {
 
 #ifdef _WIN32
   Vector<BaseString> saved;
+  char *cwd = 0;
   save_environment(m_env.c_str(), saved);
 #endif
 
@@ -346,6 +347,13 @@ CPCD::Process::do_exec() {
   char **argv = BaseString::argify(m_path.c_str(), m_args.c_str());
 
   if(strlen(m_cwd.c_str()) > 0) {
+#ifdef _WIN32
+    cwd = getcwd(0, 0);
+    if(!cwd)
+    {
+      logger.critical("Couldn't getcwd before spawn");
+    }
+#endif
     int err = chdir(m_cwd.c_str());
     if(err == -1) {
       BaseString err;
@@ -427,6 +435,14 @@ CPCD::Process::do_exec() {
 #else
   HANDLE proc = (HANDLE)_spawnvp(_P_NOWAIT, m_path.c_str(), argv);
 
+  // go back up to original cwd
+  if(chdir(cwd))
+  {
+    logger.critical("Couldn't go back to saved cwd after spawn()");
+    logger.critical("%s", strerror(errno));
+  }
+  free(cwd);
+
   // get back to original std i/o
   for(i = 0; i < 3; i++) {
     dup2(std_dups[i], i);
@@ -580,124 +596,16 @@ CPCD::Process::start() {
   return -1;
 }
 
-
-#ifdef _WIN32
-#include <tlhelp32.h>
-/*
-   fill pids with pairs:
-    - all valid pids ordered as (child, parent)
-*/
-struct Pair
-{
-  pid_t child, parent;
-};
-
-typedef Vector<struct Pair> Pairs;
-
-static void get_processes(Pairs & pairs)
-{
-  HANDLE h = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
-  PROCESSENTRY32 pe = { 0 };
-
-  pe.dwSize = sizeof(PROCESSENTRY32);
-  if(Process32First(h, &pe))
-  {
-    do
-    {
-      struct Pair pr;
-      pr.child  = pe.th32ProcessID;
-      pr.parent = pe.th32ParentProcessID;
-      pairs.push_back(pr);
-    } while(Process32Next(h, &pe));
-  }
-  CloseHandle(h);
-}
-
-/*
-   will kill pid after killing it's children.
-   last two parameters come from get_processes()
-*/
-static int kill_tree(pid_t pid, Pairs & pairs)
-{
-  unsigned i, j;
-  int retval = 0;
-  Vector<pid_t> parents;
-
-  parents.push_back(pid);
-  for(i = 0; i < pairs.size(); i++)
-  {
-    Vector<pid_t> new_parents;
-    for(j = 0; j < parents.size(); j++)
-    {
-      if(pairs[i].parent == parents[j])
-      {
-        new_parents.push_back(pairs[i].child);
-      }
-    }
-    if(!new_parents.size())
-    {
-      break;
-    }
-    for(j = 0; j < new_parents.size(); j++)
-    {
-      parents.push_back(new_parents[j]);
-    }
-  }
-
-  logger.debug("killing processes in order: ");
-  for(i = parents.size() - 1; i >= 0; i--)
-  {
-    logger.debug(" %d", parents[i]);
-  }
-  logger.debug(".\n");
-
-  for(i = parents.size() - 1; i >= 0; i--)
-  {
-    pid_t pid = parents[i];
-    HANDLE proc = OpenProcess(PROCESS_TERMINATE, 0, pid);
-    if (!proc)
-    {
-      logger.info("Cannot open process %d (during a kill_tree)\n", pid);
-      return 1;
-    }
-
-    BOOL tp = TerminateProcess(proc, -1);
-    if(!tp)
-    {
-      CloseHandle(proc);
-      return 2;
-    }
-  }
-  return 0;
-}
-
-/*
-  function to kill pid and children processes
-*/
-static int kill_process_tree(pid_t pid)
-{
-  Pairs pairs;
-
-  get_processes(pairs);
-  if(!pairs.size())
-  {
-    return 1;
-  }
-  return kill_tree(pid, pairs);
-}
-#endif
-
 void
 CPCD::Process::stop() {
 
   char filename[PATH_MAX*2+1];
   BaseString::snprintf(filename, sizeof(filename), "%d", m_id);
   unlink(filename);
-
-  if (is_bad_pid(m_pid))
-  {
+  
+  if (is_bad_pid(m_pid)) {
     logger.critical("Stopping process with bogus pid: %d id: %d", 
-                   m_pid, m_id);
+		    m_pid, m_id);
     return;
   }
 
@@ -732,9 +640,21 @@ CPCD::Process::stop() {
     }
   } 
 #else
-  if(isRunning())
-  {
-    kill_process_tree(m_pid);
+  if (isRunning()) {
+    HANDLE proc = OpenProcess(PROCESS_TERMINATE, 0, m_pid);
+
+    if (!proc) {
+      logger.critical("Cannot open process %d\n", m_pid);
+      return;
+    }
+
+    BOOL tp = TerminateProcess(proc, -1);
+
+    CloseHandle(proc);
+    if (!tp) {
+      logger.critical("Cannot terminate process %d\n", m_pid);
+      return;
+    }
   }
 #endif
 

=== modified file 'storage/ndb/src/kernel/blocks/dbinfo/Dbinfo.cpp'
--- a/storage/ndb/src/kernel/blocks/dbinfo/Dbinfo.cpp	2009-11-09 12:23:11 +0000
+++ b/storage/ndb/src/kernel/blocks/dbinfo/Dbinfo.cpp	2009-11-10 11:49:35 +0000
@@ -24,7 +24,7 @@
 #include <signaldata/TransIdAI.hpp>
 
 Uint32 dbinfo_blocks[] = { DBACC, DBTUP, BACKUP, DBTC, SUMA, DBUTIL,
-                           TRIX, DBTUX, DBDICT, CMVMI, DBLQH, 0};
+                           TRIX, DBTUX, DBDICT, CMVMI, DBLQH, LGMAN, 0};
 
 Dbinfo::Dbinfo(Block_context& ctx) :
   SimulatedBlock(DBINFO, ctx),

=== modified file 'storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp'
--- a/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp	2009-11-09 13:33:54 +0000
+++ b/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp	2009-11-10 11:49:35 +0000
@@ -21464,14 +21464,13 @@ void Dblqh::execDBINFO_SCANREQ(Signal *s
       row.write_uint64((total-mb));     // currently in use
       row.write_uint64(high);           // in use high water mark
       ndbinfo_send_row(signal, req, row, rl);
-
+      logpart++;
       if (rl.need_break(req))
       {
         jam();
         ndbinfo_send_scan_break(signal, req, rl, logpart);
         return;
       }
-      logpart++;
     }
   }
 
@@ -21919,7 +21918,21 @@ Dblqh::closeFile_cache(Signal* signal,
   {
     jam();
     Ptr<LogFileRecord> evictPtr;
+    Uint32 logPartRec = filePtr.p->logPartRec;
+    /**
+     * Only evict file with same log-part, other redo-execution will continue
+     *   for the log-part once file is closed
+     *
+     * Note: 1) loop is guaranteed to terminate as filePtr must be in list
+     *       2) loop is ok as MAX_CACHED_OPEN_FILES is "small"
+     *          (if it was big, the m_lru should be split per log-part)
+     */
     m_redo_open_file_cache.m_lru.last(evictPtr);
+    while (evictPtr.p->logPartRec != logPartRec)
+    {
+      jam();
+      ndbrequire(m_redo_open_file_cache.m_lru.prev(evictPtr));
+    }
     m_redo_open_file_cache.m_lru.remove(evictPtr);
     evictPtr.p->logFileStatus = LogFileRecord::CLOSING_EXEC_LOG;
     closeFile(signal, evictPtr, line);

=== modified file 'storage/ndb/src/kernel/blocks/lgman.cpp'
--- a/storage/ndb/src/kernel/blocks/lgman.cpp	2009-10-14 11:44:05 +0000
+++ b/storage/ndb/src/kernel/blocks/lgman.cpp	2009-11-09 17:01:33 +0000
@@ -30,6 +30,7 @@
 #include <signaldata/LgmanContinueB.hpp>
 #include <signaldata/GetTabInfo.hpp>
 #include <signaldata/NodeFailRep.hpp>
+#include <signaldata/DbinfoScan.hpp>
 #include "dbtup/Dbtup.hpp"
 
 #include <EventLogger.hpp>
@@ -69,6 +70,7 @@ Lgman::Lgman(Block_context & ctx) :
   addRecSignal(GSN_STTOR, &Lgman::execSTTOR);
   addRecSignal(GSN_READ_CONFIG_REQ, &Lgman::execREAD_CONFIG_REQ);
   addRecSignal(GSN_DUMP_STATE_ORD, &Lgman::execDUMP_STATE_ORD);
+  addRecSignal(GSN_DBINFO_SCANREQ, &Lgman::execDBINFO_SCANREQ);
   addRecSignal(GSN_CONTINUEB, &Lgman::execCONTINUEB);
   addRecSignal(GSN_NODE_FAILREP, &Lgman::execNODE_FAILREP);
 
@@ -421,6 +423,50 @@ Lgman::execDUMP_STATE_ORD(Signal* signal
 }
 
 void
+Lgman::execDBINFO_SCANREQ(Signal *signal)
+{
+  DbinfoScanReq req= *(DbinfoScanReq*)signal->theData;
+  const Ndbinfo::ScanCursor* cursor =
+    (Ndbinfo::ScanCursor*)DbinfoScan::getCursorPtr(&req);
+  Ndbinfo::Ratelimit rl;
+
+  jamEntry();
+
+  if(req.tableId == Ndbinfo::LOG_SPACE_TABLEID)
+  {
+#if 0
+    Uint32 logid = cursor->data[0];
+    while(find_next_logid(logid))
+    {
+      jam();
+      Uint64 mb = Logfile_group::m_free_file_words;
+      Uint64 total = 0; // TODO
+      Uint64 high = 0; // TODO
+
+      Ndbinfo::Row row(signal, req);
+      row.write_uint32(logid);          // log id
+      row.write_uint32(1);              // log type, 1 = DD-UNDO
+      row.write_uint32(0);              // log part
+      row.write_uint32(getOwnNodeId());
+      row.write_uint64(total);          // total allocated
+      row.write_uint64((total-mb));     // currently in use
+      row.write_uint64(high);           // in use high water mark
+      ndbinfo_send_row(signal, req, row, rl);
+      logid++;
+      if (rl.need_break(req))
+      {
+        jam();
+        ndbinfo_send_scan_break(signal, req, rl, logpart);
+        return;
+      }
+    }
+#endif
+  }
+
+  ndbinfo_send_scan_conf(signal, req, rl);
+}
+
+void
 Lgman::execCREATE_FILEGROUP_IMPL_REQ(Signal* signal){
   jamEntry();
   CreateFilegroupImplReq* req= (CreateFilegroupImplReq*)signal->getDataPtr();

=== modified file 'storage/ndb/src/kernel/blocks/lgman.hpp'
--- a/storage/ndb/src/kernel/blocks/lgman.hpp	2009-10-14 11:44:05 +0000
+++ b/storage/ndb/src/kernel/blocks/lgman.hpp	2009-11-09 17:01:33 +0000
@@ -47,6 +47,7 @@ protected:
   void sendSTTORRY(Signal*);
   void execREAD_CONFIG_REQ(Signal* signal);
   void execDUMP_STATE_ORD(Signal* signal);
+  void execDBINFO_SCANREQ(Signal* signal);
   void execCONTINUEB(Signal* signal);
   void execNODE_FAILREP(Signal* signal);
   

=== modified file 'storage/ndb/test/run-test/files.cpp'
--- a/storage/ndb/test/run-test/files.cpp	2009-11-06 10:23:32 +0000
+++ b/storage/ndb/test/run-test/files.cpp	2009-11-10 02:04:05 +0000
@@ -197,7 +197,6 @@ setup_files(atrt_config& config, int set
   }
   
   FILE * out = NULL;
-  bool retval = true;
   if (config.m_generated == false)
   {
     g_logger.info("Nothing configured...");
@@ -274,8 +273,7 @@ setup_files(atrt_config& config, int set
 	if (fenv == 0)
 	{
 	  g_logger.error("Failed to open %s for writing", tmp.c_str());
-	  retval = false;
-          goto end;
+	  return false;
 	}
 	for (size_t k = 0; env[k]; k++)
 	{
@@ -312,8 +310,7 @@ setup_files(atrt_config& config, int set
         if (fenv == 0)
         {
           g_logger.error("Failed to open %s for writing", tmp.c_str());
-          retval = false;
-          goto end;
+          return false;
         }
         fprintf(fenv, "#!/bin/sh\n");
         fprintf(fenv, "cd %s\n", proc.m_proc.m_cwd.c_str());
@@ -326,14 +323,14 @@ setup_files(atrt_config& config, int set
       }
     }
   }
-
-end:
+  
   if (out)
   {
+    fflush(out);
     fclose(out);
   }
 
-  return retval;
+  return true;
 }
 
 static int 

=== modified file 'storage/ndb/tools/ndbinfo_sql.cpp'
--- a/storage/ndb/tools/ndbinfo_sql.cpp	2009-11-08 21:16:50 +0000
+++ b/storage/ndb/tools/ndbinfo_sql.cpp	2009-11-09 18:52:53 +0000
@@ -70,6 +70,34 @@ struct view {
 size_t num_views = sizeof(views)/sizeof(views[0]);
 
 
+#include "../src/common/debugger/BlockNames.cpp"
+static void fill_blocks(void)
+{
+  const char* separator = "";
+  for (BlockNumber i = 0; i < NO_OF_BLOCK_NAMES; i++)
+  {
+    const BlockName& bn = BlockNames[i];
+    printf("%s(%u, \"%s\")", separator, bn.number, bn.name);
+    separator = ", ";
+  }
+}
+
+struct lookup {
+  const char* name;
+  const char* columns;
+  void (*fill)(void);
+} lookups[] =
+{
+  { "block",
+    "no INT UNSIGNED, "
+    "name VARCHAR(512)",
+    &fill_blocks
+   }
+};
+
+size_t num_lookups = sizeof(lookups)/sizeof(lookups[0]);
+
+
 struct replace {
   const char* tag;
   const char* string;
@@ -144,6 +172,14 @@ int main(int argc, char** argv){
   }
   printf("\n");
 
+  printf("# drop any old lookup tables in %s\n", opt_ndbinfo_db);
+  for (size_t i = 0; i < num_lookups; i++)
+  {
+    printf("DROP TABLE IF EXISTS %s.%s;\n",
+            opt_ndbinfo_db, lookups[i].name);
+  }
+  printf("\n");
+
   for (int i = 0; i < Ndbinfo::getNumTables(); i++)
   {
     const Ndbinfo::Table& table = Ndbinfo::getTable(i);
@@ -206,6 +242,25 @@ int main(int argc, char** argv){
 
   }
 
+
+  for (size_t i = 0; i < num_lookups; i++)
+  {
+    lookup l = lookups[i];
+    printf("# %s.%s\n", opt_ndbinfo_db, l.name);
+
+    /* Create lookup table */
+    printf("CREATE TABLE `%s`.`%s` (%s);\n",
+           opt_ndbinfo_db, l.name, l.columns);
+
+    /* Insert data */
+    printf("INSERT INTO `%s`.`%s` VALUES ",
+           opt_ndbinfo_db, l.name);
+    l.fill();
+    printf(";\n");
+
+  }
+  printf("\n");
+
   printf("#\n");
   printf("# %s views\n", opt_ndbinfo_db);
   printf("#\n\n");


Attachment: [text/bzr-bundle] bzr/jonas@mysql.com-20091110114935-a4irjcn3ls58d8at.bundle
Thread
bzr push into mysql-5.1-telco-7.1 branch (jonas:3148 to 3149)Jonas Oreland10 Nov