From 0066dc9ac08748cfd81c92ca7fe0c4089f4b015f Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Wed, 14 Oct 2020 12:43:45 +0800 Subject: [PATCH 1/3] [td-1716] --- src/client/src/tscSql.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/client/src/tscSql.c b/src/client/src/tscSql.c index ef8625da06..f73b4abb15 100644 --- a/src/client/src/tscSql.c +++ b/src/client/src/tscSql.c @@ -257,10 +257,21 @@ TAOS *taos_connect_a(char *ip, char *user, char *pass, char *db, uint16_t port, void taos_close(TAOS *taos) { STscObj *pObj = (STscObj *)taos; - if (pObj == NULL || pObj->signature != pObj) { + if (pObj == NULL) { + tscDebug("(null) try to free tscObj and close dnodeConn"); return; } + tscDebug("%p try to free tscObj and close dnodeConn:%p", pObj, pObj->pDnodeConn); + if (pObj->signature != pObj) { + tscDebug("%p already closed or invalid tscObj", pObj); + return; + } + + // make sure that the close connection can only be executed once. + pObj->signature = NULL; + taosTmrStopA(&(pObj->pTimer)); + SSqlObj* pHb = pObj->pHb; if (pHb != NULL && atomic_val_compare_exchange_ptr(&pObj->pHb, pHb, 0) == pHb) { if (pHb->pRpcCtx != NULL) { // wait for rsp from dnode From 2a9855bbaf52c513bcb4b028ae9b764cd2a70501 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Wed, 14 Oct 2020 13:02:23 +0800 Subject: [PATCH 2/3] [td-225] fix bugs found by tsim --- src/client/src/tscSubquery.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client/src/tscSubquery.c b/src/client/src/tscSubquery.c index fbbd810a19..abfe62c72c 100644 --- a/src/client/src/tscSubquery.c +++ b/src/client/src/tscSubquery.c @@ -258,11 +258,11 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) { assert(numOfSub > 0); // scan all subquery, if one sub query has only ts, ignore it - tscDebug("%p start to launch secondary subqueries, total:%d, only:%d needs to query", pSql, pSql->subState.numOfSub, numOfSub); + tscDebug("%p start to launch secondary subqueries, %d out of %d needs to query", pSql, numOfSub, pSql->subState.numOfSub); //the subqueries that do not actually launch the secondary query to virtual node is set as completed. SSubqueryState* pState = &pSql->subState; - pState->numOfRemain = pState->numOfSub; + pState->numOfRemain = numOfSub; bool success = true; From 4c22b72d0663b3aa9b85f2ac0efaceb31d64e00e Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Wed, 14 Oct 2020 14:31:46 +0800 Subject: [PATCH 3/3] [td-225] --- src/util/src/tcache.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/util/src/tcache.c b/src/util/src/tcache.c index 2896481574..6e20c1708d 100644 --- a/src/util/src/tcache.c +++ b/src/util/src/tcache.c @@ -558,8 +558,8 @@ void taosAddToTrashcan(SCacheObj *pCacheObj, SCacheDataNode *pNode) { pCacheObj->numOfElemsInTrash++; __cache_unlock(pCacheObj); - uDebug("cache:%s key:%p, %p move to trashcan, numOfElem in trashcan:%d", pCacheObj->name, pNode->key, pNode->data, - pCacheObj->numOfElemsInTrash); + uDebug("cache:%s key:%p, %p move to trashcan, pTrashElem:%p, numOfElem in trashcan:%d", pCacheObj->name, + pNode->key, pNode->data, pElem, pCacheObj->numOfElemsInTrash); } void taosTrashcanEmpty(SCacheObj *pCacheObj, bool force) {