List:Commits« Previous MessageNext Message »
From:DonKehndon.kehn Date:November 19 2008 4:37pm
Subject:bzr commit into mysql-5.1 branch (DonKehndon.kehn:2755)
View as plain text  
#At file:///u02/devl/bzr-tree/6.3-patch4/ based on revid:don.kehn@stripped

 2755 Don Kehn	2008-11-19 [merge]
      [BUG $33626] merge with  6.3 parent.
added:
  storage/ndb/test/ndbapi/testMgmDisconnect.c
modified:
  mysql-test/ndb/ndb_config_2_node.ini
  storage/ndb/include/kernel/signaldata/FsReadWriteReq.hpp
  storage/ndb/include/mgmapi/mgmapi.h
  storage/ndb/include/mgmapi/mgmapi_config_parameters.h
  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/vm/SimulatedBlock.cpp
  storage/ndb/src/kernel/vm/SimulatedBlock.hpp
  storage/ndb/src/mgmapi/mgmapi.cpp
  storage/ndb/src/mgmclient/CommandInterpreter.cpp
  storage/ndb/src/mgmclient/main.cpp
  storage/ndb/src/mgmsrv/ConfigInfo.cpp
  storage/ndb/test/ndbapi/Makefile.am
  storage/ndb/test/ndbapi/testReconnect.cpp

=== modified file 'mysql-test/ndb/ndb_config_2_node.ini'
--- a/mysql-test/ndb/ndb_config_2_node.ini	2007-11-15 00:29:37 +0000
+++ b/mysql-test/ndb/ndb_config_2_node.ini	2008-11-19 10:13:01 +0000
@@ -35,6 +35,7 @@ HostName= CHOOSE_HOSTNAME_1   # hostname
 
 [ndbd]
 HostName= CHOOSE_HOSTNAME_2   # hostname is a valid network adress
+InitFragmentLogFiles=full
 
 [ndb_mgmd]
 HostName= CHOOSE_HOSTNAME_1   # hostname is a valid network adress

