Bug #28899 not possible to set separate watchdog timeout at startup

parent 8a9bf139
...@@ -81,6 +81,8 @@ ...@@ -81,6 +81,8 @@
#define CFG_DB_BACKUP_WRITE_SIZE 136 #define CFG_DB_BACKUP_WRITE_SIZE 136
#define CFG_DB_BACKUP_MAX_WRITE_SIZE 139 #define CFG_DB_BACKUP_MAX_WRITE_SIZE 139
#define CFG_DB_WATCHDOG_INTERVAL_INITIAL 141
#define CFG_LOG_DESTINATION 147 #define CFG_LOG_DESTINATION 147
#define CFG_DB_DISCLESS 148 #define CFG_DB_DISCLESS 148
......
...@@ -37,9 +37,6 @@ NDB_TICKS NdbTick_CurrentMillisecond(void); ...@@ -37,9 +37,6 @@ NDB_TICKS NdbTick_CurrentMillisecond(void);
*/ */
int NdbTick_CurrentMicrosecond(NDB_TICKS * secs, Uint32 * micros); int NdbTick_CurrentMicrosecond(NDB_TICKS * secs, Uint32 * micros);
/*#define TIME_MEASUREMENT*/
#ifdef TIME_MEASUREMENT
struct MicroSecondTimer { struct MicroSecondTimer {
NDB_TICKS seconds; NDB_TICKS seconds;
NDB_TICKS micro_seconds; NDB_TICKS micro_seconds;
...@@ -54,7 +51,6 @@ struct MicroSecondTimer { ...@@ -54,7 +51,6 @@ struct MicroSecondTimer {
NDB_TICKS NdbTick_getMicrosPassed(struct MicroSecondTimer start, NDB_TICKS NdbTick_getMicrosPassed(struct MicroSecondTimer start,
struct MicroSecondTimer stop); struct MicroSecondTimer stop);
int NdbTick_getMicroTimer(struct MicroSecondTimer* time_now); int NdbTick_getMicroTimer(struct MicroSecondTimer* time_now);
#endif
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#include <ndb_global.h> #include <ndb_global.h>
#include "NdbTick.h" #include <NdbTick.h>
#define NANOSEC_PER_SEC 1000000000 #define NANOSEC_PER_SEC 1000000000
#define MICROSEC_PER_SEC 1000000 #define MICROSEC_PER_SEC 1000000
...@@ -71,7 +71,6 @@ NdbTick_CurrentMicrosecond(NDB_TICKS * secs, Uint32 * micros){ ...@@ -71,7 +71,6 @@ NdbTick_CurrentMicrosecond(NDB_TICKS * secs, Uint32 * micros){
} }
#endif #endif
#ifdef TIME_MEASUREMENT
int int
NdbTick_getMicroTimer(struct MicroSecondTimer* input_timer) NdbTick_getMicroTimer(struct MicroSecondTimer* input_timer)
{ {
...@@ -102,4 +101,3 @@ NdbTick_getMicrosPassed(struct MicroSecondTimer start, ...@@ -102,4 +101,3 @@ NdbTick_getMicrosPassed(struct MicroSecondTimer start,
} }
return ret_value; return ret_value;
} }
#endif
...@@ -277,6 +277,14 @@ void Ndbcntr::execSTTOR(Signal* signal) ...@@ -277,6 +277,14 @@ void Ndbcntr::execSTTOR(Signal* signal)
break; break;
case ZSTART_PHASE_1: case ZSTART_PHASE_1:
jam(); jam();
{
Uint32 db_watchdog_interval = 0;
const ndb_mgm_configuration_iterator * p =
m_ctx.m_config.getOwnConfigIterator();
ndb_mgm_get_int_parameter(p, CFG_DB_WATCHDOG_INTERVAL, &db_watchdog_interval);
ndbrequire(db_watchdog_interval);
update_watch_dog_timer(db_watchdog_interval);
}
startPhase1Lab(signal); startPhase1Lab(signal);
break; break;
case ZSTART_PHASE_2: case ZSTART_PHASE_2:
......
...@@ -443,6 +443,11 @@ Configuration::setupConfiguration(){ ...@@ -443,6 +443,11 @@ Configuration::setupConfiguration(){
"TimeBetweenWatchDogCheck missing"); "TimeBetweenWatchDogCheck missing");
} }
if(iter.get(CFG_DB_WATCHDOG_INTERVAL_INITIAL, &_timeBetweenWatchDogCheckInitial)){
ERROR_SET(fatal, NDBD_EXIT_INVALID_CONFIG, "Invalid configuration fetched",
"TimeBetweenWatchDogCheckInitial missing");
}
/** /**
* Get paths * Get paths
*/ */
...@@ -462,9 +467,12 @@ Configuration::setupConfiguration(){ ...@@ -462,9 +467,12 @@ Configuration::setupConfiguration(){
* Create the watch dog thread * Create the watch dog thread
*/ */
{ {
Uint32 t = _timeBetweenWatchDogCheck; if (_timeBetweenWatchDogCheckInitial < _timeBetweenWatchDogCheck)
_timeBetweenWatchDogCheckInitial = _timeBetweenWatchDogCheck;
Uint32 t = _timeBetweenWatchDogCheckInitial;
t = globalEmulatorData.theWatchDog ->setCheckInterval(t); t = globalEmulatorData.theWatchDog ->setCheckInterval(t);
_timeBetweenWatchDogCheck = t; _timeBetweenWatchDogCheckInitial = t;
} }
ConfigValues* cf = ConfigValuesFactory::extractCurrentSection(iter.m_config); ConfigValues* cf = ConfigValuesFactory::extractCurrentSection(iter.m_config);
......
...@@ -84,6 +84,7 @@ private: ...@@ -84,6 +84,7 @@ private:
Uint32 _maxErrorLogs; Uint32 _maxErrorLogs;
Uint32 _lockPagesInMainMemory; Uint32 _lockPagesInMainMemory;
Uint32 _timeBetweenWatchDogCheck; Uint32 _timeBetweenWatchDogCheck;
Uint32 _timeBetweenWatchDogCheckInitial;
ndb_mgm_configuration * m_ownConfig; ndb_mgm_configuration * m_ownConfig;
ndb_mgm_configuration * m_clusterConfig; ndb_mgm_configuration * m_clusterConfig;
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include <NdbOut.hpp> #include <NdbOut.hpp>
#include <GlobalData.hpp> #include <GlobalData.hpp>
#include <Emulator.hpp> #include <Emulator.hpp>
#include <WatchDog.hpp>
#include <ErrorHandlingMacros.hpp> #include <ErrorHandlingMacros.hpp>
#include <TimeQueue.hpp> #include <TimeQueue.hpp>
#include <TransporterRegistry.hpp> #include <TransporterRegistry.hpp>
...@@ -662,7 +663,7 @@ SimulatedBlock::allocRecord(const char * type, size_t s, size_t n, bool clear, U ...@@ -662,7 +663,7 @@ SimulatedBlock::allocRecord(const char * type, size_t s, size_t n, bool clear, U
void * p = NULL; void * p = NULL;
size_t size = n*s; size_t size = n*s;
Uint64 real_size = (Uint64)((Uint64)n)*((Uint64)s); Uint64 real_size = (Uint64)((Uint64)n)*((Uint64)s);
refresh_watch_dog(); refresh_watch_dog(9);
if (real_size > 0){ if (real_size > 0){
#ifdef VM_TRACE_MEM #ifdef VM_TRACE_MEM
ndbout_c("%s::allocRecord(%s, %u, %u) = %llu bytes", ndbout_c("%s::allocRecord(%s, %u, %u) = %llu bytes",
...@@ -696,12 +697,12 @@ SimulatedBlock::allocRecord(const char * type, size_t s, size_t n, bool clear, U ...@@ -696,12 +697,12 @@ SimulatedBlock::allocRecord(const char * type, size_t s, size_t n, bool clear, U
char * ptr = (char*)p; char * ptr = (char*)p;
const Uint32 chunk = 128 * 1024; const Uint32 chunk = 128 * 1024;
while(size > chunk){ while(size > chunk){
refresh_watch_dog(); refresh_watch_dog(9);
memset(ptr, 0, chunk); memset(ptr, 0, chunk);
ptr += chunk; ptr += chunk;
size -= chunk; size -= chunk;
} }
refresh_watch_dog(); refresh_watch_dog(9);
memset(ptr, 0, size); memset(ptr, 0, size);
} }
} }
...@@ -720,9 +721,16 @@ SimulatedBlock::deallocRecord(void ** ptr, ...@@ -720,9 +721,16 @@ SimulatedBlock::deallocRecord(void ** ptr,
} }
void void
SimulatedBlock::refresh_watch_dog() SimulatedBlock::refresh_watch_dog(Uint32 place)
{ {
globalData.incrementWatchDogCounter(1); globalData.incrementWatchDogCounter(place);
}
void
SimulatedBlock::update_watch_dog_timer(Uint32 interval)
{
extern EmulatorData globalEmulatorData;
globalEmulatorData.theWatchDog->setCheckInterval(interval);
} }
void void
......
...@@ -334,7 +334,8 @@ protected: ...@@ -334,7 +334,8 @@ protected:
* Refresh Watch Dog in initialising code * Refresh Watch Dog in initialising code
* *
*/ */
void refresh_watch_dog(); void refresh_watch_dog(Uint32 place = 1);
void update_watch_dog_timer(Uint32 interval);
/** /**
* Prog error * Prog error
......
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
#include <ErrorHandlingMacros.hpp> #include <ErrorHandlingMacros.hpp>
#include <EventLogger.hpp> #include <EventLogger.hpp>
#include <NdbTick.h>
extern EventLogger g_eventLogger; extern EventLogger g_eventLogger;
extern "C" extern "C"
...@@ -72,73 +74,115 @@ WatchDog::doStop(){ ...@@ -72,73 +74,115 @@ WatchDog::doStop(){
} }
} }
const char *get_action(Uint32 IPValue)
{
const char *action;
switch (IPValue) {
case 1:
action = "Job Handling";
break;
case 2:
action = "Scanning Timers";
break;
case 3:
action = "External I/O";
break;
case 4:
action = "Print Job Buffers at crash";
break;
case 5:
action = "Checking connections";
break;
case 6:
action = "Performing Send";
break;
case 7:
action = "Polling for Receive";
break;
case 8:
action = "Performing Receive";
break;
case 9:
action = "Allocating memory";
break;
default:
action = "Unknown place";
break;
}//switch
return action;
}
void void
WatchDog::run(){ WatchDog::run()
unsigned int anIPValue; {
unsigned int alerts = 0; unsigned int anIPValue, sleep_time;
unsigned int oldIPValue = 0; unsigned int oldIPValue = 0;
unsigned int theIntervalCheck = theInterval;
struct MicroSecondTimer start_time, last_time, now;
NdbTick_getMicroTimer(&start_time);
last_time = start_time;
// WatchDog for the single threaded NDB // WatchDog for the single threaded NDB
while(!theStop){ while (!theStop)
Uint32 tmp = theInterval / 500; {
tmp= (tmp ? tmp : 1); sleep_time= 100;
while(!theStop && tmp > 0){ NdbSleep_MilliSleep(sleep_time);
NdbSleep_MilliSleep(500);
tmp--;
}
if(theStop) if(theStop)
break; break;
NdbTick_getMicroTimer(&now);
if (NdbTick_getMicrosPassed(last_time, now)/1000 > sleep_time*2)
{
struct tms my_tms;
times(&my_tms);
g_eventLogger.info("Watchdog: User time: %llu System time: %llu",
(Uint64)my_tms.tms_utime,
(Uint64)my_tms.tms_stime);
g_eventLogger.warning("Watchdog: Warning overslept %u ms, expected %u ms.",
NdbTick_getMicrosPassed(last_time, now)/1000,
sleep_time);
}
last_time = now;
// Verify that the IP thread is not stuck in a loop // Verify that the IP thread is not stuck in a loop
anIPValue = *theIPValue; anIPValue = *theIPValue;
if(anIPValue != 0) { if (anIPValue != 0)
{
oldIPValue = anIPValue; oldIPValue = anIPValue;
globalData.incrementWatchDogCounter(0); globalData.incrementWatchDogCounter(0);
alerts = 0; NdbTick_getMicroTimer(&start_time);
} else { theIntervalCheck = theInterval;
const char *last_stuck_action; }
alerts++; else
switch (oldIPValue) { {
case 1: int warn = 1;
last_stuck_action = "Job Handling"; Uint32 elapsed = NdbTick_getMicrosPassed(start_time, now)/1000;
break; /*
case 2: oldIPValue == 9 indicates malloc going on, this can take some time
last_stuck_action = "Scanning Timers"; so only warn if we pass the watchdog interval
break; */
case 3: if (oldIPValue == 9)
last_stuck_action = "External I/O"; if (elapsed < theIntervalCheck)
break; warn = 0;
case 4: else
last_stuck_action = "Print Job Buffers at crash"; theIntervalCheck += theInterval;
break;
case 5: if (warn)
last_stuck_action = "Checking connections";
break;
case 6:
last_stuck_action = "Performing Send";
break;
case 7:
last_stuck_action = "Polling for Receive";
break;
case 8:
last_stuck_action = "Performing Receive";
break;
default:
last_stuck_action = "Unknown place";
break;
}//switch
g_eventLogger.warning("Ndb kernel is stuck in: %s", last_stuck_action);
{ {
struct tms my_tms; const char *last_stuck_action = get_action(oldIPValue);
times(&my_tms); g_eventLogger.warning("Ndb kernel is stuck in: %s", last_stuck_action);
g_eventLogger.info("User time: %llu System time: %llu", {
(Uint64)my_tms.tms_utime, struct tms my_tms;
(Uint64)my_tms.tms_stime); times(&my_tms);
} g_eventLogger.info("Watchdog: User time: %llu System time: %llu",
if(alerts == 3){ (Uint64)my_tms.tms_utime,
shutdownSystem(last_stuck_action); (Uint64)my_tms.tms_stime);
}
if (elapsed > 3 * theInterval)
{
shutdownSystem(last_stuck_action);
}
} }
} }
} }
......
...@@ -571,6 +571,18 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ...@@ -571,6 +571,18 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = {
"70", "70",
STR_VALUE(MAX_INT_RNIL) }, STR_VALUE(MAX_INT_RNIL) },
{
CFG_DB_WATCHDOG_INTERVAL_INITIAL,
"TimeBetweenWatchDogCheckInitial",
DB_TOKEN,
"Time between execution checks inside a database node in the early start phases when memory is allocated",
ConfigInfo::CI_USED,
true,
ConfigInfo::CI_INT,
"6000",
"70",
STR_VALUE(MAX_INT_RNIL) },
{ {
CFG_DB_STOP_ON_ERROR, CFG_DB_STOP_ON_ERROR,
"StopOnError", "StopOnError",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment