[vnode] Fix a few error handling as well as memory leak

1. Fix error handling in vnodeProcessQueryMsg() where qCreateQueryInfo()
fails.
2. Inside qCreateQueryInfo(), cleanup pQInfo upon failure, also add a
missing goto statement.
This commit is contained in:
yifan hao 2020-05-06 22:06:17 -06:00
parent 5f132980e8
commit f38f691796
2 changed files with 159 additions and 150 deletions

View File

@ -6131,6 +6131,7 @@ int32_t qCreateQueryInfo(void *tsdb, int32_t vgId, SQueryTableMsg *pQueryMsg, qi
(*pQInfo) = createQInfoImpl(pQueryMsg, pGroupbyExpr, pExprs, &groupInfo, pTagColumnInfo);
if ((*pQInfo) == NULL) {
code = TSDB_CODE_SERV_OUT_OF_MEMORY;
goto _query_over;
}
code = initQInfo(pQueryMsg, tsdb, vgId, *pQInfo, isSTableQuery);
@ -6140,6 +6141,11 @@ _query_over:
tfree(tbnameCond);
taosArrayDestroy(pTableIdList);
if (code != TSDB_CODE_SUCCESS) {
tfree(*pQInfo);
*pQInfo = NULL;
}
// if failed to add ref for all meters in this query, abort current query
// atomic_fetch_add_32(&vnodeSelectReqNum, 1);
return code;

View File

@ -67,11 +67,14 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, void *pCont, int32_t cont
dTrace("pVnode:%p vgId:%d QInfo:%p, dnode query msg disposed", pVnode, pVnode->vgId, pQInfo);
} else {
assert(pCont != NULL);
pQInfo = pCont;
code = TSDB_CODE_ACTION_IN_PROGRESS;
}
qTableQuery(pQInfo); // do execute query
if (pQInfo != NULL) {
qTableQuery(pQInfo); // do execute query
}
return code;
}