From 16e0a12fd0237e37ed26f18b5588d288ab79d963 Mon Sep 17 00:00:00 2001 From: lihui Date: Sat, 9 May 2020 16:18:42 +0800 Subject: [PATCH] [TD-161] --- src/client/src/tscAsync.c | 11 ++++++----- src/client/src/tscUtil.c | 9 ++++++++- src/system/detail/src/vnodeRead.c | 3 +++ src/util/src/tcache.c | 2 ++ 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/client/src/tscAsync.c b/src/client/src/tscAsync.c index 34ecc25c59..cf762b9af6 100644 --- a/src/client/src/tscAsync.c +++ b/src/client/src/tscAsync.c @@ -494,6 +494,12 @@ void tscMeterMetaCallBack(void *param, TAOS_RES *res, int code) { if ((pQueryInfo->type & TSDB_QUERY_TYPE_STABLE_SUBQUERY) == TSDB_QUERY_TYPE_STABLE_SUBQUERY) { SMeterMetaInfo* pMeterMetaInfo = tscGetMeterMetaInfoFromQueryInfo(pQueryInfo, 0); + + code = tscGetMeterMeta(pSql, pMeterMetaInfo); + pRes->code = code; + + if (code == TSDB_CODE_ACTION_IN_PROGRESS) return; + assert(pMeterMetaInfo->pMeterMeta->numOfTags != 0 && pMeterMetaInfo->vnodeIndex >= 0 && pSql->param != NULL); SRetrieveSupport *trs = (SRetrieveSupport *)pSql->param; @@ -504,11 +510,6 @@ void tscMeterMetaCallBack(void *param, TAOS_RES *res, int code) { tscTrace("%p get metricMeta during super table query successfully", pSql); - code = tscGetMeterMeta(pSql, pMeterMetaInfo); - pRes->code = code; - - if (code == TSDB_CODE_ACTION_IN_PROGRESS) return; - code = tscGetMetricMeta(pSql, 0); pRes->code = code; diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index 2d86e7c4e0..77d4a95c14 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -2064,7 +2064,14 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void pMeterMetaInfo->tagColumnIndex); } - assert(pFinalInfo->pMeterMeta != NULL && pNewQueryInfo->numOfTables == 1); + if (pFinalInfo->pMeterMeta == NULL) { + tscError("%p new subquery failed for get pMeterMeta is NULL from cache", pSql); + tscFreeSqlObj(pNew); + return NULL; + } + + assert(pNewQueryInfo->numOfTables == 1); + if (UTIL_METER_IS_SUPERTABLE(pMeterMetaInfo)) { assert(pFinalInfo->pMetricMeta != NULL); } diff --git a/src/system/detail/src/vnodeRead.c b/src/system/detail/src/vnodeRead.c index 08b0b1eba6..7a92fa235b 100644 --- a/src/system/detail/src/vnodeRead.c +++ b/src/system/detail/src/vnodeRead.c @@ -496,6 +496,9 @@ void vnodeDecRefCount(void *param) { assert(vnodeIsQInfoValid(pQInfo)); int32_t ref = atomic_sub_fetch_32(&pQInfo->refCount, 1); + if (ref < 0) { + return; // avoid two threads dec ref count + } assert(ref >= 0); dTrace("QInfo:%p decrease obj refcount, %d", pQInfo, ref); diff --git a/src/util/src/tcache.c b/src/util/src/tcache.c index c042c0181f..54c6ea039c 100644 --- a/src/util/src/tcache.c +++ b/src/util/src/tcache.c @@ -587,6 +587,8 @@ void *taosAddDataIntoCache(void *handle, char *key, char *pData, int dataSize, i "size:%" PRId64 " bytes, collision:%d", pNode->key, pNode, HASH_INDEX(pNode->hashVal, pObj->capacity), pNode->addTime, pNode->time, pObj->size, pObj->totalSize, pObj->statistics.numOfCollision); + } else { + pError("key:%s failed to added into cache, out of memory", key); } } else { // old data exists, update the node pNode = taosUpdateCacheImpl(pObj, pOldNode, key, keyLen, pData, dataSize, keepTime * 1000L); -- GitLab