diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt index 97bfcfb8c039c05a4d997fb2b6adadb2a00d0b75..aba955ff3ba68fe5bef617b295330417509b9c9f 100644 --- a/contrib/CMakeLists.txt +++ b/contrib/CMakeLists.txt @@ -226,10 +226,10 @@ endif(${BUILD_WITH_NURAFT}) if(${BUILD_PTHREAD}) set(CMAKE_BUILD_TYPE release) add_definitions(-DPTW32_STATIC_LIB) - add_subdirectory(pthread) + add_subdirectory(pthread EXCLUDE_FROM_ALL) set_target_properties(libpthreadVC3 PROPERTIES OUTPUT_NAME pthread) - add_library(pthread STATIC IMPORTED GLOBAL) - SET_PROPERTY(TARGET pthread PROPERTY IMPORTED_LOCATION ${LIBRARY_OUTPUT_PATH}/pthread.lib) + add_library(pthread INTERFACE) + target_link_libraries(pthread INTERFACE libpthreadVC3) endif() # iconv diff --git a/source/client/src/clientStmt.c b/source/client/src/clientStmt.c index f2c5fdec0f3b530a453e1391eb62a5d833304018..764571e71e5f3ddf89f58183a1d7b26a73cfc79d 100644 --- a/source/client/src/clientStmt.c +++ b/source/client/src/clientStmt.c @@ -260,8 +260,8 @@ int32_t stmtCleanBindInfo(STscStmt* pStmt) { return TSDB_CODE_SUCCESS; } -int32_t stmtCleanExecInfo(STscStmt* pStmt, bool keepTable, bool freeRequest) { - if (STMT_TYPE_QUERY != pStmt->sql.type || freeRequest) { +int32_t stmtCleanExecInfo(STscStmt* pStmt, bool keepTable, bool deepClean) { + if (STMT_TYPE_QUERY != pStmt->sql.type || deepClean) { taos_free_result(pStmt->exec.pRequest); pStmt->exec.pRequest = NULL; } @@ -280,7 +280,11 @@ int32_t stmtCleanExecInfo(STscStmt* pStmt, bool keepTable, bool freeRequest) { continue; } - qFreeStmtDataBlock(pBlocks); + if (STMT_TYPE_MULTI_INSERT == pStmt->sql.type) { + qFreeStmtDataBlock(pBlocks); + } else { + qDestroyStmtDataBlock(pBlocks); + } taosHashRemove(pStmt->exec.pBlockHash, key, keyLen); pIter = taosHashIterate(pStmt->exec.pBlockHash, pIter); @@ -320,11 +324,11 @@ int32_t stmtCleanSQLInfo(STscStmt* pStmt) { taosHashCleanup(pStmt->sql.pTableCache); pStmt->sql.pTableCache = NULL; - memset(&pStmt->sql, 0, sizeof(pStmt->sql)); - STMT_ERR_RET(stmtCleanExecInfo(pStmt, false, true)); STMT_ERR_RET(stmtCleanBindInfo(pStmt)); + memset(&pStmt->sql, 0, sizeof(pStmt->sql)); + return TSDB_CODE_SUCCESS; } diff --git a/source/dnode/mgmt/node_mgmt/src/dmNodes.c b/source/dnode/mgmt/node_mgmt/src/dmNodes.c index ff9d4089cdcd4fe7d94b04b5fff51fc873d1b20f..f23db5da16559e8dea2e3b31d949310a848130de 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmNodes.c +++ b/source/dnode/mgmt/node_mgmt/src/dmNodes.c @@ -58,6 +58,7 @@ static int32_t dmNewProc(SMgmtWrapper *pWrapper, EDndNodeType ntype) { return -1; } + taosIgnSignal(SIGCHLD); pWrapper->proc.pid = pid; dInfo("node:%s, continue running in new process:%d", pWrapper->name, pid); return 0; @@ -254,7 +255,7 @@ static void dmWatchNodes(SDnode *pDnode) { if (!OnlyInParentProc(pWrapper)) continue; if (proc->pid <= 0 || !taosProcExist(proc->pid)) { - dWarn("node:%s, process:%d is killed and needs to restart", pWrapper->name, proc->pid); + dError("node:%s, process:%d is killed and needs to restart", pWrapper->name, proc->pid); dmCloseProcRpcHandles(&pWrapper->proc); dmNewProc(pWrapper, ntype); } diff --git a/source/libs/catalog/inc/catalogInt.h b/source/libs/catalog/inc/catalogInt.h index 1bf21ad7d1e48814b77564a8de64a81fcb377624..857c7088523a919671c05c15eef75debdbffc0de 100644 --- a/source/libs/catalog/inc/catalogInt.h +++ b/source/libs/catalog/inc/catalogInt.h @@ -131,6 +131,7 @@ typedef struct SCtgCacheStat { uint64_t dbNum; uint64_t tblNum; uint64_t stblNum; + uint64_t userNum; uint64_t vgHitNum; uint64_t vgMissNum; uint64_t tblHitNum; diff --git a/source/libs/catalog/src/catalog.c b/source/libs/catalog/src/catalog.c index c96ad140a18aa7a7a8275410fed866be16664aa4..d3045f68a185cd4bef1ac03ab4c278da9eae04e0 100644 --- a/source/libs/catalog/src/catalog.c +++ b/source/libs/catalog/src/catalog.c @@ -122,6 +122,11 @@ void ctgFreeDbCache(SCtgDBCache *dbCache) { ctgFreeTableMetaCache(&dbCache->tbCache); } +void ctgFreeSCtgUserAuth(SCtgUserAuth *userCache) { + taosHashCleanup(userCache->createdDbs); + taosHashCleanup(userCache->readDbs); + taosHashCleanup(userCache->writeDbs); +} void ctgFreeHandle(SCatalog* pCtg) { ctgFreeMetaRent(&pCtg->dbRent); @@ -145,7 +150,24 @@ void ctgFreeHandle(SCatalog* pCtg) { CTG_CACHE_STAT_SUB(dbNum, dbNum); } - + + if (pCtg->userCache) { + int32_t userNum = taosHashGetSize(pCtg->userCache); + + void *pIter = taosHashIterate(pCtg->userCache, NULL); + while (pIter) { + SCtgUserAuth *userCache = pIter; + + ctgFreeSCtgUserAuth(userCache); + + pIter = taosHashIterate(pCtg->userCache, pIter); + } + + taosHashCleanup(pCtg->userCache); + + CTG_CACHE_STAT_SUB(userNum, userNum); + } + taosMemoryFree(pCtg); } @@ -2031,10 +2053,13 @@ int32_t ctgGetTableMeta(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, cons SName stbName = *pTableName; strcpy(stbName.tname, output->tbName); + + taosMemoryFreeClear(output->tbMeta); CTG_ERR_JRET(ctgGetTableMetaFromCache(pCtg, &stbName, pTableMeta, &inCache, flag, NULL)); if (!inCache) { ctgDebug("stb no longer exist, dbFName:%s, tbName:%s", output->dbFName, pTableName->tname); + continue; } @@ -2306,6 +2331,8 @@ int32_t ctgActUpdateUser(SCtgMetaAction *action) { CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); } + taosMemoryFreeClear(msg); + return TSDB_CODE_SUCCESS; } diff --git a/source/libs/index/src/indexComm.c b/source/libs/index/src/indexComm.c index 74e28610372768ccaa0416f75712ab5a263f2649..8763a8ab3fcc2f3b8bdd80ac6ed4bdc4a42b6a3b 100644 --- a/source/libs/index/src/indexComm.c +++ b/source/libs/index/src/indexComm.c @@ -361,7 +361,7 @@ int32_t indexConvertDataToStr(void* src, int8_t type, void** dst) { tlen = taosEncodeBinary(NULL, varDataVal(src), varDataLen(src)); *dst = taosMemoryCalloc(1, tlen + 1); tlen = taosEncodeBinary(dst, varDataVal(src), varDataLen(src)); - *dst = *dst - tlen; + *dst = (char*) * dst - tlen; break; } case TSDB_DATA_TYPE_VARCHAR: { // TSDB_DATA_TYPE_BINARY diff --git a/source/libs/parser/src/parInsert.c b/source/libs/parser/src/parInsert.c index 01833e1776c794f8ba9ac6cecfb0ba3f1e91c1ff..29951ccdee3a818ea41029cf43f27306d30af039 100644 --- a/source/libs/parser/src/parInsert.c +++ b/source/libs/parser/src/parInsert.c @@ -1045,6 +1045,7 @@ static void destroyInsertParseContext(SInsertParseContext* pCxt) { destroyInsertParseContextForTable(pCxt); taosHashCleanup(pCxt->pVgroupsHashObj); taosHashCleanup(pCxt->pSubTableHashObj); + taosHashCleanup(pCxt->pTableNameHashObj); destroyBlockHashmap(pCxt->pTableBlockHashObj); destroyBlockArrayList(pCxt->pVgDataBlocks); diff --git a/source/libs/parser/src/parInsertData.c b/source/libs/parser/src/parInsertData.c index deb899309ebf56f6470602dacdddaf2544edfe3e..f82c792c96bb9affb839c37c7ee82358e6c84162 100644 --- a/source/libs/parser/src/parInsertData.c +++ b/source/libs/parser/src/parInsertData.c @@ -235,12 +235,12 @@ static void destroyDataBlock(STableDataBlocks* pDataBlock) { } taosMemoryFreeClear(pDataBlock->pData); - if (!pDataBlock->cloned) { +// if (!pDataBlock->cloned) { // free the refcount for metermeta taosMemoryFreeClear(pDataBlock->pTableMeta); destroyBoundColumnInfo(&pDataBlock->boundColumnInfo); - } +// } taosMemoryFreeClear(pDataBlock); } diff --git a/source/libs/scheduler/src/scheduler.c b/source/libs/scheduler/src/scheduler.c index 4fcdb35e0db5a7b958dcb3f576c75119f1c41b8c..bdf674ab9385158487a1cb55a0db1587bb0c9896 100644 --- a/source/libs/scheduler/src/scheduler.c +++ b/source/libs/scheduler/src/scheduler.c @@ -1438,24 +1438,24 @@ int32_t schHandleDropCallback(void *param, const SDataBuf *pMsg, int32_t code) { } int32_t schHandleHbCallback(void *param, const SDataBuf *pMsg, int32_t code) { + SSchedulerHbRsp rsp = {0}; + SSchTaskCallbackParam *pParam = (SSchTaskCallbackParam *)param; + if (code) { qError("hb rsp error:%s", tstrerror(code)); - SCH_ERR_RET(code); + SCH_ERR_JRET(code); } - SSchedulerHbRsp rsp = {0}; if (tDeserializeSSchedulerHbRsp(pMsg->pData, pMsg->len, &rsp)) { qError("invalid hb rsp msg, size:%d", pMsg->len); - SCH_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); + SCH_ERR_JRET(TSDB_CODE_QRY_INVALID_INPUT); } - SSchTaskCallbackParam *pParam = (SSchTaskCallbackParam *)param; - SSchTrans trans = {0}; trans.transInst = pParam->transport; trans.transHandle = pMsg->handle; - SCH_ERR_RET(schUpdateHbConnection(&rsp.epId, &trans)); + SCH_ERR_JRET(schUpdateHbConnection(&rsp.epId, &trans)); int32_t taskNum = (int32_t)taosArrayGetSize(rsp.taskStatus); qDebug("%d task status in hb rsp, nodeId:%d, fqdn:%s, port:%d", taskNum, rsp.epId.nodeId, rsp.epId.ep.fqdn, @@ -1483,6 +1483,7 @@ int32_t schHandleHbCallback(void *param, const SDataBuf *pMsg, int32_t code) { _return: tFreeSSchedulerHbRsp(&rsp); + taosMemoryFree(param); SCH_RET(code); } diff --git a/tests/script/api/batchprepare.c b/tests/script/api/batchprepare.c index 546075a1d93ff9aa94a71a80e620fa5e630cce7c..ba1cd00fcb102bf6e0fbcb29c7655a6cc0d7357a 100644 --- a/tests/script/api/batchprepare.c +++ b/tests/script/api/batchprepare.c @@ -251,16 +251,12 @@ CaseCtrl gCaseCtrl = { .bindColNum = 0, .bindTagNum = 0, .bindRowNum = 0, - .bindColTypeNum = tListLen(bindColTypeList), - .bindColTypeList = bindColTypeList, .bindTagTypeNum = 0, .bindTagTypeList = NULL, - .optrIdxListNum = tListLen(optrIdxList), - .optrIdxList = optrIdxList, .checkParamNum = false, .printRes = false, .runTimes = 0, - .caseIdx = 23, + .caseIdx = 1, .caseNum = 1, .caseRunIdx = -1, .caseRunNum = 1, @@ -1101,7 +1097,9 @@ void destroyData(BindData *data) { taosMemoryFree(data->binaryLen); taosMemoryFree(data->isNull); taosMemoryFree(data->pBind); + taosMemoryFree(data->pTags); taosMemoryFree(data->colTypes); + taosMemoryFree(data->sql); } void bpFetchRows(TAOS_RES *result, bool printr, int32_t *rows) {