Merge pull request #12636 from taosdata/feature/qnode
fix: fix stmt memory leak
This commit is contained in:
commit
016738bb60
|
@ -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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
@ -146,6 +151,23 @@ 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);
|
||||
}
|
||||
|
||||
|
@ -2032,9 +2054,12 @@ 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue