From 9b7f04b0595d080ab382a78dd76e0ab434f7b5fc Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Tue, 27 Oct 2020 05:42:46 +0000 Subject: [PATCH] TD-1762 --- src/dnode/src/dnodeCfg.c | 6 +++++- src/dnode/src/dnodeCheck.c | 4 +--- src/dnode/src/dnodeEps.c | 6 +++++- src/dnode/src/dnodeMInfos.c | 7 ++++++- src/dnode/src/dnodeMPeer.c | 2 +- src/dnode/src/dnodeMRead.c | 2 +- src/dnode/src/dnodeMWrite.c | 2 +- src/dnode/src/dnodeMain.c | 2 +- src/dnode/src/dnodeMgmt.c | 1 - src/dnode/src/dnodeModule.c | 1 + src/dnode/src/dnodePeer.c | 4 ++-- src/dnode/src/dnodeShell.c | 2 +- src/dnode/src/dnodeTelemetry.c | 1 + src/dnode/src/dnodeVRead.c | 2 +- src/dnode/src/dnodeVWrite.c | 2 +- src/mnode/src/mnodeDnode.c | 16 +++++++++++----- src/rpc/src/rpcMain.c | 4 ++-- src/rpc/src/rpcTcp.c | 5 +++-- src/rpc/src/rpcUdp.c | 5 +++-- 19 files changed, 47 insertions(+), 27 deletions(-) diff --git a/src/dnode/src/dnodeCfg.c b/src/dnode/src/dnodeCfg.c index 19ebde163d..c4a1f6b450 100644 --- a/src/dnode/src/dnodeCfg.c +++ b/src/dnode/src/dnodeCfg.c @@ -32,7 +32,11 @@ static void dnodePrintCfg(SDnodeCfg *cfg); int32_t dnodeInitCfg() { pthread_mutex_init(&tsCfgMutex, NULL); dnodeResetCfg(NULL); - return dnodeReadCfg(); + int32_t ret = dnodeReadCfg(); + if (ret == 0) { + dInfo("dnode cfg is initialized"); + } + return ret; } void dnodeCleanupCfg() { pthread_mutex_destroy(&tsCfgMutex); } diff --git a/src/dnode/src/dnodeCheck.c b/src/dnode/src/dnodeCheck.c index b68c22df33..a9ee4ac649 100644 --- a/src/dnode/src/dnodeCheck.c +++ b/src/dnode/src/dnodeCheck.c @@ -262,8 +262,6 @@ int32_t dnodeInitCheck() { } } + dInfo("dnode check is initialized"); return 0; } - - - diff --git a/src/dnode/src/dnodeEps.c b/src/dnode/src/dnodeEps.c index a97bf02cca..9627333fc3 100644 --- a/src/dnode/src/dnodeEps.c +++ b/src/dnode/src/dnodeEps.c @@ -35,7 +35,11 @@ int32_t dnodeInitEps() { pthread_mutex_init(&tsEpsMutex, NULL); tsEpsHash = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, true); dnodeResetEps(NULL); - return dnodeReadEps(); + int32_t ret = dnodeReadEps(); + if (ret == 0) { + dInfo("dnode eps is initialized"); + } + return ret; } void dnodeCleanupEps() { diff --git a/src/dnode/src/dnodeMInfos.c b/src/dnode/src/dnodeMInfos.c index 31e22514a3..0fbb946869 100644 --- a/src/dnode/src/dnodeMInfos.c +++ b/src/dnode/src/dnodeMInfos.c @@ -34,7 +34,12 @@ static int32_t dnodeWriteMInfos(); int32_t dnodeInitMInfos() { pthread_mutex_init(&tsMInfosMutex, NULL); dnodeResetMInfos(NULL); - return dnodeReadMInfos(); + int32_t ret = dnodeReadMInfos(); + if (ret == 0) { + dInfo("dnode minfos is initialized"); + } + + return ret; } void dnodeCleanupMInfos() { pthread_mutex_destroy(&tsMInfosMutex); } diff --git a/src/dnode/src/dnodeMPeer.c b/src/dnode/src/dnodeMPeer.c index 8414d79a98..0da7ab74e4 100644 --- a/src/dnode/src/dnodeMPeer.c +++ b/src/dnode/src/dnodeMPeer.c @@ -58,7 +58,7 @@ int32_t dnodeInitMnodePeer() { dDebug("dnode mpeer worker:%d is created", i); } - dDebug("dnode mpeer is opened, workers:%d qset:%p", tsMPeerPool.maxNum, tsMPeerQset); + dDebug("dnode mpeer is initialized, workers:%d qset:%p", tsMPeerPool.maxNum, tsMPeerQset); return 0; } diff --git a/src/dnode/src/dnodeMRead.c b/src/dnode/src/dnodeMRead.c index fdcbb5889f..4ad787f26e 100644 --- a/src/dnode/src/dnodeMRead.c +++ b/src/dnode/src/dnodeMRead.c @@ -60,7 +60,7 @@ int32_t dnodeInitMnodeRead() { dDebug("dnode mread worker:%d is created", i); } - dDebug("dnode mread is opened, workers:%d qset:%p", tsMReadPool.maxNum, tsMReadQset); + dDebug("dnode mread is initialized, workers:%d qset:%p", tsMReadPool.maxNum, tsMReadQset); return 0; } diff --git a/src/dnode/src/dnodeMWrite.c b/src/dnode/src/dnodeMWrite.c index 384a0fae75..600688b9fd 100644 --- a/src/dnode/src/dnodeMWrite.c +++ b/src/dnode/src/dnodeMWrite.c @@ -60,7 +60,7 @@ int32_t dnodeInitMnodeWrite() { dDebug("dnode mwrite worker:%d is created", i); } - dDebug("dnode mwrite is opened, workers:%d qset:%p", tsMWritePool.maxNum, tsMWriteQset); + dDebug("dnode mwrite is initialized, workers:%d qset:%p", tsMWritePool.maxNum, tsMWriteQset); return 0; } diff --git a/src/dnode/src/dnodeMain.c b/src/dnode/src/dnodeMain.c index 991ac8f9f9..4731c813b8 100644 --- a/src/dnode/src/dnodeMain.c +++ b/src/dnode/src/dnodeMain.c @@ -205,7 +205,7 @@ static int32_t dnodeInitStorage() { dnodeCheckDataDirOpenned(tsDnodeDir); - dInfo("storage directory is initialized"); + dInfo("dnode storage is initialized at %s", tsDnodeDir); return 0; } diff --git a/src/dnode/src/dnodeMgmt.c b/src/dnode/src/dnodeMgmt.c index c26b548fca..ace44f8161 100644 --- a/src/dnode/src/dnodeMgmt.c +++ b/src/dnode/src/dnodeMgmt.c @@ -79,7 +79,6 @@ int32_t dnodeInitMgmt() { dnodeAddClientRspHandle(TSDB_MSG_TYPE_DM_STATUS_RSP, dnodeProcessStatusRsp); tsRebootTime = taosGetTimestampSec(); - int32_t code = vnodeInitResources(); if (code != TSDB_CODE_SUCCESS) { dnodeCleanupMgmt(); diff --git a/src/dnode/src/dnodeModule.c b/src/dnode/src/dnodeModule.c index 4cc59ec40d..bd9500ba51 100644 --- a/src/dnode/src/dnodeModule.c +++ b/src/dnode/src/dnodeModule.c @@ -114,6 +114,7 @@ int32_t dnodeInitModules() { } } + dInfo("dnode modules is initialized"); return 0; } diff --git a/src/dnode/src/dnodePeer.c b/src/dnode/src/dnodePeer.c index 48efdf69c1..d2bb5d888d 100644 --- a/src/dnode/src/dnodePeer.c +++ b/src/dnode/src/dnodePeer.c @@ -72,7 +72,7 @@ int32_t dnodeInitServer() { return -1; } - dInfo("inter-dnodes RPC server is opened"); + dInfo("dnode inter-dnodes RPC server is initialized"); return 0; } @@ -137,7 +137,7 @@ int32_t dnodeInitClient() { return -1; } - dInfo("inter-dnodes rpc client is opened"); + dInfo("initialized inter-dnodes rpc client is initialized"); return 0; } diff --git a/src/dnode/src/dnodeShell.c b/src/dnode/src/dnodeShell.c index 4c6c2100e0..ec56145503 100644 --- a/src/dnode/src/dnodeShell.c +++ b/src/dnode/src/dnodeShell.c @@ -97,7 +97,7 @@ int32_t dnodeInitShell() { return -1; } - dInfo("shell rpc server is opened"); + dInfo("dnode shell rpc server is initialized"); return 0; } diff --git a/src/dnode/src/dnodeTelemetry.c b/src/dnode/src/dnodeTelemetry.c index 4fdc0b8a73..ab58e0470f 100644 --- a/src/dnode/src/dnodeTelemetry.c +++ b/src/dnode/src/dnodeTelemetry.c @@ -299,6 +299,7 @@ int32_t dnodeInitTelemetry() { dTrace("failed to create telemetry thread, reason:%s", strerror(errno)); } + dInfo("dnode telemetry is initialized"); return 0; } diff --git a/src/dnode/src/dnodeVRead.c b/src/dnode/src/dnodeVRead.c index e61158ef30..cd913cc100 100644 --- a/src/dnode/src/dnodeVRead.c +++ b/src/dnode/src/dnodeVRead.c @@ -61,7 +61,7 @@ int32_t dnodeInitVnodeRead() { pWorker->workerId = i; } - dInfo("dnode read is opened, min worker:%d max worker:%d", readPool.min, readPool.max); + dInfo("dnode read is initialized, min worker:%d max worker:%d", readPool.min, readPool.max); return 0; } diff --git a/src/dnode/src/dnodeVWrite.c b/src/dnode/src/dnodeVWrite.c index f2740bf6b8..d36c140f43 100644 --- a/src/dnode/src/dnodeVWrite.c +++ b/src/dnode/src/dnodeVWrite.c @@ -69,7 +69,7 @@ int32_t dnodeInitVnodeWrite() { wWorkerPool.writeWorker[i].workerId = i; } - dInfo("dnode write is opened, max worker %d", wWorkerPool.max); + dInfo("dnode write is initialized, max worker %d", wWorkerPool.max); return 0; } diff --git a/src/mnode/src/mnodeDnode.c b/src/mnode/src/mnodeDnode.c index c9e8b8c87a..59c02ca373 100644 --- a/src/mnode/src/mnodeDnode.c +++ b/src/mnode/src/mnodeDnode.c @@ -440,9 +440,11 @@ static int32_t mnodeGetDnodeEpsSize() { return size; } -static void mnodeGetDnodeEpsData(SDnodeEps *pEps) { +static void mnodeGetDnodeEpsData(SDnodeEps *pEps, int32_t epsSize) { pthread_mutex_lock(&tsDnodeEpsMutex); - memcpy(pEps, tsDnodeEps, tsDnodeEpsSize); + if (epsSize == tsDnodeEpsSize) { + memcpy(pEps, tsDnodeEps, tsDnodeEpsSize); + } pthread_mutex_unlock(&tsDnodeEpsMutex); } @@ -451,6 +453,7 @@ static void mnodeUpdateDnodeEps() { int32_t totalDnodes = mnodeGetDnodesNum(); tsDnodeEpsSize = sizeof(SDnodeEps) + totalDnodes * sizeof(SDnodeEp); + free(tsDnodeEps); tsDnodeEps = calloc(1, tsDnodeEpsSize); tsDnodeEps->dnodeNum = htonl(totalDnodes); @@ -534,7 +537,10 @@ static int32_t mnodeProcessDnodeStatusMsg(SMnodeMsg *pMsg) { } int32_t openVnodes = htons(pStatus->openVnodes); - int32_t contLen = sizeof(SDMStatusRsp) + openVnodes * sizeof(SDMVgroupAccess) + mnodeGetDnodeEpsSize(); + int32_t epsSize = mnodeGetDnodeEpsSize(); + int32_t vgAccessSize = openVnodes * sizeof(SDMVgroupAccess); + int32_t contLen = sizeof(SDMStatusRsp) + vgAccessSize + epsSize; + SDMStatusRsp *pRsp = rpcMallocCont(contLen); if (pRsp == NULL) { mnodeDecDnodeRef(pDnode); @@ -596,8 +602,8 @@ static int32_t mnodeProcessDnodeStatusMsg(SMnodeMsg *pMsg) { mnodeDecDnodeRef(pDnode); - SDnodeEps *pEps = (SDnodeEps *)((char *)pAccess + openVnodes * sizeof(SDMVgroupAccess)); - mnodeGetDnodeEpsData(pEps); + SDnodeEps *pEps = (SDnodeEps *)((char *)pRsp + sizeof(SDMStatusRsp) + vgAccessSize); + mnodeGetDnodeEpsData(pEps, epsSize); pMsg->rpcRsp.len = contLen; pMsg->rpcRsp.rsp = pRsp; diff --git a/src/rpc/src/rpcMain.c b/src/rpc/src/rpcMain.c index 6e9088d9fb..680f162f70 100644 --- a/src/rpc/src/rpcMain.c +++ b/src/rpc/src/rpcMain.c @@ -323,7 +323,7 @@ void *rpcMallocCont(int contLen) { tError("failed to malloc msg, size:%d", size); return NULL; } else { - tTrace("malloc mem: %p", start); + tTrace("malloc mem:%p size:%d", start, size); } return start + sizeof(SRpcReqContext) + sizeof(SRpcHead); @@ -1453,7 +1453,7 @@ static SRpcHead *rpcDecompressRpcMsg(SRpcHead *pHead) { pNewHead->msgLen = rpcMsgLenFromCont(origLen); rpcFreeMsg(pHead); // free the compressed message buffer pHead = pNewHead; - tTrace("decomp malloc mem: %p", temp); + tTrace("decomp malloc mem:%p", temp); } else { tError("failed to allocate memory to decompress msg, contLen:%d", contLen); } diff --git a/src/rpc/src/rpcTcp.c b/src/rpc/src/rpcTcp.c index bc8d360d39..c6de398608 100644 --- a/src/rpc/src/rpcTcp.c +++ b/src/rpc/src/rpcTcp.c @@ -437,12 +437,13 @@ static int taosReadTcpData(SFdObj *pFdObj, SRecvInfo *pInfo) { } msgLen = (int32_t)htonl((uint32_t)rpcHead.msgLen); - buffer = malloc(msgLen + tsRpcOverhead); + int32_t size = msgLen + tsRpcOverhead; + buffer = malloc(size); if (NULL == buffer) { tError("%s %p TCP malloc(size:%d) fail", pThreadObj->label, pFdObj->thandle, msgLen); return -1; } else { - tTrace("TCP malloc mem: %p", buffer); + tTrace("TCP malloc mem:%p size:%d", buffer, size); } msg = buffer + tsRpcOverhead; diff --git a/src/rpc/src/rpcUdp.c b/src/rpc/src/rpcUdp.c index 6f65304661..9bac2b1c19 100644 --- a/src/rpc/src/rpcUdp.c +++ b/src/rpc/src/rpcUdp.c @@ -209,12 +209,13 @@ static void *taosRecvUdpData(void *param) { continue; } - char *tmsg = malloc(dataLen + tsRpcOverhead); + int32_t size = dataLen + tsRpcOverhead; + char *tmsg = malloc(size); if (NULL == tmsg) { tError("%s failed to allocate memory, size:%" PRId64, pConn->label, (int64_t)dataLen); continue; } else { - tTrace("UDP malloc mem: %p", tmsg); + tTrace("UDP malloc mem:%p size:%d", tmsg, size); } tmsg += tsRpcOverhead; // overhead for SRpcReqContext -- GitLab