From 9fc13dc750f438f11e0b9108fc5f9c993771e3a4 Mon Sep 17 00:00:00 2001 From: plum-lihui Date: Thu, 20 Jan 2022 18:14:41 +0800 Subject: [PATCH] [fix memory leak, and temp get tables of vnode into log] --- source/dnode/vnode/src/vnd/vnodeQuery.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/source/dnode/vnode/src/vnd/vnodeQuery.c b/source/dnode/vnode/src/vnd/vnodeQuery.c index 96791488fa..fb36e82dec 100644 --- a/source/dnode/vnode/src/vnd/vnodeQuery.c +++ b/source/dnode/vnode/src/vnd/vnodeQuery.c @@ -166,16 +166,26 @@ static int32_t vnodeGetTableList(SVnode *pVnode, SRpcMsg *pMsg) { char * name = NULL; int32_t totalLen = 0; + int32_t numOfTables = 0; while ((name = metaTbCursorNext(pCur)) != NULL) { - taosArrayPush(pArray, &name); - totalLen += strlen(name); + if (numOfTables < 1000) { // TODO: temp get tables of vnode, and should del when show tables commad ok. + taosArrayPush(pArray, &name); + totalLen += strlen(name); + } + numOfTables++; + } + + // TODO: temp debug, and should del when show tables command ok + vError("====vgId:%d, numOfTables: %d", pVnode->vgId, numOfTables); + if (numOfTables > 1000) { + numOfTables = 1000; } metaCloseTbCursor(pCur); int32_t rowLen = (TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE) + 8 + 2 + (TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE) + 8 + 4; - int32_t numOfTables = (int32_t)taosArrayGetSize(pArray); + //int32_t numOfTables = (int32_t)taosArrayGetSize(pArray); int32_t payloadLen = rowLen * numOfTables; // SVShowTablesFetchReq *pFetchReq = pMsg->pCont; @@ -203,5 +213,6 @@ static int32_t vnodeGetTableList(SVnode *pVnode, SRpcMsg *pMsg) { }; rpcSendResponse(&rpcMsg); + taosArrayDestroy(pArray); return 0; }