From 8058a0f1a700b8886d64a4ed17129bb2b4929406 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Thu, 24 Mar 2022 18:32:14 +0800 Subject: [PATCH] xshm --- source/dnode/mgmt/container/inc/dnd.h | 9 ++------- source/dnode/mgmt/container/inc/dndInt.h | 2 +- source/dnode/mgmt/container/src/dndInt.c | 15 +++++++-------- source/dnode/mgmt/container/src/dndObj.c | 2 +- source/dnode/mgmt/container/src/dndTransport.c | 2 +- source/dnode/mgmt/mnode/src/mmInt.c | 1 + 6 files changed, 13 insertions(+), 18 deletions(-) diff --git a/source/dnode/mgmt/container/inc/dnd.h b/source/dnode/mgmt/container/inc/dnd.h index 6805c4a232..c89448ab3c 100644 --- a/source/dnode/mgmt/container/inc/dnd.h +++ b/source/dnode/mgmt/container/inc/dnd.h @@ -19,7 +19,6 @@ #include "os.h" #include "cJSON.h" -#include "monitor.h" #include "tcache.h" #include "tcrc32c.h" #include "tdatablock.h" @@ -36,8 +35,7 @@ #include "tworker.h" #include "dnode.h" -#include "tfs.h" -#include "wal.h" +#include "monitor.h" #ifdef __cplusplus extern "C" { @@ -53,7 +51,6 @@ extern "C" { typedef enum { DNODE, VNODES, QNODE, SNODE, MNODE, BNODE, NODE_MAX } ENodeType; typedef enum { DND_STAT_INIT, DND_STAT_RUNNING, DND_STAT_STOPPED } EDndStatus; typedef enum { DND_ENV_INIT, DND_ENV_READY, DND_ENV_CLEANUP } EEnvStatus; -typedef enum { DND_WORKER_SINGLE, DND_WORKER_MULTI } EWorkerType; typedef enum { PROC_SINGLE, PROC_CHILD, PROC_PARENT } EProcType; typedef struct SMgmtFp SMgmtFp; @@ -127,7 +124,6 @@ typedef struct SDnode { bool dropped; EDndStatus status; EDndEvent event; - EProcType procType; SStartupReq startup; TdFilePtr pLockFile; STransMgmt trans; @@ -138,7 +134,7 @@ EDndStatus dndGetStatus(SDnode *pDnode); void dndSetStatus(SDnode *pDnode, EDndStatus stat); SMgmtWrapper *dndAcquireWrapper(SDnode *pDnode, ENodeType nodeType); void dndSetMsgHandle(SMgmtWrapper *pWrapper, int32_t msgType, NodeMsgFp nodeMsgFp, int32_t vgId); -void dndReportStartup(SDnode *pDnode, char *pName, char *pDesc); +void dndReportStartup(SDnode *pDnode, const char *pName, const char *pDesc); void dndSendMonitorReport(SDnode *pDnode); int32_t dndSendReqToMnode(SMgmtWrapper *pWrapper, SRpcMsg *pMsg); @@ -146,7 +142,6 @@ int32_t dndSendReqToDnode(SMgmtWrapper *pWrapper, SEpSet *pEpSet, SRpcMsg *pMsg) void dndSendRsp(SMgmtWrapper *pWrapper, SRpcMsg *pRsp); int32_t dndProcessNodeMsg(SDnode *pDnode, SNodeMsg *pMsg); - int32_t dndReadFile(SMgmtWrapper *pWrapper, bool *pDeployed); int32_t dndWriteFile(SMgmtWrapper *pWrapper, bool deployed); diff --git a/source/dnode/mgmt/container/inc/dndInt.h b/source/dnode/mgmt/container/inc/dndInt.h index 9ae70874fe..0a25a989c1 100644 --- a/source/dnode/mgmt/container/inc/dndInt.h +++ b/source/dnode/mgmt/container/inc/dndInt.h @@ -34,7 +34,7 @@ int32_t dndInit(); void dndCleanup(); const char *dndStatStr(EDndStatus stat); void dndGetStartup(SDnode *pDnode, SStartupReq *pStartup); -TdFilePtr dndCheckRunning(char *dataDir); +TdFilePtr dndCheckRunning(const char *dataDir); void dndProcessStartupReq(SDnode *pDnode, SRpcMsg *pMsg); // dndMsg.c diff --git a/source/dnode/mgmt/container/src/dndInt.c b/source/dnode/mgmt/container/src/dndInt.c index 8ad4351a88..ab19415168 100644 --- a/source/dnode/mgmt/container/src/dndInt.c +++ b/source/dnode/mgmt/container/src/dndInt.c @@ -15,11 +15,12 @@ #define _DEFAULT_SOURCE #include "dndInt.h" +#include "wal.h" static int8_t once = DND_ENV_INIT; int32_t dndInit() { - dDebug("start to init dnode env"); + dInfo("start to init dnode env"); if (atomic_val_compare_exchange_8(&once, DND_ENV_INIT, DND_ENV_READY) != DND_ENV_INIT) { terrno = TSDB_CODE_REPEAT_INIT; dError("failed to init dnode env since %s", terrstr()); @@ -52,7 +53,7 @@ int32_t dndInit() { } void dndCleanup() { - dDebug("start to cleanup dnode env"); + dInfo("start to cleanup dnode env"); if (atomic_val_compare_exchange_8(&once, DND_ENV_READY, DND_ENV_CLEANUP) != DND_ENV_READY) { dError("dnode env is already cleaned up"); return; @@ -92,7 +93,7 @@ const char *dndStatStr(EDndStatus status) { } } -void dndReportStartup(SDnode *pDnode, char *pName, char *pDesc) { +void dndReportStartup(SDnode *pDnode, const char *pName, const char *pDesc) { SStartupReq *pStartup = &pDnode->startup; tstrncpy(pStartup->name, pName, TSDB_STEP_NAME_LEN); tstrncpy(pStartup->desc, pDesc, TSDB_STEP_DESC_LEN); @@ -104,21 +105,21 @@ void dndGetStartup(SDnode *pDnode, SStartupReq *pStartup) { pStartup->finished = (dndGetStatus(pDnode) == DND_STAT_RUNNING); } -TdFilePtr dndCheckRunning(char *dataDir) { +TdFilePtr dndCheckRunning(const char *dataDir) { char filepath[PATH_MAX] = {0}; snprintf(filepath, sizeof(filepath), "%s/.running", dataDir); TdFilePtr pFile = taosOpenFile(filepath, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_TRUNC); if (pFile == NULL) { terrno = TAOS_SYSTEM_ERROR(errno); - dError("failed to lock file:%s since %s, quit", filepath, terrstr()); + dError("failed to lock file:%s since %s", filepath, terrstr()); return NULL; } int32_t ret = taosLockFile(pFile); if (ret != 0) { terrno = TAOS_SYSTEM_ERROR(errno); - dError("failed to lock file:%s since %s, quit", filepath, terrstr()); + dError("failed to lock file:%s since %s", filepath, terrstr()); taosCloseFile(&pFile); return NULL; } @@ -129,12 +130,10 @@ TdFilePtr dndCheckRunning(char *dataDir) { void dndProcessStartupReq(SDnode *pDnode, SRpcMsg *pReq) { dDebug("startup req is received"); - SStartupReq *pStartup = rpcMallocCont(sizeof(SStartupReq)); dndGetStartup(pDnode, pStartup); dDebug("startup req is sent, step:%s desc:%s finished:%d", pStartup->name, pStartup->desc, pStartup->finished); - SRpcMsg rpcRsp = {.handle = pReq->handle, .pCont = pStartup, .contLen = sizeof(SStartupReq)}; rpcSendResponse(&rpcRsp); } diff --git a/source/dnode/mgmt/container/src/dndObj.c b/source/dnode/mgmt/container/src/dndObj.c index 15acbfccad..d618f4e503 100644 --- a/source/dnode/mgmt/container/src/dndObj.c +++ b/source/dnode/mgmt/container/src/dndObj.c @@ -58,7 +58,7 @@ static void dndClearMemory(SDnode *pDnode) { SDnode *dndCreate(const SDnodeOpt *pOption) { dInfo("start to create dnode object"); int32_t code = -1; - char path[PATH_MAX]; + char path[PATH_MAX] = {0}; SDnode *pDnode = NULL; pDnode = calloc(1, sizeof(SDnode)); diff --git a/source/dnode/mgmt/container/src/dndTransport.c b/source/dnode/mgmt/container/src/dndTransport.c index 25edb82baa..0f6aee4fc8 100644 --- a/source/dnode/mgmt/container/src/dndTransport.c +++ b/source/dnode/mgmt/container/src/dndTransport.c @@ -271,7 +271,7 @@ int32_t dndInitMsgHandle(SDnode *pDnode) { int32_t vgId = pWrapper->msgVgIds[msgIndex]; if (msgFp == NULL) continue; - dTrace("msg:%s will be processed by %s, vgId:%d", tMsgInfo[msgIndex], pWrapper->name, vgId); + // dTrace("msg:%s will be processed by %s, vgId:%d", tMsgInfo[msgIndex], pWrapper->name, vgId); SMsgHandle *pHandle = &pMgmt->msgHandles[msgIndex]; if (vgId == QND_VGID) { diff --git a/source/dnode/mgmt/mnode/src/mmInt.c b/source/dnode/mgmt/mnode/src/mmInt.c index aa348ae879..81d1abc692 100644 --- a/source/dnode/mgmt/mnode/src/mmInt.c +++ b/source/dnode/mgmt/mnode/src/mmInt.c @@ -15,6 +15,7 @@ #define _DEFAULT_SOURCE #include "mmInt.h" +#include "wal.h" static bool mmDeployRequired(SDnode *pDnode) { if (pDnode->dnodeId > 0) return false;