From b859e6bde247dc2cc617a1314f3aa416477b75a5 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Mon, 25 Jul 2022 15:27:47 +0800 Subject: [PATCH 1/3] fix: the modification of alter dnode does not take effect through show dnode variables --- include/common/tglobal.h | 3 +- include/util/tlog.h | 1 + source/common/src/tglobal.c | 5 +++ source/dnode/mnode/impl/src/mndDnode.c | 2 +- source/util/src/tlog.c | 42 ++++++++++++++++---------- 5 files changed, 35 insertions(+), 18 deletions(-) diff --git a/include/common/tglobal.h b/include/common/tglobal.h index 23d9c41a51..9633b3e8aa 100644 --- a/include/common/tglobal.h +++ b/include/common/tglobal.h @@ -152,7 +152,8 @@ void taosCfgDynamicOptions(const char *option, const char *value); void taosAddDataDir(int32_t index, char *v1, int32_t level, int32_t primary); struct SConfig *taosGetCfg(); -int32_t taosSetCfg(SConfig *pCfg, char* name); + +int32_t taosSetCfg(SConfig *pCfg, char *name); #ifdef __cplusplus } diff --git a/include/util/tlog.h b/include/util/tlog.h index d186c32841..04ffe21e0b 100644 --- a/include/util/tlog.h +++ b/include/util/tlog.h @@ -68,6 +68,7 @@ int32_t taosInitLog(const char *logName, int32_t maxFiles); void taosCloseLog(); void taosResetLog(); void taosSetAllDebugFlag(int32_t flag); +void taosSetDebugFlag(int32_t *pFlagPtr, const char *flagName, int32_t flagVal); void taosDumpData(uint8_t *msg, int32_t len); void taosPrintLog(const char *flags, ELogLevel level, int32_t dflag, const char *format, ...) diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c index 36900e3dfa..5cb5148e30 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -1143,6 +1143,10 @@ void taosCfgDynamicOptions(const char *option, const char *value) { int32_t monitor = atoi(value); uInfo("monitor set from %d to %d", tsEnableMonitor, monitor); tsEnableMonitor = monitor; + SConfigItem *pItem = cfgGetItem(tsCfg, "monitor"); + if (pItem != NULL) { + pItem->bval = tsEnableMonitor; + } return; } @@ -1166,6 +1170,7 @@ void taosCfgDynamicOptions(const char *option, const char *value) { int32_t flag = atoi(value); uInfo("%s set from %d to %d", optName, *optionVars[d], flag); *optionVars[d] = flag; + taosSetDebugFlag(optionVars[d], optName, flag); return; } diff --git a/source/dnode/mnode/impl/src/mndDnode.c b/source/dnode/mnode/impl/src/mndDnode.c index f26c1a7d32..7141a62be5 100644 --- a/source/dnode/mnode/impl/src/mndDnode.c +++ b/source/dnode/mnode/impl/src/mndDnode.c @@ -874,7 +874,7 @@ static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) { } static int32_t mndProcessConfigDnodeRsp(SRpcMsg *pRsp) { - mInfo("config rsp from dnode, app:%p", pRsp->info.ahandle); + mInfo("config rsp from dnode"); return 0; } diff --git a/source/util/src/tlog.c b/source/util/src/tlog.c index 490c6f29bf..678a12fcf1 100644 --- a/source/util/src/tlog.c +++ b/source/util/src/tlog.c @@ -17,6 +17,7 @@ #include "tlog.h" #include "os.h" #include "tutil.h" +#include "tconfig.h" #define LOG_MAX_LINE_SIZE (1024) #define LOG_MAX_LINE_BUFFER_SIZE (LOG_MAX_LINE_SIZE + 3) @@ -62,6 +63,7 @@ typedef struct { TdThreadMutex logMutex; } SLogObj; +extern SConfig *tsCfg; static int8_t tsLogInited = 0; static SLogObj tsLogObj = {.fileNum = 1}; static int64_t tsAsyncLogLostLines = 0; @@ -742,24 +744,32 @@ cmp_end: return ret; } +void taosSetDebugFlag(int32_t *pFlagPtr, const char *flagName, int32_t flagVal) { + SConfigItem *pItem = cfgGetItem(tsCfg, flagName); + if (pItem != NULL) { + pItem->i32 = flagVal; + } + *pFlagPtr = flagVal; +} + void taosSetAllDebugFlag(int32_t flag) { if (flag <= 0) return; - uDebugFlag = flag; - rpcDebugFlag = flag; - jniDebugFlag = flag; - qDebugFlag = flag; - cDebugFlag = flag; - dDebugFlag = flag; - vDebugFlag = flag; - mDebugFlag = flag; - wDebugFlag = flag; - sDebugFlag = flag; - tsdbDebugFlag = flag; - tqDebugFlag = flag; - fsDebugFlag = flag; - udfDebugFlag = flag; - smaDebugFlag = flag; - idxDebugFlag = flag; + taosSetDebugFlag(&uDebugFlag, "uDebugFlag", flag); + taosSetDebugFlag(&rpcDebugFlag, "rpcDebugFlag", flag); + taosSetDebugFlag(&jniDebugFlag, "jniDebugFlag", flag); + taosSetDebugFlag(&qDebugFlag, "qDebugFlag", flag); + taosSetDebugFlag(&cDebugFlag, "cDebugFlag", flag); + taosSetDebugFlag(&dDebugFlag, "dDebugFlag", flag); + taosSetDebugFlag(&vDebugFlag, "vDebugFlag", flag); + taosSetDebugFlag(&mDebugFlag, "mDebugFlag", flag); + taosSetDebugFlag(&wDebugFlag, "wDebugFlag", flag); + taosSetDebugFlag(&sDebugFlag, "sDebugFlag", flag); + taosSetDebugFlag(&tsdbDebugFlag, "tsdbDebugFlag", flag); + taosSetDebugFlag(&tqDebugFlag, "tqDebugFlag", flag); + taosSetDebugFlag(&fsDebugFlag, "fsDebugFlag", flag); + taosSetDebugFlag(&udfDebugFlag, "udfDebugFlag", flag); + taosSetDebugFlag(&smaDebugFlag, "smaDebugFlag", flag); + taosSetDebugFlag(&idxDebugFlag, "idxDebugFlag", flag); uInfo("all debug flag are set to %d", flag); } From e4c434d18680b7202f21a3ccf13e4ed39c00d460 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Mon, 25 Jul 2022 17:20:48 +0800 Subject: [PATCH 2/3] fix: crash while get cfg item --- source/util/src/tconfig.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/util/src/tconfig.c b/source/util/src/tconfig.c index 11ae31919a..ab7e30bab2 100644 --- a/source/util/src/tconfig.c +++ b/source/util/src/tconfig.c @@ -335,6 +335,7 @@ int32_t cfgSetItem(SConfig *pCfg, const char *name, const char *value, ECfgSrcTy } SConfigItem *cfgGetItem(SConfig *pCfg, const char *name) { + if (pCfg == NULL) return NULL; int32_t size = taosArrayGetSize(pCfg->array); for (int32_t i = 0; i < size; ++i) { SConfigItem *pItem = taosArrayGet(pCfg->array, i); From 49c42ef2894d161f92bdf2a7fc0ab164745d3888 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Mon, 25 Jul 2022 17:39:05 +0800 Subject: [PATCH 3/3] fix: compile error in unitest --- include/common/tglobal.h | 2 ++ include/util/tlog.h | 2 -- source/common/src/tglobal.c | 30 ++++++++++++++++++++++++++++++ source/util/src/tlog.c | 30 ------------------------------ 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/include/common/tglobal.h b/include/common/tglobal.h index 9633b3e8aa..ac998b807e 100644 --- a/include/common/tglobal.h +++ b/include/common/tglobal.h @@ -153,6 +153,8 @@ void taosAddDataDir(int32_t index, char *v1, int32_t level, int32_t primary); struct SConfig *taosGetCfg(); +void taosSetAllDebugFlag(int32_t flag); +void taosSetDebugFlag(int32_t *pFlagPtr, const char *flagName, int32_t flagVal); int32_t taosSetCfg(SConfig *pCfg, char *name); #ifdef __cplusplus diff --git a/include/util/tlog.h b/include/util/tlog.h index 04ffe21e0b..76d04a5997 100644 --- a/include/util/tlog.h +++ b/include/util/tlog.h @@ -67,8 +67,6 @@ extern int32_t idxDebugFlag; int32_t taosInitLog(const char *logName, int32_t maxFiles); void taosCloseLog(); void taosResetLog(); -void taosSetAllDebugFlag(int32_t flag); -void taosSetDebugFlag(int32_t *pFlagPtr, const char *flagName, int32_t flagVal); void taosDumpData(uint8_t *msg, int32_t len); void taosPrintLog(const char *flags, ELogLevel level, int32_t dflag, const char *format, ...) diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c index 5cb5148e30..7a20969a63 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -1176,3 +1176,33 @@ void taosCfgDynamicOptions(const char *option, const char *value) { uError("failed to cfg dynamic option:%s value:%s", option, value); } + +void taosSetDebugFlag(int32_t *pFlagPtr, const char *flagName, int32_t flagVal) { + SConfigItem *pItem = cfgGetItem(tsCfg, flagName); + if (pItem != NULL) { + pItem->i32 = flagVal; + } + *pFlagPtr = flagVal; +} + +void taosSetAllDebugFlag(int32_t flag) { + if (flag <= 0) return; + + taosSetDebugFlag(&uDebugFlag, "uDebugFlag", flag); + taosSetDebugFlag(&rpcDebugFlag, "rpcDebugFlag", flag); + taosSetDebugFlag(&jniDebugFlag, "jniDebugFlag", flag); + taosSetDebugFlag(&qDebugFlag, "qDebugFlag", flag); + taosSetDebugFlag(&cDebugFlag, "cDebugFlag", flag); + taosSetDebugFlag(&dDebugFlag, "dDebugFlag", flag); + taosSetDebugFlag(&vDebugFlag, "vDebugFlag", flag); + taosSetDebugFlag(&mDebugFlag, "mDebugFlag", flag); + taosSetDebugFlag(&wDebugFlag, "wDebugFlag", flag); + taosSetDebugFlag(&sDebugFlag, "sDebugFlag", flag); + taosSetDebugFlag(&tsdbDebugFlag, "tsdbDebugFlag", flag); + taosSetDebugFlag(&tqDebugFlag, "tqDebugFlag", flag); + taosSetDebugFlag(&fsDebugFlag, "fsDebugFlag", flag); + taosSetDebugFlag(&udfDebugFlag, "udfDebugFlag", flag); + taosSetDebugFlag(&smaDebugFlag, "smaDebugFlag", flag); + taosSetDebugFlag(&idxDebugFlag, "idxDebugFlag", flag); + uInfo("all debug flag are set to %d", flag); +} diff --git a/source/util/src/tlog.c b/source/util/src/tlog.c index 678a12fcf1..a71a75eac5 100644 --- a/source/util/src/tlog.c +++ b/source/util/src/tlog.c @@ -743,33 +743,3 @@ cmp_end: return ret; } - -void taosSetDebugFlag(int32_t *pFlagPtr, const char *flagName, int32_t flagVal) { - SConfigItem *pItem = cfgGetItem(tsCfg, flagName); - if (pItem != NULL) { - pItem->i32 = flagVal; - } - *pFlagPtr = flagVal; -} - -void taosSetAllDebugFlag(int32_t flag) { - if (flag <= 0) return; - - taosSetDebugFlag(&uDebugFlag, "uDebugFlag", flag); - taosSetDebugFlag(&rpcDebugFlag, "rpcDebugFlag", flag); - taosSetDebugFlag(&jniDebugFlag, "jniDebugFlag", flag); - taosSetDebugFlag(&qDebugFlag, "qDebugFlag", flag); - taosSetDebugFlag(&cDebugFlag, "cDebugFlag", flag); - taosSetDebugFlag(&dDebugFlag, "dDebugFlag", flag); - taosSetDebugFlag(&vDebugFlag, "vDebugFlag", flag); - taosSetDebugFlag(&mDebugFlag, "mDebugFlag", flag); - taosSetDebugFlag(&wDebugFlag, "wDebugFlag", flag); - taosSetDebugFlag(&sDebugFlag, "sDebugFlag", flag); - taosSetDebugFlag(&tsdbDebugFlag, "tsdbDebugFlag", flag); - taosSetDebugFlag(&tqDebugFlag, "tqDebugFlag", flag); - taosSetDebugFlag(&fsDebugFlag, "fsDebugFlag", flag); - taosSetDebugFlag(&udfDebugFlag, "udfDebugFlag", flag); - taosSetDebugFlag(&smaDebugFlag, "smaDebugFlag", flag); - taosSetDebugFlag(&idxDebugFlag, "idxDebugFlag", flag); - uInfo("all debug flag are set to %d", flag); -}