From 06b3e87ab7d3a4be66d27fa1952ef1e3e03f082e Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Sat, 31 Oct 2020 10:08:22 +0000 Subject: [PATCH] TD-1663 --- src/client/src/tscSystem.c | 1 - src/common/inc/tglobal.h | 14 +++++++------- src/common/src/tglobal.c | 6 ++++-- src/dnode/src/dnodeEps.c | 3 +++ src/dnode/src/dnodeMInfos.c | 10 +++++++--- src/dnode/src/dnodeMain.c | 16 +++++++++------- src/util/src/tconfig.c | 6 +++++- src/vnode/src/vnodeCfg.c | 2 ++ 8 files changed, 37 insertions(+), 21 deletions(-) diff --git a/src/client/src/tscSystem.c b/src/client/src/tscSystem.c index 77d668c5af..839d5889f3 100644 --- a/src/client/src/tscSystem.c +++ b/src/client/src/tscSystem.c @@ -104,7 +104,6 @@ void taos_init_imp(void) { taosReadGlobalCfg(); taosCheckGlobalCfg(); - taosPrintGlobalCfg(); tscDebug("starting to initialize TAOS client ..."); tscDebug("Local End Point is:%s", tsLocalEp); diff --git a/src/common/inc/tglobal.h b/src/common/inc/tglobal.h index 4636eaac08..b00f4b9f9f 100644 --- a/src/common/inc/tglobal.h +++ b/src/common/inc/tglobal.h @@ -183,13 +183,13 @@ extern int32_t debugFlag; #define NEEDTO_COMPRESSS_MSG(size) (tsCompressMsgSize != -1 && (size) > tsCompressMsgSize) -void taosInitGlobalCfg(); -bool taosCheckGlobalCfg(); -void taosSetAllDebugFlag(); -bool taosCfgDynamicOptions(char *msg); -int taosGetFqdnPortFromEp(const char *ep, char *fqdn, uint16_t *port); -bool taosCheckBalanceCfgOptions(const char *option, int32_t *vnodeId, int32_t *dnodeId); - +void taosInitGlobalCfg(); +int32_t taosCheckGlobalCfg(); +void taosSetAllDebugFlag(); +bool taosCfgDynamicOptions(char *msg); +int taosGetFqdnPortFromEp(const char *ep, char *fqdn, uint16_t *port); +bool taosCheckBalanceCfgOptions(const char *option, int32_t *vnodeId, int32_t *dnodeId); + #ifdef __cplusplus } #endif diff --git a/src/common/src/tglobal.c b/src/common/src/tglobal.c index 32569e3982..2fd0a53661 100644 --- a/src/common/src/tglobal.c +++ b/src/common/src/tglobal.c @@ -1316,7 +1316,7 @@ void taosInitGlobalCfg() { pthread_once(&tsInitGlobalCfgOnce, doInitGlobalConfig); } -bool taosCheckGlobalCfg() { +int32_t taosCheckGlobalCfg() { char fqdn[TSDB_FQDN_LEN]; uint16_t port; @@ -1375,7 +1375,9 @@ bool taosCheckGlobalCfg() { tsSyncPort = tsServerPort + TSDB_PORT_SYNC; tsHttpPort = tsServerPort + TSDB_PORT_HTTP; - return true; + taosPrintGlobalCfg(); + + return 0; } int taosGetFqdnPortFromEp(const char *ep, char *fqdn, uint16_t *port) { diff --git a/src/dnode/src/dnodeEps.c b/src/dnode/src/dnodeEps.c index af8f18e884..9c90c39181 100644 --- a/src/dnode/src/dnodeEps.c +++ b/src/dnode/src/dnodeEps.c @@ -87,6 +87,7 @@ bool dnodeCheckEpChanged(int32_t dnodeId, char *epstr) { char epSaved[TSDB_EP_LEN + 1]; snprintf(epSaved, TSDB_EP_LEN, "%s:%u", ep->dnodeFqdn, ep->dnodePort); changed = strcmp(epstr, epSaved) != 0; + tstrncpy(epstr, epSaved, TSDB_EP_LEN); } pthread_mutex_unlock(&tsEpsMutex); return changed; @@ -235,6 +236,8 @@ PRASE_EPS_OVER: dnodeResetEps(eps); if (eps) free(eps); + dnodeUpdateEp(dnodeGetDnodeId(), tsLocalEp, tsLocalFqdn, &tsServerPort); + terrno = 0; return 0; } diff --git a/src/dnode/src/dnodeMInfos.c b/src/dnode/src/dnodeMInfos.c index 5240b0d487..c985db371d 100644 --- a/src/dnode/src/dnodeMInfos.c +++ b/src/dnode/src/dnodeMInfos.c @@ -124,9 +124,9 @@ void dnodeGetEpSetForShell(SRpcEpSet *epSet) { } static void dnodePrintMInfos(SMnodeInfos *minfos) { - dInfo("print mnode infos, mnodeNum:%d inUse:%d", tsMInfos.mnodeNum, tsMInfos.inUse); - for (int32_t i = 0; i < tsMInfos.mnodeNum; i++) { - dInfo("mnode index:%d, %s", tsMInfos.mnodeInfos[i].mnodeId, tsMInfos.mnodeInfos[i].mnodeEp); + dInfo("print mnode infos, mnodeNum:%d inUse:%d", minfos->mnodeNum, minfos->inUse); + for (int32_t i = 0; i < minfos->mnodeNum; i++) { + dInfo("mnode index:%d, %s", minfos->mnodeInfos[i].mnodeId, minfos->mnodeInfos[i].mnodeEp); } } @@ -240,6 +240,10 @@ PARSE_MINFOS_OVER: if (fp != NULL) fclose(fp); terrno = 0; + for (int32_t i = 0; i < minfos.mnodeNum; ++i) { + SMnodeInfo *mInfo = &minfos.mnodeInfos[i]; + dnodeUpdateEp(mInfo->mnodeId, mInfo->mnodeEp, NULL, NULL); + } dnodeResetMInfos(&minfos); return 0; } diff --git a/src/dnode/src/dnodeMain.c b/src/dnode/src/dnodeMain.c index 4731c813b8..e79d3550b6 100644 --- a/src/dnode/src/dnodeMain.c +++ b/src/dnode/src/dnodeMain.c @@ -54,9 +54,10 @@ typedef struct { static const SDnodeComponent tsDnodeComponents[] = { {"storage", dnodeInitStorage, dnodeCleanupStorage}, - {"eps", dnodeInitEps, dnodeCleanupEps}, - {"minfos", dnodeInitMInfos, dnodeCleanupMInfos}, - {"cfg", dnodeInitCfg, dnodeCleanupCfg}, + {"dnodecfg", dnodeInitCfg, dnodeCleanupCfg}, + {"dnodeeps", dnodeInitEps, dnodeCleanupEps}, + {"mnodeinfos",dnodeInitMInfos, dnodeCleanupMInfos}, + {"globalcfg" ,taosCheckGlobalCfg, NULL}, {"check", dnodeInitCheck, dnodeCleanupCheck}, // NOTES: dnodeInitCheck must be behind the dnodeinitStorage component !!! {"vread", dnodeInitVnodeRead, dnodeCleanupVnodeRead}, {"vwrite", dnodeInitVnodeWrite, dnodeCleanupVnodeWrite}, @@ -82,7 +83,9 @@ static int dnodeCreateDir(const char *dir) { static void dnodeCleanupComponents(int32_t stepId) { for (int32_t i = stepId; i >= 0; i--) { - tsDnodeComponents[i].cleanup(); + if (tsDnodeComponents[i].cleanup) { + (*tsDnodeComponents[i].cleanup)(); + } } } @@ -119,14 +122,13 @@ int32_t dnodeInitSystem() { printf("failed to init log file\n"); } - if (!taosReadGlobalCfg() || !taosCheckGlobalCfg()) { + if (!taosReadGlobalCfg()) { taosPrintGlobalCfg(); dError("TDengine read global config failed"); return -1; } - taosPrintGlobalCfg(); - dInfo("start to initialize TDengine on %s", tsLocalEp); + dInfo("start to initialize TDengine"); if (dnodeInitComponents() != 0) { return -1; diff --git a/src/util/src/tconfig.c b/src/util/src/tconfig.c index 0ec55841a0..f449bfb68b 100644 --- a/src/util/src/tconfig.c +++ b/src/util/src/tconfig.c @@ -355,7 +355,11 @@ bool taosReadGlobalCfg() { fclose(fp); taosTFree(line); - + + if (debugFlag & DEBUG_TRACE || debugFlag & DEBUG_DEBUG || debugFlag & DEBUG_DUMP) { + taosSetAllDebugFlag(); + } + return true; } diff --git a/src/vnode/src/vnodeCfg.c b/src/vnode/src/vnodeCfg.c index 746a5ab494..f0040f8cdf 100644 --- a/src/vnode/src/vnodeCfg.c +++ b/src/vnode/src/vnodeCfg.c @@ -72,6 +72,8 @@ int32_t vnodeReadCfg(SVnodeObj *pVnode) { char file[TSDB_FILENAME_LEN + 30] = {0}; sprintf(file, "%s/vnode%d/config.json", tsVnodeDir, pVnode->vgId); + vnodeMsg.cfg.vgId = pVnode->vgId; + fp = fopen(file, "r"); if (!fp) { vError("vgId:%d, failed to open vnode cfg file:%s to read, error:%s", pVnode->vgId, file, strerror(errno)); -- GitLab