=== modified file 'storage/ndb/include/kernel/signaldata/FsReadWriteReq.hpp'
--- a/storage/ndb/include/kernel/signaldata/FsReadWriteReq.hpp	2007-11-15 00:30:00 +0000
+++ b/storage/ndb/include/kernel/signaldata/FsReadWriteReq.hpp	2008-11-19 10:13:01 +0000
@@ -45,6 +45,7 @@ class FsReadWriteReq {
   friend class Tsman;
   friend class Pgman;
   friend class Restore;
+  friend class Dblqh;
 
   /**
    * For printing

=== modified file 'storage/ndb/include/mgmapi/mgmapi.h'
--- a/storage/ndb/include/mgmapi/mgmapi.h	2008-11-17 14:20:48 +0000
+++ b/storage/ndb/include/mgmapi/mgmapi.h	2008-11-19 10:31:54 +0000
@@ -405,6 +405,23 @@ extern "C" {
    */
   void ndb_mgm_set_name(NdbMgmHandle handle, const char *name);
 
+  /**
+   * Set 'ignore_sigpipe' behaviour
+   *
+   * The mgmapi will by default install a signal handler
+   * that ignores all SIGPIPE signals that might occur when
+   * writing to an already closed or reset socket. An application
+   * that wish to use its own handler for SIGPIPE should call this
+   * function after 'ndb_mgm_create_handle' and before
+   * 'ndb_mgm_connect'(where the signal handler is installed)
+   *
+   * @param   handle        Management handle
+   * @param   val           Value
+   *                        0 - Don't ignore SIGPIPE
+   *                        1 - Ignore SIGPIPE(default)
+   */
+  int ndb_mgm_set_ignore_sigpipe(NdbMgmHandle handle, int val);
+
   /** @} *********************************************************************/
   /**
    * @name Functions: Connect/Disconnect Management Server

=== modified file 'storage/ndb/include/mgmapi/mgmapi_config_parameters.h'
--- a/storage/ndb/include/mgmapi/mgmapi_config_parameters.h	2008-05-29 13:24:03 +0000
+++ b/storage/ndb/include/mgmapi/mgmapi_config_parameters.h	2008-11-19 10:13:01 +0000
@@ -139,6 +139,8 @@
 #define CFG_DB_MAX_BUFFERED_EPOCHS    182
 #define CFG_DB_SUMA_HANDOVER_TIMEOUT  183
 
+#define CFG_DB_INIT_REDO              189
+
 #define CFG_DB_SGA                    198 /* super pool mem */
 #define CFG_DB_DATA_MEM_2             199 /* used in special build in 5.1 */
 

=== modified file 'storage/ndb/src/kernel/blocks/dblqh/Dblqh.hpp'
--- a/storage/ndb/src/kernel/blocks/dblqh/Dblqh.hpp	2008-11-14 11:19:35 +0000
+++ b/storage/ndb/src/kernel/blocks/dblqh/Dblqh.hpp	2008-11-19 10:13:01 +0000
@@ -2158,6 +2158,7 @@ private:
   void execFSWRITEREF(Signal* signal);
   void execFSREADCONF(Signal* signal);
   void execFSREADREF(Signal* signal);
+  void execFSWRITEREQ(Signal*);
   void execSCAN_HBREP(Signal* signal);
   void execTIME_SIGNAL(Signal* signal);
   void execFSSYNCCONF(Signal* signal);
@@ -2904,6 +2905,7 @@ private:
   
   Uint32 c_diskless;
   Uint32 c_o_direct;
+  Uint32 m_use_om_init;
   Uint32 c_error_insert_table_id;
   
 public:

=== 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-11-19 10:13:01 +0000
@@ -309,6 +309,10 @@ Dblqh::Dblqh(Block_context& ctx):
   addRecSignal(GSN_PREPARE_COPY_FRAG_REQ,
 	       &Dblqh::execPREPARE_COPY_FRAG_REQ);
   
+
+  addRecSignal(GSN_FSWRITEREQ,
+               &Dblqh::execFSWRITEREQ);
+
   initData();
 
 #ifdef VM_TRACE

=== modified file 'storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp'
--- a/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp	2008-11-14 11:19:35 +0000
+++ b/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp	2008-11-19 10:13:01 +0000
@@ -63,6 +63,7 @@
 #include <KeyDescriptor.hpp>
 #include <signaldata/RouteOrd.hpp>
 #include <signaldata/FsRef.hpp>
+#include <signaldata/FsReadWriteReq.hpp>
 
 #include "../suma/Suma.hpp"
 
@@ -840,7 +841,8 @@ void Dblqh::startphase3Lab(Signal* signa
       initLogfile(signal, fileNo);
       if ((cstartType == NodeState::ST_INITIAL_START) ||
 	  (cstartType == NodeState::ST_INITIAL_NODE_RESTART)) {
-        if (logFilePtr.i == zeroLogFilePtr.i) {
+        if (logFilePtr.i == zeroLogFilePtr.i)
+        {
           jam();
 /* ------------------------------------------------------------------------- */
 /*IN AN INITIAL START WE START BY CREATING ALL LOG FILES AND SETTING THEIR   */
@@ -848,7 +850,26 @@ void Dblqh::startphase3Lab(Signal* signa
 /*WE START BY CREATING FILE ZERO IN EACH LOG PART AND THEN PROCEED           */
 /*SEQUENTIALLY THROUGH ALL LOG FILES IN THE LOG PART.                        */
 /* ------------------------------------------------------------------------- */
-          openLogfileInit(signal);
+          if (m_use_om_init == 0 || logPartPtr.i == 0)
+          {
+            /**
+             * initialize one file at a time if using OM_INIT
+             */
+            jam();
+#ifdef VM_TRACE
+            if (m_use_om_init)
+            {
+              jam();
+              /**
+               * FSWRITEREQ does cross-thread execute-direct
+               *   which makes the clear_global_variables "unsafe"
+               *   disable it until we're finished with init log-files
+               */
+              disable_global_variables();
+            }
+#endif
+            openLogfileInit(signal);
+          }
         }//if
       }//if
     }//for
@@ -1046,6 +1067,25 @@ void Dblqh::execREAD_CONFIG_REQ(Signal* 
   c_o_direct = true;
   ndb_mgm_get_int_parameter(p, CFG_DB_O_DIRECT, &c_o_direct);
   
+  m_use_om_init = 0;
+  {
+    const char * conf = 0;
+    if (!ndb_mgm_get_string_parameter(p, CFG_DB_INIT_REDO, &conf) && conf)
+    {
+      jam();
+      if (strcmp(conf, "sparse") == 0)
+      {
+        jam();
+        m_use_om_init = 0;
+      }
+      else if (strcmp(conf, "full") == 0)
+      {
+        jam();
+        m_use_om_init = 1;
+      }
+    }
+  }
+
   Uint32 tmp= 0;
   ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_LQH_FRAG, &tmp));
   c_fragment_pool.setSize(tmp);
@@ -13417,9 +13457,20 @@ void Dblqh::openFileInitLab(Signal* sign
 {
   logFilePtr.p->logFileStatus = LogFileRecord::OPEN_INIT;
   seizeLogpage(signal);
-  writeSinglePage(signal, (clogFileSize * ZPAGES_IN_MBYTE) - 1,
-                  ZPAGE_SIZE - 1, __LINE__, false);
-  lfoPtr.p->lfoState = LogFileOperationRecord::INIT_WRITE_AT_END;
+  if (m_use_om_init == 0)
+  {
+    jam();
+    initLogpage(signal);
+    writeSinglePage(signal, (clogFileSize * ZPAGES_IN_MBYTE) - 1,
+                    ZPAGE_SIZE - 1, __LINE__, false);
+    lfoPtr.p->lfoState = LogFileOperationRecord::INIT_WRITE_AT_END;
+  }
+  else
+  {
+    jam();
+    seizeLfo(signal);
+    initWriteEndLab(signal);
+  }
   return;
 }//Dblqh::openFileInitLab()
 
@@ -13518,6 +13569,18 @@ void Dblqh::checkInitCompletedLab(Signal
 /* MEANS THIS PART OF THE LOG IS NOT WRITTEN YET.                            */
 /*---------------------------------------------------------------------------*/
   logPartPtr.p->logLap = 1;
+
+  if (m_use_om_init && logPartPtr.i != 3)
+  {
+    jam();
+    logPartPtr.i++;
+    ptrAss(logPartPtr, logPartRecord);
+    logFilePtr.i = logPartPtr.p->firstLogfile;
+    ptrCheckGuard(logFilePtr, clogFileFileSize, logFileRecord);
+    openLogfileInit(signal);
+    return;
+  }
+
   logPartPtr.i = 0;
 CHECK_LOG_PARTS_LOOP:
   ptrAss(logPartPtr, logPartRecord);
@@ -13536,6 +13599,9 @@ CHECK_LOG_PARTS_LOOP:
 /* NEED TO INITIALISE ALL NEEDED DATA AND TO OPEN FILE ZERO AND THE NEXT AND */
 /* TO SET THE CURRENT LOG PAGE TO BE PAGE 1 IN FILE ZERO.                    */
 /*---------------------------------------------------------------------------*/
+#ifdef VM_TRACE
+    enable_global_variables();
+#endif
     for (logPartPtr.i = 0; logPartPtr.i <= 3; logPartPtr.i++) {
       ptrAss(logPartPtr, logPartRecord);
       signal->theData[0] = ZINIT_FOURTH;
@@ -13680,10 +13746,76 @@ void Dblqh::openLogfileInit(Signal* sign
   signal->theData[6] = FsOpenReq::OM_READWRITE | FsOpenReq::OM_TRUNCATE | FsOpenReq::OM_CREATE | FsOpenReq::OM_AUTOSYNC;
   if (c_o_direct)
     signal->theData[6] |= FsOpenReq::OM_DIRECT;
+
+  Uint64 sz = Uint64(clogFileSize) * 1024 * 1024;
+  req->file_size_hi = Uint32(sz >> 32);
+  req->file_size_lo = Uint32(sz);
+  req->page_size = File_formats::NDB_PAGE_SIZE;
+  if (m_use_om_init)
+  {
+    jam();
+    signal->theData[6] |= FsOpenReq::OM_INIT;
+  }
+
   req->auto_sync_size = MAX_REDO_PAGES_WITHOUT_SYNCH * sizeof(LogPageRecord);
   sendSignal(NDBFS_REF, GSN_FSOPENREQ, signal, FsOpenReq::SignalLength, JBA);
 }//Dblqh::openLogfileInit()
 
+void
+Dblqh::execFSWRITEREQ(Signal* signal)
+{
+  /**
+   * This is currently run in other thread -> no jam
+   *   and no global variables
+   */
+  Ptr<GlobalPage> page_ptr;
+  FsReadWriteReq* req= (FsReadWriteReq*)signal->getDataPtr();
+  m_shared_page_pool.getPtr(page_ptr, req->data.pageData[0]);
+
+  LogFileRecordPtr currLogFilePtr;
+  currLogFilePtr.i = req->userPointer;
+  ptrCheckGuard(currLogFilePtr, clogFileFileSize, logFileRecord);
+
+  LogPartRecordPtr currLogPartPtr;
+  currLogPartPtr.i = currLogFilePtr.p->logPartRec;
+  ptrCheckGuard(currLogPartPtr, clogPartFileSize, logPartRecord);
+
+  Uint32 page_no = req->varIndex;
+  LogPageRecordPtr currLogPagePtr;
+  currLogPagePtr.p = (LogPageRecord*)page_ptr.p;
+
+  bzero(page_ptr.p, sizeof(LogPageRecord));
+  if (page_no == 0)
+  {
+    // keep writing these afterwards
+  }
+  else if (((page_no % ZPAGES_IN_MBYTE) == 0) ||
+           (page_no == ((clogFileSize * ZPAGES_IN_MBYTE) - 1)))
+  {
+    currLogPagePtr.p->logPageWord[ZPOS_LOG_LAP] = currLogPartPtr.p->logLap;
+    currLogPagePtr.p->logPageWord[ZPOS_MAX_GCI_COMPLETED] =
+      currLogPartPtr.p->logPartNewestCompletedGCI;
+    currLogPagePtr.p->logPageWord[ZPOS_MAX_GCI_STARTED] = cnewestGci;
+    currLogPagePtr.p->logPageWord[ZPOS_VERSION] = NDB_VERSION;
+    currLogPagePtr.p->logPageWord[ZPOS_NO_LOG_FILES] =
+      currLogPartPtr.p->noLogFiles;
+    currLogPagePtr.p->logPageWord[ZCURR_PAGE_INDEX] = ZPAGE_HEADER_SIZE;
+    currLogPagePtr.p->logPageWord[ZLAST_LOG_PREP_REF] =
+      (currLogFilePtr.p->fileNo << 16) +
+      (currLogFilePtr.p->currentFilepage >> ZTWOLOG_NO_PAGES_IN_MBYTE);
+
+    currLogPagePtr.p->logPageWord[ZNEXT_PAGE] = RNIL;
+    currLogPagePtr.p->logPageWord[ZPOS_CHECKSUM] =
+      calcPageCheckSum(currLogPagePtr);
+  }
+  else if (0)
+  {
+    currLogPagePtr.p->logPageWord[ZNEXT_PAGE] = RNIL;
+    currLogPagePtr.p->logPageWord[ZPOS_CHECKSUM] =
+      calcPageCheckSum(currLogPagePtr);
+  }
+}
+
 /* OPEN FOR READ/WRITE, DO CREATE AND DO TRUNCATE FILE */
 /* ------------------------------------------------------------------------- */
 /* -------               OPEN NEXT LOG FILE                          ------- */
@@ -13832,6 +13964,9 @@ void Dblqh::seizeLogpage(Signal* signal)
 /*IF LIST IS EMPTY THEN A SYSTEM CRASH IS INVOKED SINCE LOG_PAGE_PTR = RNIL  */
 /* ------------------------------------------------------------------------- */
   cfirstfreeLogPage = logPagePtr.p->logPageWord[ZNEXT_PAGE];
+#ifdef VM_TRACE
+  bzero(logPagePtr.p, sizeof(LogPageRecord));
+#endif
   logPagePtr.p->logPageWord[ZNEXT_PAGE] = RNIL;
   logPagePtr.p->logPageWord[ZPOS_IN_FREE_LIST] = 0;
 }//Dblqh::seizeLogpage()
@@ -13964,10 +14099,21 @@ void Dblqh::writeFileHeaderOpen(Signal* 
 /* ------------------------------------------------------------------------- */
 void Dblqh::writeInitMbyte(Signal* signal) 
 {
-  initLogpage(signal);
-  writeSinglePage(signal, logFilePtr.p->currentMbyte * ZPAGES_IN_MBYTE,
-                  ZPAGE_SIZE - 1, __LINE__, false);
-  lfoPtr.p->lfoState = LogFileOperationRecord::WRITE_INIT_MBYTE;
+  if (m_use_om_init == 0)
+  {
+    jam();
+    initLogpage(signal);
+    writeSinglePage(signal, logFilePtr.p->currentMbyte * ZPAGES_IN_MBYTE,
+                    ZPAGE_SIZE - 1, __LINE__, false);
+    lfoPtr.p->lfoState = LogFileOperationRecord::WRITE_INIT_MBYTE;
+  }
+  else
+  {
+    jam();
+    seizeLfo(signal);
+    logFilePtr.p->currentMbyte = clogFileSize - 1;
+    writeInitMbyteLab(signal);
+  }
 }//Dblqh::writeInitMbyte()
 
 /* ------------------------------------------------------------------------- */

=== modified file 'storage/ndb/src/kernel/vm/SimulatedBlock.cpp'
--- a/storage/ndb/src/kernel/vm/SimulatedBlock.cpp	2008-08-11 11:24:12 +0000
+++ b/storage/ndb/src/kernel/vm/SimulatedBlock.cpp	2008-11-19 10:13:01 +0000
@@ -83,6 +83,7 @@ SimulatedBlock::SimulatedBlock(BlockNumb
 #ifdef VM_TRACE
   m_global_variables = new Ptr<void> * [1];
   m_global_variables[0] = 0;
+  m_global_variables_save = 0;
 #endif
 }
 
@@ -2166,6 +2167,23 @@ SimulatedBlock::execFSAPPENDREF(Signal* 
 }
 
 #ifdef VM_TRACE
+static Ptr<void> * m_empty_global_variables[] = { 0 };
+void
+SimulatedBlock::disable_global_variables()
+{
+  m_global_variables_save = m_global_variables;
+  m_global_variables = m_empty_global_variables;
+}
+
+void
+SimulatedBlock::enable_global_variables()
+{
+  if (m_global_variables == m_empty_global_variables)
+  {
+    m_global_variables = m_global_variables_save;
+  }
+}
+
 void
 SimulatedBlock::clear_global_variables(){
   Ptr<void> ** tmp = m_global_variables;

=== modified file 'storage/ndb/src/kernel/vm/SimulatedBlock.hpp'
--- a/storage/ndb/src/kernel/vm/SimulatedBlock.hpp	2008-11-06 16:46:27 +0000
+++ b/storage/ndb/src/kernel/vm/SimulatedBlock.hpp	2008-11-19 10:13:01 +0000
@@ -598,9 +598,11 @@ public:
 #endif
 
 #ifdef VM_TRACE
-  Ptr<void> **m_global_variables;
+  Ptr<void> **m_global_variables, **m_global_variables_save;
   void clear_global_variables();
   void init_globals_list(void ** tmp, size_t cnt);
+  void disable_global_variables();
+  void enable_global_variables();
 #endif
 };
 

=== modified file 'storage/ndb/src/mgmapi/mgmapi.cpp'
--- a/storage/ndb/src/mgmapi/mgmapi.cpp	2008-11-17 14:20:48 +0000
+++ b/storage/ndb/src/mgmapi/mgmapi.cpp	2008-11-19 10:31:54 +0000
@@ -107,6 +107,7 @@ struct ndb_mgm_handle {
   int mgmd_version_build;
   char * m_bindaddress;
   int m_bindaddress_port;
+  bool ignore_sigpipe;
 };
 
 #define SET_ERROR(h, e, s) setError(h, e, __LINE__, s)
@@ -191,6 +192,7 @@ ndb_mgm_create_handle()
   h->m_name          = 0;
   h->m_bindaddress   = 0;
   h->m_bindaddress_port = 0;
+  h->ignore_sigpipe  = true;
 
   strncpy(h->last_error_desc, "No error", NDB_MGM_MAX_ERR_DESC_SIZE);
 
@@ -266,6 +268,19 @@ ndb_mgm_set_bindaddress(NdbMgmHandle han
   DBUG_RETURN(0);
 }
 
+extern "C"
+int
+ndb_mgm_set_ignore_sigpipe(NdbMgmHandle handle, int val)
+{
+  CHECK_HANDLE(handle, -1);
+  if (handle->connected){
+    SET_ERROR(handle, EINVAL, "Can't change 'ignore_sigpipe' while connected");
+    return -1;
+  }
+  handle->ignore_sigpipe = (val != 0);
+  return 0;
+}
+
 /**
  * Destroy a handle
  */
@@ -530,6 +545,11 @@ ndb_mgm_connect(NdbMgmHandle handle, int
 #endif
   char buf[1024];
 
+#if defined SIGPIPE && !defined _WIN32
+  if (handle->ignore_sigpipe)
+    (void)signal(SIGPIPE, SIG_IGN);
+#endif
+
   /**
    * Do connect
    */

=== modified file 'storage/ndb/src/mgmclient/CommandInterpreter.cpp'
--- a/storage/ndb/src/mgmclient/CommandInterpreter.cpp	2008-03-14 13:34:05 +0000
+++ b/storage/ndb/src/mgmclient/CommandInterpreter.cpp	2008-11-19 09:52:01 +0000
@@ -941,13 +941,25 @@ CommandInterpreter::connect(bool interac
 
   m_mgmsrv = ndb_mgm_create_handle();
   if(m_mgmsrv == NULL) {
-    ndbout_c("Cannot create handle to management server.");
+    ndbout_c("Can't create handle to management server.");
+    exit(-1);
+  }
+  if (ndb_mgm_set_ignore_sigpipe(m_mgmsrv, 0)) {
+    ndbout_c("Can't set 'ignore_sigpipe', error: %d - %s",
+             ndb_mgm_get_latest_error(m_mgmsrv),
+             ndb_mgm_get_latest_error_desc(m_mgmsrv));
     exit(-1);
   }
   if (interactive) {
     m_mgmsrv2 = ndb_mgm_create_handle();
     if(m_mgmsrv2 == NULL) {
-      ndbout_c("Cannot create 2:nd handle to management server.");
+      ndbout_c("Can't create 2:nd handle to management server.");
+      exit(-1);
+    }
+    if (ndb_mgm_set_ignore_sigpipe(m_mgmsrv2, 0)) {
+      ndbout_c("Can't set 'ignore_sigpipe', error: %d - %s",
+               ndb_mgm_get_latest_error(m_mgmsrv2),
+               ndb_mgm_get_latest_error_desc(m_mgmsrv2));
       exit(-1);
     }
   }
@@ -2278,7 +2290,7 @@ CommandInterpreter::executeStatus(int pr
   cl = ndb_mgm_get_status2(m_mgmsrv, all ? types : 0);
   if(cl == NULL) 
   {
-    ndbout_c("Cannot get status of node %d.", processId);
+    ndbout_c("Can't get status of node %d.", processId);
     printError();
     return -1;
   }
@@ -2396,7 +2408,7 @@ CommandInterpreter::executeReport(int pr
     struct ndb_mgm_cluster_state *cl = ndb_mgm_get_status(m_mgmsrv);
     if (cl == NULL)
     {
-      ndbout_c("Cannot get status of node %d.", processId);
+      ndbout_c("Can't get status of node %d.", processId);
       printError();
       return -1;
     }

=== modified file 'storage/ndb/src/mgmclient/main.cpp'
--- a/storage/ndb/src/mgmclient/main.cpp	2007-06-17 15:21:27 +0000
+++ b/storage/ndb/src/mgmclient/main.cpp	2008-11-19 09:52:01 +0000
@@ -55,7 +55,9 @@ handler(int sig)
      * Will happen when connection to mgmsrv is broken
      * Reset connected flag
      */
-    com->disconnect();    
+    printf("Got SIGPIPE!\n");
+    if (com)
+      com->disconnect();
     break;
   }
   DBUG_VOID_RETURN;
@@ -154,6 +156,10 @@ int main(int argc, char** argv){
     prompt= 0;
   }
 
+  // Install our own signal handler for SIGPIPE that calls
+  // 'Ndb_mgmclient' disconnect. In order to avoid that the
+  // mgmapi installs its own SIGPIPE handler, the Ndb_mgmclient will
+  // use 'ndb_mgm_set_ignore_sigpipe(handle, 0)'
   signal(SIGPIPE, handler);
   com = new Ndb_mgmclient(opt_connect_str,1);
   int ret= 0;

=== modified file 'storage/ndb/src/mgmsrv/ConfigInfo.cpp'
--- a/storage/ndb/src/mgmsrv/ConfigInfo.cpp	2008-11-03 08:33:52 +0000
+++ b/storage/ndb/src/mgmsrv/ConfigInfo.cpp	2008-11-19 10:13:01 +0000
@@ -1049,6 +1049,17 @@ const ConfigInfo::ParamInfo ConfigInfo::
     "1G" },
 
   {
+    CFG_DB_INIT_REDO,
+    "InitFragmentLogFiles",
+    DB_TOKEN,
+    "Initialize fragment logfiles (sparse/full)",
+    ConfigInfo::CI_USED,
+    false,
+    ConfigInfo::CI_STRING,
+    UNDEFINED,
+    0, 0 },
+
+  {
     CFG_DB_MAX_OPEN_FILES,
     "MaxNoOfOpenFiles",
     DB_TOKEN,

=== modified file 'storage/ndb/test/ndbapi/Makefile.am'
--- a/storage/ndb/test/ndbapi/Makefile.am	2008-10-30 15:15:48 +0000
+++ b/storage/ndb/test/ndbapi/Makefile.am	2008-11-19 09:52:01 +0000
@@ -59,7 +59,8 @@ ndbapi_50compat1 \
 testNDBT \
 testReconnect \
 NdbRepStress \
-msa
+msa \
+testMgmDisconnect
 
 EXTRA_PROGRAMS = \
  test_event \

=== added file 'storage/ndb/test/ndbapi/testMgmDisconnect.c'
--- a/storage/ndb/test/ndbapi/testMgmDisconnect.c	1970-01-01 00:00:00 +0000
+++ b/storage/ndb/test/ndbapi/testMgmDisconnect.c	2008-11-19 09:52:01 +0000
@@ -0,0 +1,63 @@
+/* Copyright (C) 2008 Sun Microsystems Inc.
+
+   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; 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
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
+
+
+#include <stdlib.h>
+#include <unistd.h>
+
+#include <mgmapi.h>
+
+int main()
+{
+  NdbMgmHandle handle= ndb_mgm_create_handle();
+
+  while(1==1){
+    if (ndb_mgm_connect(handle,0,0,0) == -1){
+      printf("connect failed, error: '%d: %s'\n",
+             ndb_mgm_get_latest_error(handle),
+             ndb_mgm_get_latest_error_desc(handle));
+      sleep(1);
+      continue;
+    }
+
+    while(ndb_mgm_is_connected(handle) != 0){
+      struct ndb_mgm_cluster_state *state= ndb_mgm_get_status(handle);
+
+      if(state==NULL){
+        printf("ndb_mgm_get_status failed, error: '%d: %s', line: %d\n",
+               ndb_mgm_get_latest_error(handle),
+               ndb_mgm_get_latest_error_desc(handle),
+               ndb_mgm_get_latest_error_line(handle));
+        continue;
+      }
+
+      int i= 0;
+      for(i=0; i < state->no_of_nodes; i++)
+      {
+        struct ndb_mgm_node_state *node_state= &state->node_states[i];
+        printf("node with ID=%d ", node_state->node_id);
+
+        if(node_state->version != 0)
+          printf("connected\n");
+        else
+          printf("not connected\n");
+      }
+      free((void*)state);
+    }
+  }
+
+  ndb_mgm_destroy_handle(&handle);
+  return 1;
+}

=== modified file 'storage/ndb/test/ndbapi/testReconnect.cpp'
--- a/storage/ndb/test/ndbapi/testReconnect.cpp	2008-10-30 15:15:48 +0000
+++ b/storage/ndb/test/ndbapi/testReconnect.cpp	2008-11-17 09:39:56 +0000
@@ -163,7 +163,7 @@ int runRestartCluster(NDBT_Context* ctx,
 }
 
 
-NDBT_TESTSUITE(testSQL);
+NDBT_TESTSUITE(testReconnect);
 TESTCASE("InsertAndRestart",
 	 "Run INSERTs while cluster restart"){
   INITIALIZER(runDropTable);
@@ -195,10 +195,10 @@ TESTCASE("AllAndRestart",
   STEP(runRestartCluster);
 }
 
-NDBT_TESTSUITE_END(testSQL);
+NDBT_TESTSUITE_END(testReconnect);
 
 int main(int argc, const char** argv){
   ndb_init();
-  return testSQL.execute(argc, argv);
+  return testReconnect.execute(argc, argv);
 }
 

Thread
bzr commit into mysql-5.1 branch (DonKehndon.kehn:2755) DonKehndon.kehn19 Nov