Loading ndb/include/util/ndb_opts.h +11 −1 Original line number Diff line number Diff line Loading @@ -30,8 +30,14 @@ my_bool opt_ndb_optimized_node_selection bool opt_endinfo= 0; my_bool opt_ndb_shm; my_bool opt_core; #define OPT_NDB_CONNECTSTRING 'c' #if defined VM_TRACE && ( ! ( defined NDB_OSE || defined NDB_SOFTOSE) ) #define OPT_WANT_CORE_DEFAULT 1 #else #define OPT_WANT_CORE_DEFAULT 0 #endif #define NDB_STD_OPTS_COMMON \ { "usage", '?', "Display this help and exit.", \ Loading @@ -57,7 +63,10 @@ my_bool opt_ndb_shm; GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0},\ { "connect-string", OPT_NDB_CONNECTSTRING, "same as --ndb-connectstring",\ (gptr*) &opt_connect_str, (gptr*) &opt_connect_str, 0,\ GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 } GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },\ { "core-file", OPT_WANT_CORE, "Write core on errors.",\ (gptr*) &opt_core, (gptr*) &opt_core, 0,\ GET_BOOL, NO_ARG, OPT_WANT_CORE_DEFAULT, 0, 0, 0, 0, 0} #ifndef DBUG_OFF #define NDB_STD_OPTS(prog_name) \ Loading @@ -80,6 +89,7 @@ enum ndb_std_options { OPT_NDB_SHM= 256, OPT_NDB_SHM_SIGNUM, OPT_NDB_OPTIMIZED_NODE_SELECTION, OPT_WANT_CORE, NDB_STD_OPTIONS_LAST /* should always be last in this enum */ }; Loading ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp +8 −0 Original line number Diff line number Diff line Loading @@ -2493,6 +2493,14 @@ void Ndbcntr::Missra::sendNextSTTOR(Signal* signal){ const Uint32 start = currentBlockIndex; if (currentStartPhase == ZSTART_PHASE_6) { // Ndbd has passed the critical startphases. // Change error handler from "startup" state // to normal state. ErrorReporter::setErrorHandlerShutdownType(); } for(; currentBlockIndex < ALL_BLOCKS_SZ; currentBlockIndex++){ jam(); if(ALL_BLOCKS[currentBlockIndex].NextSP == currentStartPhase){ Loading ndb/src/kernel/error/ErrorReporter.cpp +12 −2 Original line number Diff line number Diff line Loading @@ -152,6 +152,14 @@ ErrorReporter::formatMessage(ErrorCategory type, return; } NdbShutdownType ErrorReporter::s_errorHandlerShutdownType = NST_ErrorHandler; void ErrorReporter::setErrorHandlerShutdownType(NdbShutdownType nst) { s_errorHandlerShutdownType = nst; } void ErrorReporter::handleAssert(const char* message, const char* file, int line) { Loading @@ -170,7 +178,7 @@ ErrorReporter::handleAssert(const char* message, const char* file, int line) WriteMessage(assert, ERR_ERROR_PRGERR, message, refMessage, theEmulatedJamIndex, theEmulatedJam); NdbShutdown(NST_ErrorHandler); NdbShutdown(s_errorHandlerShutdownType); } void Loading @@ -182,7 +190,7 @@ ErrorReporter::handleThreadAssert(const char* message, BaseString::snprintf(refMessage, 100, "file: %s lineNo: %d - %s", file, line, message); NdbShutdown(NST_ErrorHandler); NdbShutdown(s_errorHandlerShutdownType); }//ErrorReporter::handleThreadAssert() Loading @@ -201,6 +209,8 @@ ErrorReporter::handleError(ErrorCategory type, int messageID, if(messageID == ERR_ERROR_INSERT){ NdbShutdown(NST_ErrorInsert); } else { if (nst == NST_ErrorHandler) nst = s_errorHandlerShutdownType; NdbShutdown(nst); } } Loading ndb/src/kernel/error/ErrorReporter.hpp +2 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ class ErrorReporter { public: static void setErrorHandlerShutdownType(NdbShutdownType nst = NST_ErrorHandler); static void handleAssert(const char* message, const char* file, int line); Loading Loading @@ -57,6 +58,7 @@ public: static const char* formatTimeStampString(); private: static enum NdbShutdownType s_errorHandlerShutdownType; }; #endif ndb/src/kernel/main.cpp +37 −0 Original line number Diff line number Diff line Loading @@ -45,8 +45,14 @@ extern NdbMutex * theShutdownMutex; void catchsigs(bool ignore); // for process signal handling #define MAX_FAILED_STARTUPS 3 // Flag set by child through SIGUSR1 to signal a failed startup static bool failed_startup_flag = false; // Counter for consecutive failed startups static Uint32 failed_startups = 0; extern "C" void handler_shutdown(int signum); // for process signal handling extern "C" void handler_error(int signum); // for process signal handling extern "C" void handler_sigusr1(int signum); // child signalling failed restart // Shows system information void systemInfo(const Configuration & conf, Loading Loading @@ -92,6 +98,8 @@ int main(int argc, char** argv) } #ifndef NDB_WIN32 signal(SIGUSR1, handler_sigusr1); for(pid_t child = fork(); child != 0; child = fork()){ /** * Parent Loading Loading @@ -137,6 +145,20 @@ int main(int argc, char** argv) */ exit(0); } if (!failed_startup_flag) { // Reset the counter for consecutive failed startups failed_startups = 0; } else if (failed_startups >= MAX_FAILED_STARTUPS && !theConfig->stopOnError()) { /** * Error shutdown && stopOnError() */ g_eventLogger.alert("Ndbd has failed %u consecutive startups. Not restarting", failed_startups); exit(0); } failed_startup_flag = false; g_eventLogger.info("Ndb has terminated (pid %d) restarting", child); theConfig->fetch_configuration(); } Loading Loading @@ -170,6 +192,9 @@ int main(int argc, char** argv) /** * Do startup */ ErrorReporter::setErrorHandlerShutdownType(NST_ErrorHandlerStartup); switch(globalData.theRestartFlag){ case initial_state: globalEmulatorData.theThreadConfig->doStart(NodeState::SL_CMVMI); Loading Loading @@ -359,3 +384,15 @@ handler_error(int signum){ BaseString::snprintf(errorData, 40, "Signal %d received", signum); ERROR_SET_SIGNAL(fatal, 0, errorData, __FILE__); } extern "C" void handler_sigusr1(int signum) { if (!failed_startup_flag) { failed_startups++; failed_startup_flag = true; } g_eventLogger.info("Received signal %d. Ndbd failed startup (%u).", signum, failed_startups); } Loading
ndb/include/util/ndb_opts.h +11 −1 Original line number Diff line number Diff line Loading @@ -30,8 +30,14 @@ my_bool opt_ndb_optimized_node_selection bool opt_endinfo= 0; my_bool opt_ndb_shm; my_bool opt_core; #define OPT_NDB_CONNECTSTRING 'c' #if defined VM_TRACE && ( ! ( defined NDB_OSE || defined NDB_SOFTOSE) ) #define OPT_WANT_CORE_DEFAULT 1 #else #define OPT_WANT_CORE_DEFAULT 0 #endif #define NDB_STD_OPTS_COMMON \ { "usage", '?', "Display this help and exit.", \ Loading @@ -57,7 +63,10 @@ my_bool opt_ndb_shm; GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0},\ { "connect-string", OPT_NDB_CONNECTSTRING, "same as --ndb-connectstring",\ (gptr*) &opt_connect_str, (gptr*) &opt_connect_str, 0,\ GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 } GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },\ { "core-file", OPT_WANT_CORE, "Write core on errors.",\ (gptr*) &opt_core, (gptr*) &opt_core, 0,\ GET_BOOL, NO_ARG, OPT_WANT_CORE_DEFAULT, 0, 0, 0, 0, 0} #ifndef DBUG_OFF #define NDB_STD_OPTS(prog_name) \ Loading @@ -80,6 +89,7 @@ enum ndb_std_options { OPT_NDB_SHM= 256, OPT_NDB_SHM_SIGNUM, OPT_NDB_OPTIMIZED_NODE_SELECTION, OPT_WANT_CORE, NDB_STD_OPTIONS_LAST /* should always be last in this enum */ }; Loading
ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp +8 −0 Original line number Diff line number Diff line Loading @@ -2493,6 +2493,14 @@ void Ndbcntr::Missra::sendNextSTTOR(Signal* signal){ const Uint32 start = currentBlockIndex; if (currentStartPhase == ZSTART_PHASE_6) { // Ndbd has passed the critical startphases. // Change error handler from "startup" state // to normal state. ErrorReporter::setErrorHandlerShutdownType(); } for(; currentBlockIndex < ALL_BLOCKS_SZ; currentBlockIndex++){ jam(); if(ALL_BLOCKS[currentBlockIndex].NextSP == currentStartPhase){ Loading
ndb/src/kernel/error/ErrorReporter.cpp +12 −2 Original line number Diff line number Diff line Loading @@ -152,6 +152,14 @@ ErrorReporter::formatMessage(ErrorCategory type, return; } NdbShutdownType ErrorReporter::s_errorHandlerShutdownType = NST_ErrorHandler; void ErrorReporter::setErrorHandlerShutdownType(NdbShutdownType nst) { s_errorHandlerShutdownType = nst; } void ErrorReporter::handleAssert(const char* message, const char* file, int line) { Loading @@ -170,7 +178,7 @@ ErrorReporter::handleAssert(const char* message, const char* file, int line) WriteMessage(assert, ERR_ERROR_PRGERR, message, refMessage, theEmulatedJamIndex, theEmulatedJam); NdbShutdown(NST_ErrorHandler); NdbShutdown(s_errorHandlerShutdownType); } void Loading @@ -182,7 +190,7 @@ ErrorReporter::handleThreadAssert(const char* message, BaseString::snprintf(refMessage, 100, "file: %s lineNo: %d - %s", file, line, message); NdbShutdown(NST_ErrorHandler); NdbShutdown(s_errorHandlerShutdownType); }//ErrorReporter::handleThreadAssert() Loading @@ -201,6 +209,8 @@ ErrorReporter::handleError(ErrorCategory type, int messageID, if(messageID == ERR_ERROR_INSERT){ NdbShutdown(NST_ErrorInsert); } else { if (nst == NST_ErrorHandler) nst = s_errorHandlerShutdownType; NdbShutdown(nst); } } Loading
ndb/src/kernel/error/ErrorReporter.hpp +2 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ class ErrorReporter { public: static void setErrorHandlerShutdownType(NdbShutdownType nst = NST_ErrorHandler); static void handleAssert(const char* message, const char* file, int line); Loading Loading @@ -57,6 +58,7 @@ public: static const char* formatTimeStampString(); private: static enum NdbShutdownType s_errorHandlerShutdownType; }; #endif
ndb/src/kernel/main.cpp +37 −0 Original line number Diff line number Diff line Loading @@ -45,8 +45,14 @@ extern NdbMutex * theShutdownMutex; void catchsigs(bool ignore); // for process signal handling #define MAX_FAILED_STARTUPS 3 // Flag set by child through SIGUSR1 to signal a failed startup static bool failed_startup_flag = false; // Counter for consecutive failed startups static Uint32 failed_startups = 0; extern "C" void handler_shutdown(int signum); // for process signal handling extern "C" void handler_error(int signum); // for process signal handling extern "C" void handler_sigusr1(int signum); // child signalling failed restart // Shows system information void systemInfo(const Configuration & conf, Loading Loading @@ -92,6 +98,8 @@ int main(int argc, char** argv) } #ifndef NDB_WIN32 signal(SIGUSR1, handler_sigusr1); for(pid_t child = fork(); child != 0; child = fork()){ /** * Parent Loading Loading @@ -137,6 +145,20 @@ int main(int argc, char** argv) */ exit(0); } if (!failed_startup_flag) { // Reset the counter for consecutive failed startups failed_startups = 0; } else if (failed_startups >= MAX_FAILED_STARTUPS && !theConfig->stopOnError()) { /** * Error shutdown && stopOnError() */ g_eventLogger.alert("Ndbd has failed %u consecutive startups. Not restarting", failed_startups); exit(0); } failed_startup_flag = false; g_eventLogger.info("Ndb has terminated (pid %d) restarting", child); theConfig->fetch_configuration(); } Loading Loading @@ -170,6 +192,9 @@ int main(int argc, char** argv) /** * Do startup */ ErrorReporter::setErrorHandlerShutdownType(NST_ErrorHandlerStartup); switch(globalData.theRestartFlag){ case initial_state: globalEmulatorData.theThreadConfig->doStart(NodeState::SL_CMVMI); Loading Loading @@ -359,3 +384,15 @@ handler_error(int signum){ BaseString::snprintf(errorData, 40, "Signal %d received", signum); ERROR_SET_SIGNAL(fatal, 0, errorData, __FILE__); } extern "C" void handler_sigusr1(int signum) { if (!failed_startup_flag) { failed_startups++; failed_startup_flag = true; } g_eventLogger.info("Received signal %d. Ndbd failed startup (%u).", signum, failed_startups); }