From 7c588cc074775c9f67e599778b8cc11b86671aae Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Tue, 19 Apr 2022 19:43:55 +0800 Subject: [PATCH] feat: report startup steps --- include/common/tmsgcb.h | 3 +++ source/common/src/tmsgcb.c | 4 ++++ source/dnode/mgmt/implement/src/dmExec.c | 2 ++ source/dnode/mgmt/implement/src/dmHandle.c | 8 +++++--- source/dnode/mgmt/implement/src/dmTransport.c | 2 +- source/dnode/mgmt/implement/src/dmWorker.c | 2 ++ source/dnode/mgmt/interface/inc/dmInt.h | 1 + source/dnode/mgmt/interface/src/dmInt.c | 6 ++++++ source/dnode/mgmt/mgmt_bnode/src/bmInt.c | 2 ++ source/dnode/mgmt/mgmt_mnode/src/mmInt.c | 2 ++ source/dnode/mgmt/mgmt_qnode/src/qmInt.c | 2 ++ source/dnode/mgmt/mgmt_snode/src/smInt.c | 2 ++ source/dnode/mgmt/mgmt_vnode/src/vmInt.c | 7 ++++++- source/dnode/mnode/impl/src/mnode.c | 1 + 14 files changed, 39 insertions(+), 5 deletions(-) diff --git a/include/common/tmsgcb.h b/include/common/tmsgcb.h index 6c3671a8d6..02d8b76b9b 100644 --- a/include/common/tmsgcb.h +++ b/include/common/tmsgcb.h @@ -44,6 +44,7 @@ typedef int32_t (*SendMnodeReqFp)(SMgmtWrapper* pWrapper, SRpcMsg* pReq); typedef void (*SendRspFp)(SMgmtWrapper* pWrapper, const SRpcMsg* pRsp); typedef void (*RegisterBrokenLinkArgFp)(SMgmtWrapper* pWrapper, SRpcMsg* pMsg); typedef void (*ReleaseHandleFp)(SMgmtWrapper* pWrapper, void* handle, int8_t type); +typedef void (*ReportStartup)(SMgmtWrapper* pWrapper, const char* name, const char* desc); typedef struct { SMgmtWrapper* pWrapper; @@ -53,6 +54,7 @@ typedef struct { SendRspFp sendRspFp; RegisterBrokenLinkArgFp registerBrokenLinkArgFp; ReleaseHandleFp releaseHandleFp; + ReportStartup reportStartupFp; } SMsgCb; void tmsgSetDefaultMsgCb(const SMsgCb* pMsgCb); @@ -62,6 +64,7 @@ int32_t tmsgSendReq(const SMsgCb* pMsgCb, const SEpSet* epSet, SRpcMsg* pReq); void tmsgSendRsp(const SRpcMsg* pRsp); void tmsgRegisterBrokenLinkArg(const SMsgCb* pMsgCb, SRpcMsg* pMsg); void tmsgReleaseHandle(void* handle, int8_t type); +void tmsgReportStartup(const char* name, const char* desc); #ifdef __cplusplus } diff --git a/source/common/src/tmsgcb.c b/source/common/src/tmsgcb.c index cb5e2b07c1..5b4bb539e3 100644 --- a/source/common/src/tmsgcb.c +++ b/source/common/src/tmsgcb.c @@ -40,4 +40,8 @@ void tmsgRegisterBrokenLinkArg(const SMsgCb* pMsgCb, SRpcMsg* pMsg) { void tmsgReleaseHandle(void* handle, int8_t type) { (*tsDefaultMsgCb.releaseHandleFp)(tsDefaultMsgCb.pWrapper, handle, type); +} + +void tmsgReportStartup(const char* name, const char* desc) { + (*tsDefaultMsgCb.reportStartupFp)(tsDefaultMsgCb.pWrapper, name, desc); } \ No newline at end of file diff --git a/source/dnode/mgmt/implement/src/dmExec.c b/source/dnode/mgmt/implement/src/dmExec.c index f66e7cd9d3..431c595f8f 100644 --- a/source/dnode/mgmt/implement/src/dmExec.c +++ b/source/dnode/mgmt/implement/src/dmExec.c @@ -140,6 +140,7 @@ int32_t dmOpenNode(SMgmtWrapper *pWrapper) { if (dmRunParentProc(pWrapper) != 0) return -1; } + dmReportStartup(pWrapper->pDnode, pWrapper->name, "openned"); return 0; } @@ -161,6 +162,7 @@ int32_t dmStartNode(SMgmtWrapper *pWrapper) { } } + dmReportStartup(pWrapper->pDnode, pWrapper->name, "started"); return 0; } diff --git a/source/dnode/mgmt/implement/src/dmHandle.c b/source/dnode/mgmt/implement/src/dmHandle.c index 1179db8ae2..713cf24145 100644 --- a/source/dnode/mgmt/implement/src/dmHandle.c +++ b/source/dnode/mgmt/implement/src/dmHandle.c @@ -36,7 +36,8 @@ static int32_t dmProcessStatusRsp(SDnode *pDnode, SRpcMsg *pRsp) { } } else { SStatusRsp statusRsp = {0}; - if (pRsp->pCont != NULL && pRsp->contLen > 0 && tDeserializeSStatusRsp(pRsp->pCont, pRsp->contLen, &statusRsp) == 0) { + if (pRsp->pCont != NULL && pRsp->contLen > 0 && + tDeserializeSStatusRsp(pRsp->pCont, pRsp->contLen, &statusRsp) == 0) { pDnode->data.dnodeVer = statusRsp.dnodeVer; dmUpdateDnodeCfg(pDnode, &statusRsp.dnodeCfg); dmUpdateEps(pDnode, statusRsp.pDnodeEps); @@ -76,7 +77,7 @@ void dmSendStatusReq(SDnode *pDnode) { req.pVloads = info.pVloads; int32_t contLen = tSerializeSStatusReq(NULL, 0, &req); - void * pHead = rpcMallocCont(contLen); + void *pHead = rpcMallocCont(contLen); tSerializeSStatusReq(pHead, contLen, &req); tFreeSStatusReq(&req); @@ -101,7 +102,7 @@ int32_t dmProcessGrantRsp(SDnode *pDnode, SNodeMsg *pMsg) { } int32_t dmProcessConfigReq(SDnode *pDnode, SNodeMsg *pMsg) { - SRpcMsg * pReq = &pMsg->rpcMsg; + SRpcMsg *pReq = &pMsg->rpcMsg; SDCfgDnodeReq *pCfg = pReq->pCont; dError("config req is received, but not supported yet"); return TSDB_CODE_OPS_NOT_SUPPORT; @@ -230,6 +231,7 @@ static int32_t dmInitMgmt(SMgmtWrapper *pWrapper) { dError("failed to init transport since %s", terrstr()); return -1; } + dmReportStartup(pDnode, "dnode-transport", "initialized"); dInfo("dnode-mgmt is initialized"); return 0; diff --git a/source/dnode/mgmt/implement/src/dmTransport.c b/source/dnode/mgmt/implement/src/dmTransport.c index 689e492d5c..7cfec917b1 100644 --- a/source/dnode/mgmt/implement/src/dmTransport.c +++ b/source/dnode/mgmt/implement/src/dmTransport.c @@ -505,7 +505,6 @@ static void dmCleanupServer(SDnode *pDnode) { int32_t dmInitTrans(SDnode *pDnode) { if (dmInitServer(pDnode) != 0) return -1; if (dmInitClient(pDnode) != 0) return -1; - dmReportStartup(pDnode, "transport", "initialized"); return 0; } @@ -520,6 +519,7 @@ SMsgCb dmGetMsgcb(SMgmtWrapper *pWrapper) { .sendRspFp = dmSendRsp, .registerBrokenLinkArgFp = dmRegisterBrokenLinkArg, .releaseHandleFp = dmReleaseHandle, + .reportStartupFp = dmReportStartupByWrapper, .pWrapper = pWrapper, }; return msgCb; diff --git a/source/dnode/mgmt/implement/src/dmWorker.c b/source/dnode/mgmt/implement/src/dmWorker.c index 6ffb8e1a23..505efeb8c6 100644 --- a/source/dnode/mgmt/implement/src/dmWorker.c +++ b/source/dnode/mgmt/implement/src/dmWorker.c @@ -74,6 +74,7 @@ int32_t dmStartStatusThread(SDnode *pDnode) { return -1; } + dmReportStartup(pDnode, "dnode-status", "initialized"); return 0; } @@ -92,6 +93,7 @@ int32_t dmStartMonitorThread(SDnode *pDnode) { return -1; } + dmReportStartup(pDnode, "dnode-monitor", "initialized"); return 0; } diff --git a/source/dnode/mgmt/interface/inc/dmInt.h b/source/dnode/mgmt/interface/inc/dmInt.h index 851887de5f..a2368f3173 100644 --- a/source/dnode/mgmt/interface/inc/dmInt.h +++ b/source/dnode/mgmt/interface/inc/dmInt.h @@ -35,6 +35,7 @@ void dmSetStatus(SDnode *pDnode, EDndRunStatus stat); void dmSetEvent(SDnode *pDnode, EDndEvent event); void dmSetMsgHandle(SMgmtWrapper *pWrapper, tmsg_t msgType, NodeMsgFp nodeMsgFp, int8_t vgId); void dmReportStartup(SDnode *pDnode, const char *pName, const char *pDesc); +void dmReportStartupByWrapper(SMgmtWrapper *pWrapper, const char *pName, const char *pDesc); void dmProcessServerStatusReq(SDnode *pDnode, SRpcMsg *pMsg); void dmGetMonitorSysInfo(SMonSysInfo *pInfo); diff --git a/source/dnode/mgmt/interface/src/dmInt.c b/source/dnode/mgmt/interface/src/dmInt.c index d10660d69d..e79fd59bd0 100644 --- a/source/dnode/mgmt/interface/src/dmInt.c +++ b/source/dnode/mgmt/interface/src/dmInt.c @@ -140,6 +140,12 @@ void dmReportStartup(SDnode *pDnode, const char *pName, const char *pDesc) { SStartupInfo *pStartup = &pDnode->startup; tstrncpy(pStartup->name, pName, TSDB_STEP_NAME_LEN); tstrncpy(pStartup->desc, pDesc, TSDB_STEP_DESC_LEN); + dInfo("step:%s, %s", pStartup->name, pStartup->desc); + taosMsleep(300); +} + +void dmReportStartupByWrapper(SMgmtWrapper *pWrapper, const char *pName, const char *pDesc) { + dmReportStartup(pWrapper->pDnode, pName, pDesc); } static void dmGetServerStatus(SDnode *pDnode, SServerStatusRsp *pStatus) { diff --git a/source/dnode/mgmt/mgmt_bnode/src/bmInt.c b/source/dnode/mgmt/mgmt_bnode/src/bmInt.c index f635df8ec7..2920d12eb4 100644 --- a/source/dnode/mgmt/mgmt_bnode/src/bmInt.c +++ b/source/dnode/mgmt/mgmt_bnode/src/bmInt.c @@ -61,12 +61,14 @@ int32_t bmOpen(SMgmtWrapper *pWrapper) { bmClose(pWrapper); return -1; } + dmReportStartup(pWrapper->pDnode, "bnode-impl", "initialized"); if (bmStartWorker(pMgmt) != 0) { dError("failed to start bnode worker since %s", terrstr()); bmClose(pWrapper); return -1; } + dmReportStartup(pWrapper->pDnode, "bnode-worker", "initialized"); return 0; } diff --git a/source/dnode/mgmt/mgmt_mnode/src/mmInt.c b/source/dnode/mgmt/mgmt_mnode/src/mmInt.c index 69b4d50939..f707426ab4 100644 --- a/source/dnode/mgmt/mgmt_mnode/src/mmInt.c +++ b/source/dnode/mgmt/mgmt_mnode/src/mmInt.c @@ -176,12 +176,14 @@ static int32_t mmOpen(SMgmtWrapper *pWrapper) { mmClose(pWrapper); return -1; } + dmReportStartup(pWrapper->pDnode, "mnode-impl", "initialized"); if (mmStartWorker(pMgmt) != 0) { dError("failed to start mnode worker since %s", terrstr()); mmClose(pWrapper); return -1; } + dmReportStartup(pWrapper->pDnode, "mnode-worker", "initialized"); if (!deployed) { deployed = true; diff --git a/source/dnode/mgmt/mgmt_qnode/src/qmInt.c b/source/dnode/mgmt/mgmt_qnode/src/qmInt.c index d8d02b2619..d03f001a8d 100644 --- a/source/dnode/mgmt/mgmt_qnode/src/qmInt.c +++ b/source/dnode/mgmt/mgmt_qnode/src/qmInt.c @@ -64,12 +64,14 @@ static int32_t qmOpen(SMgmtWrapper *pWrapper) { qmClose(pWrapper); return -1; } + dmReportStartup(pWrapper->pDnode, "qnode-impl", "initialized"); if (qmStartWorker(pMgmt) != 0) { dError("failed to start qnode worker since %s", terrstr()); qmClose(pWrapper); return -1; } + dmReportStartup(pWrapper->pDnode, "qnode-worker", "initialized"); dInfo("qnode-mgmt is initialized"); return 0; diff --git a/source/dnode/mgmt/mgmt_snode/src/smInt.c b/source/dnode/mgmt/mgmt_snode/src/smInt.c index 8adf643a2b..3757dcd72a 100644 --- a/source/dnode/mgmt/mgmt_snode/src/smInt.c +++ b/source/dnode/mgmt/mgmt_snode/src/smInt.c @@ -60,11 +60,13 @@ int32_t smOpen(SMgmtWrapper *pWrapper) { dError("failed to open snode since %s", terrstr()); return -1; } + dmReportStartup(pWrapper->pDnode, "snode-impl", "initialized"); if (smStartWorker(pMgmt) != 0) { dError("failed to start snode worker since %s", terrstr()); return -1; } + dmReportStartup(pWrapper->pDnode, "snode-worker", "initialized"); return 0; } diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmInt.c b/source/dnode/mgmt/mgmt_vnode/src/vmInt.c index a212d7edf4..c8e4393b59 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmInt.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmInt.c @@ -130,7 +130,7 @@ static void *vmOpenVnodeFunc(void *param) { char stepDesc[TSDB_STEP_DESC_LEN] = {0}; snprintf(stepDesc, TSDB_STEP_DESC_LEN, "vgId:%d, start to restore, %d of %d have been opened", pCfg->vgId, pMgmt->state.openVnodes, pMgmt->state.totalVnodes); - dmReportStartup(pDnode, "open-vnodes", stepDesc); + dmReportStartup(pDnode, "vnode-open", stepDesc); SMsgCb msgCb = pMgmt->pDnode->data.msgCb; msgCb.pWrapper = pMgmt->pWrapper; @@ -298,25 +298,30 @@ static int32_t vmInit(SMgmtWrapper *pWrapper) { dError("failed to init tfs since %s", terrstr()); goto _OVER; } + dmReportStartup(pDnode, "vnode-tfs", "initialized"); if (walInit() != 0) { dError("failed to init wal since %s", terrstr()); goto _OVER; } + dmReportStartup(pDnode, "vnode-wal", "initialized"); if (vnodeInit(tsNumOfCommitThreads) != 0) { dError("failed to init vnode since %s", terrstr()); goto _OVER; } + dmReportStartup(pDnode, "vnode-commit", "initialized"); if (vmStartWorker(pMgmt) != 0) { dError("failed to init workers since %s", terrstr()) goto _OVER; } + dmReportStartup(pDnode, "vnode-worker", "initialized"); if (vmOpenVnodes(pMgmt) != 0) { dError("failed to open vnode since %s", terrstr()); return -1; } + dmReportStartup(pDnode, "vnode-vnodes", "initialized"); code = 0; diff --git a/source/dnode/mnode/impl/src/mnode.c b/source/dnode/mnode/impl/src/mnode.c index 3ac1c522b2..985823653c 100644 --- a/source/dnode/mnode/impl/src/mnode.c +++ b/source/dnode/mnode/impl/src/mnode.c @@ -262,6 +262,7 @@ static int32_t mndExecSteps(SMnode *pMnode) { return -1; } else { mDebug("%s is initialized", pStep->name); + tmsgReportStartup(pStep->name, "initialized"); } } -- GitLab