From 9216c6fdce5dc2ed43b76cdb31a4bf43859713fa Mon Sep 17 00:00:00 2001 From: shenglian zhou Date: Thu, 27 Jan 2022 10:34:06 +0800 Subject: [PATCH] (query):fix core due to substate destruction and building hearbeat message at the same time --- src/client/src/tscProfile.c | 3 ++- src/client/src/tscUtil.c | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/client/src/tscProfile.c b/src/client/src/tscProfile.c index c682138a35..bfc3b9f0be 100644 --- a/src/client/src/tscProfile.c +++ b/src/client/src/tscProfile.c @@ -280,7 +280,7 @@ int tscBuildQueryStreamDesc(void *pMsg, STscObj *pObj) { // } else { // pQdesc->stableQuery = 0; // } - + pthread_mutex_lock(&pSql->subState.mutex); if (pSql->pSubs != NULL && pSql->subState.states != NULL) { for (int32_t i = 0; i < pQdesc->numOfSub; ++i) { SSqlObj *psub = pSql->pSubs[i]; @@ -295,6 +295,7 @@ int tscBuildQueryStreamDesc(void *pMsg, STscObj *pObj) { p += len; } } + pthread_mutex_unlock(&pSql->subState.mutex); } pQdesc->numOfSub = htonl(pQdesc->numOfSub); diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index cdea2cf748..1fd5806c79 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -4518,6 +4518,7 @@ void tscTryQueryNextClause(SSqlObj* pSql, __async_cb_func_t fp) { pRes->final = finalBk; pRes->numOfTotal = num; + pthread_mutex_lock(&pSql->subState.mutex); for(int32_t i = 0; i < pSql->subState.numOfSub; ++i) { taos_free_result(pSql->pSubs[i]); } @@ -4525,6 +4526,7 @@ void tscTryQueryNextClause(SSqlObj* pSql, __async_cb_func_t fp) { tfree(pSql->pSubs); tfree(pSql->subState.states); pSql->subState.numOfSub = 0; + pthread_mutex_unlock(&pSql->subState.mutex); pthread_mutex_destroy(&pSql->subState.mutex); pSql->fp = fp; -- GitLab