Merge pull request #2056 from taosdata/hotfix/freesqlobj
[td-430] fix bug while client does not retrieve or paritally retrieve…
This commit is contained in:
commit
18bf8f6db3
|
@ -217,10 +217,12 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcIpSet *pIpSet) {
|
|||
STscObj *pObj = pSql->pTscObj;
|
||||
// tscTrace("%p msg:%s is received from server", pSql, taosMsg[rpcMsg->msgType]);
|
||||
|
||||
if (pSql->freed || pObj->signature != pObj) {
|
||||
if (pObj->signature != pObj) {
|
||||
tscTrace("%p sql is already released or DB connection is closed, freed:%d pObj:%p signature:%p", pSql, pSql->freed,
|
||||
pObj, pObj->signature);
|
||||
tscFreeSqlObj(pSql);
|
||||
if (pSql != pObj->pSql) {
|
||||
tscFreeSqlObj(pSql);
|
||||
}
|
||||
rpcFreeCont(rpcMsg->pCont);
|
||||
return;
|
||||
}
|
||||
|
@ -1867,8 +1869,8 @@ int tscProcessTableMetaRsp(SSqlObj *pSql) {
|
|||
return TSDB_CODE_CLI_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
free(pTableMeta);
|
||||
tscTrace("%p recv table meta: %"PRId64 ", tid:%d, name:%s", pSql, pTableMeta->uid, pTableMeta->sid, pTableMetaInfo->name);
|
||||
free(pTableMeta);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -576,26 +576,22 @@ void taos_free_result_imp(TAOS_RES *res, int keepCmd) {
|
|||
* for each subquery. Because the failure of execution tsProcessSql may trigger the callback function
|
||||
* be executed, and the retry efforts may result in double free the resources, e.g.,SRetrieveSupport
|
||||
*/
|
||||
if ((pCmd->command == TSDB_SQL_SELECT || pCmd->command == TSDB_SQL_SHOW || pCmd->command == TSDB_SQL_RETRIEVE ||
|
||||
pCmd->command == TSDB_SQL_FETCH) &&
|
||||
(pRes->code != TSDB_CODE_QUERY_CANCELLED && ((pRes->numOfRows > 0 && pCmd->command < TSDB_SQL_LOCAL && pRes->completed == false) ||
|
||||
(pRes->code == TSDB_CODE_SUCCESS && pRes->numOfRows == 0 && pCmd->command == TSDB_SQL_SELECT &&
|
||||
pSql->pStream == NULL && pTableMetaInfo->pTableMeta != NULL)))) {
|
||||
if ((pCmd->command == TSDB_SQL_SELECT ||
|
||||
pCmd->command == TSDB_SQL_SHOW ||
|
||||
pCmd->command == TSDB_SQL_RETRIEVE ||
|
||||
pCmd->command == TSDB_SQL_FETCH) &&
|
||||
(pRes->code != TSDB_CODE_QUERY_CANCELLED && ((pCmd->command < TSDB_SQL_LOCAL && pRes->completed == false) ||
|
||||
(pRes->code == TSDB_CODE_SUCCESS && pCmd->command == TSDB_SQL_SELECT && pSql->pStream == NULL && pTableMetaInfo->pTableMeta != NULL)))) {
|
||||
pCmd->command = (pCmd->command > TSDB_SQL_MGMT) ? TSDB_SQL_RETRIEVE : TSDB_SQL_FETCH;
|
||||
|
||||
tscTrace("%p code:%d, numOfRows:%d, command:%d", pSql, pRes->code, pRes->numOfRows, pCmd->command);
|
||||
tscTrace("%p send msg to free qhandle in vnode, code:%d, numOfRows:%d, command:%s", pSql, pRes->code, pRes->numOfRows,
|
||||
sqlCmd[pCmd->command]);
|
||||
|
||||
pSql->freed = 1;
|
||||
tscProcessSql(pSql);
|
||||
|
||||
/*
|
||||
* If release connection msg is sent to vnode, the corresponding SqlObj for async query can not be freed instantly,
|
||||
* since its free operation is delegated to callback function, which is tscProcessMsgFromServer.
|
||||
*/
|
||||
STscObj* pObj = pSql->pTscObj;
|
||||
if (pObj->pSql == pSql) {
|
||||
pObj->pSql = NULL;
|
||||
}
|
||||
// waits for response and then goes on
|
||||
sem_wait(&pSql->rspSem);
|
||||
} else { // if no free resource msg is sent to vnode, we free this object immediately.
|
||||
STscObj* pTscObj = pSql->pTscObj;
|
||||
|
||||
|
|
|
@ -423,6 +423,8 @@ void tscFreeSqlObj(SSqlObj* pSql) {
|
|||
tfree(pCmd->payload);
|
||||
|
||||
pCmd->allocSize = 0;
|
||||
|
||||
tfree(pSql->sqlstr);
|
||||
free(pSql);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue