diff --git a/src/common/inc/tglobal.h b/src/common/inc/tglobal.h index 49ca1e31c5f4fc21beeed169b431f21e8985a642..cde5eab48783351d4bd8c00be9008d52b5bf6561 100644 --- a/src/common/inc/tglobal.h +++ b/src/common/inc/tglobal.h @@ -42,6 +42,7 @@ extern int8_t tsArbOnline; extern int64_t tsArbOnlineTimestamp; extern int32_t tsDnodeId; extern int64_t tsDnodeStartTime; +extern int8_t tsDnodeNopLoop; // common extern int tsRpcTimer; diff --git a/src/common/src/tglobal.c b/src/common/src/tglobal.c index b4bc38d53e517da33a7e71fe6b6b189c3d64d613..8627a3153cdac2b06cd3cf15dddefad32c39c58d 100644 --- a/src/common/src/tglobal.c +++ b/src/common/src/tglobal.c @@ -47,6 +47,7 @@ int64_t tsArbOnlineTimestamp = TSDB_ARB_DUMMY_TIME; char tsEmail[TSDB_FQDN_LEN] = {0}; int32_t tsDnodeId = 0; int64_t tsDnodeStartTime = 0; +int8_t tsDnodeNopLoop = 0; // common int32_t tsRpcTimer = 300; @@ -622,6 +623,16 @@ static void doInitGlobalConfig(void) { cfg.unitType = TAOS_CFG_UTYPE_NONE; taosInitConfigOption(cfg); + cfg.option = "dnodeNopLoop"; + cfg.ptr = &tsDnodeNopLoop; + cfg.valType = TAOS_CFG_VTYPE_INT8; + cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG; + cfg.minValue = 0; + cfg.maxValue = 1; + cfg.ptrLength = 0; + cfg.unitType = TAOS_CFG_UTYPE_NONE; + taosInitConfigOption(cfg); + cfg.option = "balance"; cfg.ptr = &tsEnableBalance; cfg.valType = TAOS_CFG_VTYPE_INT8; diff --git a/src/dnode/src/dnodeSystem.c b/src/dnode/src/dnodeSystem.c index e4d1d102e0319706c723f2659b843791654b96a7..d41a2c6a8ae442f09b20c1dc55d06d5d5273cd88 100644 --- a/src/dnode/src/dnodeSystem.c +++ b/src/dnode/src/dnodeSystem.c @@ -19,6 +19,7 @@ #include "tconfig.h" #include "dnodeMain.h" +bool dnodeExit = false; static tsem_t exitSem; static void siguser1Handler(int32_t signum, void *sigInfo, void *context); static void siguser2Handler(int32_t signum, void *sigInfo, void *context); @@ -182,6 +183,8 @@ static void sigintHandler(int32_t signum, void *sigInfo, void *context) { syslog(LOG_INFO, "Shut down signal is %d", signum); syslog(LOG_INFO, "Shutting down TDengine service..."); + dnodeExit = true; + // inform main thread to exit tsem_post(&exitSem); #ifdef WINDOWS diff --git a/src/dnode/src/dnodeVnodes.c b/src/dnode/src/dnodeVnodes.c index 93d218581cfb7d1738fa5ba3f3afd8c8f0d70dd7..981c150f1c8a523ae78749560545dd985af73eac 100644 --- a/src/dnode/src/dnodeVnodes.c +++ b/src/dnode/src/dnodeVnodes.c @@ -30,6 +30,7 @@ typedef struct { int32_t * vnodeList; } SOpenVnodeThread; +extern bool dnodeExit; extern void * tsDnodeTmr; static void * tsStatusTimer = NULL; static uint32_t tsRebootTime = 0; @@ -222,6 +223,22 @@ static void dnodeProcessStatusRsp(SRpcMsg *pMsg) { if (clusterId[0] != '\0') { dnodeSetDropped(); dError("exit zombie dropped dnode"); + + // warning: only for k8s! + while (tsDnodeNopLoop) { + if (dnodeExit) { + dInfo("Break loop"); + return; + } + + dInfo("Nop loop"); +#ifdef WINDOWS + Sleep(100); +#else + usleep(100000); +#endif + } + exit(EXIT_FAILURE); } }