diff --git a/include/common/tglobal.h b/include/common/tglobal.h index 5ebfd24d5e..e49f768f55 100644 --- a/include/common/tglobal.h +++ b/include/common/tglobal.h @@ -296,8 +296,8 @@ void taosLocalCfgForbiddenToChange(char *name, bool *forbidden); int8_t taosGranted(int8_t type); int32_t taosSetSlowLogScope(char *pScopeStr, int32_t *pScope); -int32_t persistGlobalConfig(SArray *array, const char *path, int32_t version); -int32_t persistLocalConfig(const char *path); +int32_t taosPersistGlobalConfig(SArray *array, const char *path, int32_t version); +int32_t taosPersistLocalConfig(const char *path); int32_t localConfigSerialize(SArray *array, char **serialized); int32_t tSerializeSConfigArray(SEncoder *pEncoder, SArray *array); int32_t tDeserializeSConfigArray(SDecoder *pDecoder, SArray *array); diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c index 121bbfc496..98ebc3aeff 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -2800,7 +2800,7 @@ int32_t localConfigSerialize(SArray *array, char **serialized) { } // TODO:close file when error -int32_t persistGlobalConfig(SArray *array, const char *path, int32_t version) { +int32_t taosPersistGlobalConfig(SArray *array, const char *path, int32_t version) { // TODO: just tmp ,refactor later int32_t code = 0; char *buffer = NULL; @@ -2836,7 +2836,7 @@ int32_t persistGlobalConfig(SArray *array, const char *path, int32_t version) { return TSDB_CODE_SUCCESS; } -int32_t persistLocalConfig(const char *path) { +int32_t taosPersistLocalConfig(const char *path) { // TODO: just tmp ,refactor later int32_t code = 0; char *buffer = NULL; diff --git a/source/dnode/mgmt/mgmt_dnode/src/dmHandle.c b/source/dnode/mgmt/mgmt_dnode/src/dmHandle.c index 105f597d22..7021e45173 100644 --- a/source/dnode/mgmt/mgmt_dnode/src/dmHandle.c +++ b/source/dnode/mgmt/mgmt_dnode/src/dmHandle.c @@ -20,6 +20,7 @@ #include "systable.h" #include "tanal.h" #include "tchecksum.h" +#include "tutil.h" extern SConfig *tsCfg; @@ -285,6 +286,7 @@ void dmSendStatusReq(SDnodeMgmt *pMgmt) { static void dmProcessConfigRsp(SDnodeMgmt *pMgmt, SRpcMsg *pRsp) { const STraceId *trace = &pRsp->info.traceId; + int32_t code = 0; SConfigRsp configRsp = {0}; if (pRsp->code != 0) { @@ -305,7 +307,12 @@ static void dmProcessConfigRsp(SDnodeMgmt *pMgmt, SRpcMsg *pRsp) { // Try to use cfg file in current dnode. if (configRsp.forceReadConfig) { if (configRsp.isConifgVerified) { - persistGlobalConfig(taosGetGlobalCfg(tsCfg), pMgmt->path, configRsp.cver); + code = taosPersistGlobalConfig(taosGetGlobalCfg(tsCfg), pMgmt->path, configRsp.cver); + if (code != TSDB_CODE_SUCCESS) { + dError("failed to persist global config since %s", tstrerror(code)); + goto _exit; + } + needUpdate = true; } else { // log the difference configurations printConfigNotMatch(configRsp.array); @@ -315,13 +322,20 @@ static void dmProcessConfigRsp(SDnodeMgmt *pMgmt, SRpcMsg *pRsp) { // Try to use cfg from mnode sdb. if (!configRsp.isVersionVerified) { needUpdate = true; - persistGlobalConfig(configRsp.array, pMgmt->path, configRsp.cver); + code = taosPersistGlobalConfig(configRsp.array, pMgmt->path, configRsp.cver); + if (code != TSDB_CODE_SUCCESS) { + dError("failed to persist global config since %s", tstrerror(code)); + goto _exit; + } } } if (needUpdate) { setAllConfigs(tsCfg); } - persistLocalConfig(pMgmt->path); + code = taosPersistLocalConfig(pMgmt->path); + if (code != TSDB_CODE_SUCCESS) { + dError("failed to persist local config since %s", tstrerror(code)); + } tsConfigInited = 1; } _exit: @@ -453,6 +467,7 @@ int32_t dmProcessConfigReq(SDnodeMgmt *pMgmt, SRpcMsg *pMsg) { SConfig *pCfg = taosGetCfg(); SConfigItem *pItem = NULL; + code = cfgGetAndSetItem(pCfg, &pItem, cfgReq.config, cfgReq.value, CFG_STYPE_ALTER_CMD, true); if (code != 0) { if (strncasecmp(cfgReq.config, "resetlog", strlen("resetlog")) == 0) { @@ -466,11 +481,16 @@ int32_t dmProcessConfigReq(SDnodeMgmt *pMgmt, SRpcMsg *pMsg) { tsdmConfigVersion = cfgReq.version; } if (pItem->category == CFG_CATEGORY_GLOBAL) { - persistGlobalConfig(taosGetGlobalCfg(pCfg), pMgmt->path, tsdmConfigVersion); + code = taosPersistGlobalConfig(taosGetGlobalCfg(pCfg), pMgmt->path, tsdmConfigVersion); + if (code != TSDB_CODE_SUCCESS) { + dError("failed to persist global config since %s", tstrerror(code)); + } } else { - persistLocalConfig(pMgmt->path); + code = taosPersistLocalConfig(pMgmt->path); + if (code != TSDB_CODE_SUCCESS) { + dError("failed to persist local config since %s", tstrerror(code)); + } } - return TSDB_CODE_SUCCESS; } diff --git a/source/util/src/tconfig.c b/source/util/src/tconfig.c index 995396b49d..213a41c1a3 100644 --- a/source/util/src/tconfig.c +++ b/source/util/src/tconfig.c @@ -377,7 +377,6 @@ int32_t cfgGetAndSetItem(SConfig *pCfg, SConfigItem **pItem, const char *name, c (void)taosThreadMutexUnlock(&pCfg->lock); TAOS_RETURN(TSDB_CODE_CFG_NOT_FOUND); } - TAOS_CHECK_RETURN(cfgSetItemVal(*pItem, name, value, stype)); if (lock) {