Merge branch '3.0' of https://github.com/taosdata/TDengine into enh/TD-31538-6

This commit is contained in:
Hongze Cheng 2024-08-27 13:19:43 +08:00
commit 72bd7742b4
22 changed files with 137 additions and 60 deletions

View File

@ -1051,6 +1051,10 @@ static int32_t createResultBlock(TAOS_RES* pRes, int32_t numOfRows, SSDataBlock*
for (int32_t i = 0; i < numOfRows; ++i) {
TAOS_ROW pRow = taos_fetch_row(pRes);
if(NULL == pRow[0] || NULL == pRow[1] || NULL == pRow[2]) {
tscError("invalid data from vnode");
return TSDB_CODE_TSC_INTERNAL_ERROR;
}
int64_t ts = *(int64_t*)pRow[0];
if (lastTs < ts) {
lastTs = ts;

View File

@ -57,7 +57,11 @@ void vmGetVnodeLoadsLite(SVnodeMgmt *pMgmt, SMonVloadInfo *pInfo) {
if (!pVnode->failed) {
SVnodeLoadLite vload = {0};
if (vnodeGetLoadLite(pVnode->pImpl, &vload) == 0) {
(void)taosArrayPush(pInfo->pVloads, &vload);
if (taosArrayPush(pInfo->pVloads, &vload) == NULL) {
taosArrayDestroy(pInfo->pVloads);
pInfo->pVloads = NULL;
break;
}
}
}
pIter = taosHashIterate(pMgmt->hash, pIter);
@ -841,6 +845,9 @@ int32_t vmProcessArbHeartBeatReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
arbHbRsp.dnodeId = pMgmt->pData->dnodeId;
strncpy(arbHbRsp.arbToken, arbHbReq.arbToken, TSDB_ARB_TOKEN_SIZE);
arbHbRsp.hbMembers = taosArrayInit(size, sizeof(SVArbHbRspMember));
if (arbHbRsp.hbMembers == NULL) {
goto _OVER;
}
for (int32_t i = 0; i < size; i++) {
SVArbHbReqMember *pReqMember = taosArrayGet(arbHbReq.hbMembers, i);
@ -865,7 +872,11 @@ int32_t vmProcessArbHeartBeatReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
continue;
}
(void)taosArrayPush(arbHbRsp.hbMembers, &rspMember);
if (taosArrayPush(arbHbRsp.hbMembers, &rspMember) == NULL) {
dError("dnodeId:%d vgId:%d failed to push arb hb rsp member", arbHbReq.dnodeId, pReqMember->vgId);
vmReleaseVnode(pMgmt, pVnode);
goto _OVER;
}
vmReleaseVnode(pMgmt, pVnode);
}

View File

@ -256,7 +256,9 @@ _OVER:
SDnodeEp dnodeEp = {0};
dnodeEp.isMnode = 1;
(void)taosGetFqdnPortFromEp(tsFirst, &dnodeEp.ep);
(void)taosArrayPush(pData->dnodeEps, &dnodeEp);
if (taosArrayPush(pData->dnodeEps, &dnodeEp) == NULL) {
return terrno;
}
}
if ((code = dmReadDnodePairs(pData)) != 0) {
@ -398,7 +400,11 @@ static void dmResetEps(SDnodeData *pData, SArray *dnodeEps) {
for (int32_t i = 0; i < numOfEps; i++) {
SDnodeEp *pDnodeEp = taosArrayGet(dnodeEps, i);
(void)taosHashPut(pData->dnodeHash, &pDnodeEp->id, sizeof(int32_t), pDnodeEp, sizeof(SDnodeEp));
int32_t code = taosHashPut(pData->dnodeHash, &pDnodeEp->id, sizeof(int32_t), pDnodeEp, sizeof(SDnodeEp));
if (code) {
dError("dnode:%d, fqdn:%s port:%u isMnode:%d failed to put into hash, reason:%s", pDnodeEp->id, pDnodeEp->ep.fqdn,
pDnodeEp->ep.port, pDnodeEp->isMnode, tstrerror(code));
}
}
pData->validMnodeEps = true;

View File

@ -156,7 +156,7 @@ int metaDropSTable(SMeta* pMeta, int64_t verison, SVDropStbReq* pReq
int metaCreateTable(SMeta* pMeta, int64_t version, SVCreateTbReq* pReq, STableMetaRsp** pMetaRsp);
int metaDropTable(SMeta* pMeta, int64_t version, SVDropTbReq* pReq, SArray* tbUids, int64_t* tbUid);
int32_t metaTrimTables(SMeta* pMeta);
void metaDropTables(SMeta* pMeta, SArray* tbUids);
int32_t metaDropTables(SMeta* pMeta, SArray* tbUids);
int metaTtlFindExpired(SMeta* pMeta, int64_t timePointMs, SArray* tbUids, int32_t ttlDropMaxCount);
int metaAlterTable(SMeta* pMeta, int64_t version, SVAlterTbReq* pReq, STableMetaRsp* pMetaRsp);
int metaUpdateChangeTimeWithLock(SMeta* pMeta, tb_uid_t uid, int64_t changeTimeMs);
@ -435,9 +435,9 @@ typedef struct SVCommitSched {
} SVCommitSched;
typedef struct SVMonitorObj {
char strClusterId[TSDB_CLUSTER_ID_LEN];
char strDnodeId[TSDB_NODE_ID_LEN];
char strVgId[TSDB_VGROUP_ID_LEN];
char strClusterId[TSDB_CLUSTER_ID_LEN];
char strDnodeId[TSDB_NODE_ID_LEN];
char strVgId[TSDB_VGROUP_ID_LEN];
} SVMonitorObj;
typedef struct {

View File

@ -1486,7 +1486,12 @@ int32_t metaGetTableTags(void *pVnode, uint64_t suid, SArray *pUidTagInfo) {
taosHashInit(numOfElems / 0.7, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
for (int i = 0; i < numOfElems; i++) {
STUidTagInfo *pTagInfo = taosArrayGet(pUidTagInfo, i);
(void)taosHashPut(pSepecifiedUidMap, &pTagInfo->uid, sizeof(uint64_t), &i, sizeof(int32_t));
int32_t code = taosHashPut(pSepecifiedUidMap, &pTagInfo->uid, sizeof(uint64_t), &i, sizeof(int32_t));
if (code) {
metaCloseCtbCursor(pCur);
taosHashCleanup(pSepecifiedUidMap);
return code;
}
}
}

View File

@ -381,7 +381,11 @@ int metaDropSTable(SMeta *pMeta, int64_t verison, SVDropStbReq *pReq, SArray *tb
break;
}
(void)taosArrayPush(tbUidList, &(((SCtbIdxKey *)pKey)->uid));
if (taosArrayPush(tbUidList, &(((SCtbIdxKey *)pKey)->uid)) == NULL) {
tdbFree(pKey);
(void)tdbTbcClose(pCtbIdxc);
return terrno;
}
}
(void)tdbTbcClose(pCtbIdxc);
@ -505,7 +509,11 @@ int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
return terrno = TSDB_CODE_TDB_STB_NOT_EXIST;
}
oStbEntry.pBuf = taosMemoryMalloc(nData);
if ((oStbEntry.pBuf = taosMemoryMalloc(nData)) == NULL) {
(void)tdbTbcClose(pTbDbc);
(void)tdbTbcClose(pUidIdxc);
return terrno;
}
memcpy(oStbEntry.pBuf, pData, nData);
tDecoderInit(&dc, oStbEntry.pBuf, nData);
(void)metaDecodeEntry(&dc, &oStbEntry);
@ -527,6 +535,13 @@ int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
if (!TSDB_CACHE_NO(pMeta->pVnode->config)) {
STsdb *pTsdb = pMeta->pVnode->pTsdb;
SArray *uids = taosArrayInit(8, sizeof(int64_t));
if (uids == NULL) {
if (oStbEntry.pBuf) taosMemoryFree(oStbEntry.pBuf);
tDecoderClear(&dc);
(void)tdbTbcClose(pTbDbc);
(void)tdbTbcClose(pUidIdxc);
return terrno;
}
if (deltaCol == 1) {
int16_t cid = pReq->schemaRow.pSchema[nCols - 1].colId;
int8_t col_type = pReq->schemaRow.pSchema[nCols - 1].type;
@ -1108,7 +1123,10 @@ int metaDropTable(SMeta *pMeta, int64_t version, SVDropTbReq *pReq, SArray *tbUi
}
if ((type == TSDB_CHILD_TABLE || type == TSDB_NORMAL_TABLE) && tbUids) {
(void)taosArrayPush(tbUids, &uid);
if (taosArrayPush(tbUids, &uid) == NULL) {
rc = terrno;
goto _exit;
}
if (!TSDB_CACHE_NO(pMeta->pVnode->config)) {
(void)tsdbCacheDropTable(pMeta->pVnode->pTsdb, uid, suid, NULL);
@ -1125,11 +1143,15 @@ _exit:
return rc;
}
void metaDropTables(SMeta *pMeta, SArray *tbUids) {
if (taosArrayGetSize(tbUids) == 0) return;
int32_t metaDropTables(SMeta *pMeta, SArray *tbUids) {
int32_t code = 0;
if (taosArrayGetSize(tbUids) == 0) return TSDB_CODE_SUCCESS;
int64_t nCtbDropped = 0;
SSHashObj *suidHash = tSimpleHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT));
if (suidHash == NULL) {
return terrno;
}
metaWLock(pMeta);
for (int i = 0; i < taosArrayGetSize(tbUids); ++i) {
@ -1137,7 +1159,8 @@ void metaDropTables(SMeta *pMeta, SArray *tbUids) {
tb_uid_t suid = 0;
int8_t sysTbl = 0;
int type;
(void)metaDropTableByUid(pMeta, uid, &type, &suid, &sysTbl);
code = metaDropTableByUid(pMeta, uid, &type, &suid, &sysTbl);
if (code) return code;
if (!sysTbl && type == TSDB_CHILD_TABLE && suid != 0 && suidHash) {
int64_t *pVal = tSimpleHashGet(suidHash, &suid, sizeof(tb_uid_t));
if (pVal) {
@ -1145,7 +1168,8 @@ void metaDropTables(SMeta *pMeta, SArray *tbUids) {
} else {
nCtbDropped = 1;
}
(void)tSimpleHashPut(suidHash, &suid, sizeof(tb_uid_t), &nCtbDropped, sizeof(int64_t));
code = tSimpleHashPut(suidHash, &suid, sizeof(tb_uid_t), &nCtbDropped, sizeof(int64_t));
if (code) return code;
}
/*
if (!TSDB_CACHE_NO(pMeta->pVnode->config)) {
@ -1170,6 +1194,7 @@ void metaDropTables(SMeta *pMeta, SArray *tbUids) {
tSimpleHashCleanup(suidHash);
pMeta->changed = true;
return 0;
}
static int32_t metaFilterTableByHash(SMeta *pMeta, SArray *uidList) {
@ -1210,7 +1235,10 @@ static int32_t metaFilterTableByHash(SMeta *pMeta, SArray *uidList) {
tbFName[TSDB_TABLE_FNAME_LEN] = '\0';
int32_t ret = vnodeValidateTableHash(pMeta->pVnode, tbFName);
if (ret < 0 && terrno == TSDB_CODE_VND_HASH_MISMATCH) {
(void)taosArrayPush(uidList, &me.uid);
if (taosArrayPush(uidList, &me.uid) == NULL) {
code = terrno;
break;
}
}
}
tDecoderClear(&dc);
@ -1239,7 +1267,8 @@ int32_t metaTrimTables(SMeta *pMeta) {
}
metaInfo("vgId:%d, trim %ld tables", TD_VID(pMeta->pVnode), taosArrayGetSize(tbUids));
metaDropTables(pMeta, tbUids);
code = metaDropTables(pMeta, tbUids);
if (code) goto end;
end:
taosArrayDestroy(tbUids);
@ -1867,11 +1896,19 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
} else {
memcpy(&val.i64, pAlterTbReq->pTagVal, pAlterTbReq->nTagVal);
}
(void)taosArrayPush(pTagArray, &val);
if (taosArrayPush(pTagArray, &val) == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
taosArrayDestroy(pTagArray);
goto _err;
}
} else {
STagVal val = {.cid = pCol->colId};
if (tTagGet(pOldTag, &val)) {
(void)taosArrayPush(pTagArray, &val);
if (taosArrayPush(pTagArray, &val) == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
taosArrayDestroy(pTagArray);
goto _err;
}
}
}
}
@ -2238,6 +2275,9 @@ static int metaDropTagIndex(SMeta *pMeta, int64_t version, SVAlterTbReq *pAlterT
}
SArray *tagIdxList = taosArrayInit(512, sizeof(SMetaPair));
if (tagIdxList == NULL) {
goto _err;
}
TBC *pTagIdxc = NULL;
TAOS_CHECK_RETURN(tdbTbcOpen(pMeta->pTagIdx, &pTagIdxc, NULL));
@ -2255,7 +2295,9 @@ static int metaDropTagIndex(SMeta *pMeta, int64_t version, SVAlterTbReq *pAlterT
}
SMetaPair pair = {.key = pKey, nKey = nKey};
(void)taosArrayPush(tagIdxList, &pair);
if (taosArrayPush(tagIdxList, &pair) == NULL) {
goto _err;
}
}
(void)tdbTbcClose(pTagIdxc);
@ -2797,7 +2839,14 @@ int32_t metaGetColCmpr(SMeta *pMeta, tb_uid_t uid, SHashObj **ppColCmprObj) {
SColCmprWrapper *p = &e.colCmpr;
for (int32_t i = 0; i < p->nCols; i++) {
SColCmpr *pCmpr = &p->pColCmpr[i];
(void)taosHashPut(pColCmprObj, &pCmpr->id, sizeof(pCmpr->id), &pCmpr->alg, sizeof(pCmpr->alg));
rc = taosHashPut(pColCmprObj, &pCmpr->id, sizeof(pCmpr->id), &pCmpr->alg, sizeof(pCmpr->alg));
if (rc < 0) {
tDecoderClear(&dc);
tdbFree(pData);
metaULock(pMeta);
taosHashClear(pColCmprObj);
return rc;
}
}
} else {
tDecoderClear(&dc);

View File

@ -960,7 +960,9 @@ static int32_t vnodeProcessDropTtlTbReq(SVnode *pVnode, int64_t ver, void *pReq,
}
if (ttlReq.nUids > 0) {
metaDropTables(pVnode->pMeta, ttlReq.pTbUids);
int32_t code = metaDropTables(pVnode->pMeta, ttlReq.pTbUids);
if (code) return code;
(void)tqUpdateTbUidList(pVnode->pTq, ttlReq.pTbUids, false);
}

View File

@ -14,8 +14,6 @@
* limitations under the License.
*/
#include <assert.h>
#ifndef TAOS_TEST_H
#define TAOS_TEST_H

View File

@ -22,7 +22,7 @@
#include "taos_collector_registry.h"
// Private
#include "taos_assert.h"
#include "taos_test.h"
#include "taos_collector_t.h"
#include "taos_log.h"
#include "taos_map_i.h"

View File

@ -24,7 +24,7 @@
#include "taos_collector_registry.h"
// Private
#include "taos_assert.h"
#include "taos_test.h"
#include "taos_collector_registry_t.h"
#include "taos_collector_t.h"
#include "taos_errors.h"

View File

@ -20,7 +20,7 @@
#include "taos_alloc.h"
// Private
#include "taos_assert.h"
#include "taos_test.h"
#include "taos_errors.h"
#include "taos_log.h"
#include "taos_metric_i.h"

View File

@ -20,7 +20,7 @@
#include "taos_alloc.h"
// Private
#include "taos_assert.h"
#include "taos_test.h"
#include "taos_errors.h"
#include "taos_log.h"
#include "taos_metric_i.h"

View File

@ -18,7 +18,7 @@
#include "taos_alloc.h"
// Private
#include "taos_assert.h"
#include "taos_test.h"
#include "taos_linked_list_i.h"
#include "taos_linked_list_t.h"
#include "taos_log.h"

View File

@ -21,13 +21,13 @@
#include "taos_alloc.h"
// Private
#include "taos_assert.h"
#include "taos_errors.h"
#include "taos_linked_list_i.h"
#include "taos_linked_list_t.h"
#include "taos_log.h"
#include "taos_map_i.h"
#include "taos_map_t.h"
#include "taos_test.h"
#define TAOS_MAP_INITIAL_SIZE 32

View File

@ -20,13 +20,13 @@
#include "taos_alloc.h"
// Private
#include "taos_assert.h"
#include "taos_errors.h"
#include "taos_log.h"
#include "taos_map_i.h"
#include "taos_metric_formatter_i.h"
#include "taos_metric_i.h"
#include "taos_metric_sample_i.h"
#include "taos_test.h"
char *taos_metric_type_map[4] = {"counter", "gauge", "histogram", "summary"};

View File

@ -20,7 +20,6 @@
#include "taos_alloc.h"
// Private
#include "taos_assert.h"
#include "taos_collector_t.h"
#include "taos_linked_list_t.h"
#include "taos_map_i.h"
@ -28,7 +27,7 @@
#include "taos_metric_sample_t.h"
#include "taos_metric_t.h"
#include "taos_string_builder_i.h"
#include "taos_test.h"
taos_metric_formatter_t *taos_metric_formatter_new() {
taos_metric_formatter_t *self = (taos_metric_formatter_t *)taos_malloc(sizeof(taos_metric_formatter_t));

View File

@ -21,7 +21,7 @@
#include "taos_metric_sample_t.h"
#include "tjson.h"
#include "taos_monitor_util_i.h"
#include "taos_assert.h"
#include "taos_test.h"
#include "tdef.h"
#include "taos_collector_t.h"
#include "taos_log.h"

View File

@ -20,11 +20,11 @@
#include "taos_alloc.h"
// Private
#include "taos_assert.h"
#include "taos_errors.h"
#include "taos_log.h"
#include "taos_metric_sample_i.h"
#include "taos_metric_sample_t.h"
#include "taos_test.h"
#ifdef C11_ATOMIC
#include <stdatomic.h>

View File

@ -20,9 +20,9 @@
#include "taos_alloc.h"
// Private
#include "taos_assert.h"
#include "taos_string_builder_i.h"
#include "taos_string_builder_t.h"
#include "taos_test.h"
// The initial size of a string created via taos_string_builder
#define TAOS_STRING_BUILDER_INIT_SIZE 32

View File

@ -464,7 +464,7 @@ struct SFilterInfo {
(colInfo).type = RANGE_TYPE_UNIT; \
(colInfo).dataType = FILTER_UNIT_DATA_TYPE(u); \
if (taosArrayPush((SArray *)((colInfo).info), &u) == NULL) { \
FLT_ERR_RET(terrno); \
FLT_ERR_JRET(terrno); \
} \
} while (0)
#define FILTER_PUSH_VAR_HASH(colInfo, ha) \
@ -482,7 +482,7 @@ struct SFilterInfo {
do { \
*(dst) = taosMemoryMalloc(sizeof(uint32_t) * n); \
if (NULL == *(dst)) { \
FLT_ERR_JRET(terrno); \
FLT_ERR_JRET(terrno); \
} \
(void)memcpy(*(dst), src, sizeof(uint32_t) * n); \
} while (0)

View File

@ -2446,8 +2446,7 @@ int32_t filterMergeGroupUnits(SFilterInfo *info, SFilterGroupCtx **gRes, int32_t
}
gRes[gResIdx]->colInfo = taosMemoryCalloc(info->fields[FLD_TYPE_COLUMN].num, sizeof(SFilterColInfo));
if (gRes[gResIdx]->colInfo == NULL) {
filterFreeGroupCtx(gRes[gResIdx]);
FLT_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
FLT_ERR_JRET(terrno);
}
colIdxi = 0;
empty = false;
@ -2459,7 +2458,6 @@ int32_t filterMergeGroupUnits(SFilterInfo *info, SFilterGroupCtx **gRes, int32_t
if (gRes[gResIdx]->colInfo[cidx].info == NULL) {
gRes[gResIdx]->colInfo[cidx].info = (SArray *)taosArrayInit(4, POINTER_BYTES);
if (gRes[gResIdx]->colInfo[cidx].info == NULL) {
filterFreeGroupCtx(gRes[gResIdx]);
FLT_ERR_JRET(terrno);
}
colIdx[colIdxi++] = cidx;
@ -2476,7 +2474,6 @@ int32_t filterMergeGroupUnits(SFilterInfo *info, SFilterGroupCtx **gRes, int32_t
if (colIdxi > 1) {
__compar_fn_t cmpFn = getComparFunc(TSDB_DATA_TYPE_USMALLINT, 0);
if (cmpFn == NULL) {
filterFreeGroupCtx(gRes[gResIdx]);
FLT_ERR_JRET(terrno);
}
taosSort(colIdx, colIdxi, sizeof(uint32_t), cmpFn);
@ -2488,12 +2485,7 @@ int32_t filterMergeGroupUnits(SFilterInfo *info, SFilterGroupCtx **gRes, int32_t
if (FILTER_NO_MERGE_DATA_TYPE(type)) {
continue;
}
code = filterMergeUnits(info, gRes[gResIdx], colIdx[l], &empty);
if (TSDB_CODE_SUCCESS != code) {
filterFreeGroupCtx(gRes[gResIdx]);
SCL_ERR_JRET(code);
}
SCL_ERR_JRET(filterMergeUnits(info, gRes[gResIdx], colIdx[l], &empty));
if (empty) {
break;
@ -2519,6 +2511,9 @@ int32_t filterMergeGroupUnits(SFilterInfo *info, SFilterGroupCtx **gRes, int32_t
}
_return:
if (code) {
filterFreeGroupCtx(gRes[gResIdx]);
}
taosMemoryFreeClear(colIdx);
FLT_RET(code);
}

View File

@ -154,6 +154,10 @@ static void *taosCacheTimedRefresh(void *handle);
static void doInitRefreshThread(void) {
pCacheArrayList = taosArrayInit(4, POINTER_BYTES);
if (pCacheArrayList == NULL) {
uError("failed to allocate memory, reason:%s", strerror(errno));
return;
}
(void)taosThreadMutexInit(&guard, NULL);
@ -169,7 +173,11 @@ TdThread doRegisterCacheObj(SCacheObj *pCacheObj) {
(void)taosThreadOnce(&cacheThreadInit, doInitRefreshThread);
(void)taosThreadMutexLock(&guard);
(void)taosArrayPush(pCacheArrayList, &pCacheObj);
if (taosArrayPush(pCacheArrayList, &pCacheObj) != 0) {
uError("failed to add cache object into array, reason:%s", strerror(errno));
(void)taosThreadMutexUnlock(&guard);
return cacheRefreshWorker;
}
(void)taosThreadMutexUnlock(&guard);
return cacheRefreshWorker;
@ -262,7 +270,7 @@ static void pushfrontNodeInEntryList(SCacheEntry *pEntry, SCacheNode *pNode) {
pNode->pNext = pEntry->next;
pEntry->next = pNode;
pEntry->num += 1;
//A S S E R T((pEntry->next && pEntry->num > 0) || (NULL == pEntry->next && pEntry->num == 0));
// A S S E R T((pEntry->next && pEntry->num > 0) || (NULL == pEntry->next && pEntry->num == 0));
}
static void removeNodeInEntryList(SCacheEntry *pe, SCacheNode *prev, SCacheNode *pNode) {
@ -274,7 +282,7 @@ static void removeNodeInEntryList(SCacheEntry *pe, SCacheNode *prev, SCacheNode
pNode->pNext = NULL;
pe->num -= 1;
//A S S E R T((pe->next && pe->num > 0) || (NULL == pe->next && pe->num == 0));
// A S S E R T((pe->next && pe->num > 0) || (NULL == pe->next && pe->num == 0));
}
static FORCE_INLINE SCacheEntry *doFindEntry(SCacheObj *pCacheObj, const void *key, size_t keyLen) {
@ -499,7 +507,7 @@ void *taosCacheAcquireByData(SCacheObj *pCacheObj, void *data) {
uDebug("cache:%s, data: %p acquired by data in cache, refcnt:%d", pCacheObj->name, ptNode->data, ref);
// the data if referenced by at least one object, so the reference count must be greater than the value of 2.
//A S S E R T(ref >= 2);
// A S S E R T(ref >= 2);
return data;
}
@ -574,19 +582,19 @@ void taosCacheRelease(SCacheObj *pCacheObj, void **data, bool _remove) {
if (ref == 1) {
// If it is the last ref, remove it from trashcan linked-list first, and then destroy it.Otherwise, it may be
// destroyed by refresh worker if decrease ref count before removing it from linked-list.
//A S S E R T(pNode->pTNodeHeader->pData == pNode);
// A S S E R T(pNode->pTNodeHeader->pData == pNode);
__trashcan_wr_lock(pCacheObj);
(void)doRemoveElemInTrashcan(pCacheObj, pNode->pTNodeHeader);
__trashcan_unlock(pCacheObj);
ref = T_REF_DEC(pNode);
//A S S E R T(ref == 0);
// A S S E R T(ref == 0);
doDestroyTrashcanElem(pCacheObj, pNode->pTNodeHeader);
} else {
ref = T_REF_DEC(pNode);
//A S S E R T(ref >= 0);
// A S S E R T(ref >= 0);
}
} else {
// NOTE: remove it from hash in the first place, otherwise, the pNode may have been released by other thread
@ -608,7 +616,7 @@ void taosCacheRelease(SCacheObj *pCacheObj, void **data, bool _remove) {
"others already, prev must in trashcan",
pCacheObj->name, pNode->key, p->data, T_REF_VAL_GET(p), pNode->data, T_REF_VAL_GET(pNode));
//A S S E R T(p->pTNodeHeader == NULL && pNode->pTNodeHeader != NULL);
// A S S E R T(p->pTNodeHeader == NULL && pNode->pTNodeHeader != NULL);
} else {
removeNodeInEntryList(pe, prev, p);
uDebug("cache:%s, key:%p, %p successfully removed from hash table, refcnt:%d", pCacheObj->name, pNode->key,
@ -668,7 +676,7 @@ void doTraverseElems(SCacheObj *pCacheObj, bool (*fp)(void *param, SCacheNode *p
} else {
*pPre = next;
pEntry->num -= 1;
//A S S E R T((pEntry->next && pEntry->num > 0) || (NULL == pEntry->next && pEntry->num == 0));
// A S S E R T((pEntry->next && pEntry->num > 0) || (NULL == pEntry->next && pEntry->num == 0));
(void)atomic_sub_fetch_ptr(&pCacheObj->numOfElems, 1);
pNode = next;
@ -734,7 +742,7 @@ SCacheNode *taosCreateCacheNode(const char *key, size_t keyLen, const char *pDat
void taosAddToTrashcan(SCacheObj *pCacheObj, SCacheNode *pNode) {
if (pNode->inTrashcan) { /* node is already in trash */
//A S S E R T(pNode->pTNodeHeader != NULL && pNode->pTNodeHeader->pData == pNode);
// A S S E R T(pNode->pTNodeHeader != NULL && pNode->pTNodeHeader->pData == pNode);
return;
}
@ -780,7 +788,7 @@ void taosTrashcanEmpty(SCacheObj *pCacheObj, bool force) {
STrashElem *pElem = pCacheObj->pTrash;
while (pElem) {
T_REF_VAL_CHECK(pElem->pData);
//A S S E R T(pElem->next != pElem && pElem->prev != pElem);
// A S S E R T(pElem->next != pElem && pElem->prev != pElem);
if (force || (T_REF_VAL_GET(pElem->pData) == 0)) {
uDebug("cache:%s, key:%p, %p removed from trashcan. numOfElem in trashcan:%d", pCacheObj->name, pElem->pData->key,