fix(meta/assert/cleanup): remove asserts
This commit is contained in:
parent
a42a85e291
commit
f608481ffb
|
@ -55,9 +55,9 @@ struct SMetaCache {
|
|||
// query cache
|
||||
struct STagFilterResCache {
|
||||
TdThreadMutex lock;
|
||||
SHashObj* pTableEntry;
|
||||
SLRUCache* pUidResCache;
|
||||
uint64_t keyBuf[3];
|
||||
SHashObj* pTableEntry;
|
||||
SLRUCache* pUidResCache;
|
||||
uint64_t keyBuf[3];
|
||||
} sTagFilterResCache;
|
||||
};
|
||||
|
||||
|
@ -211,7 +211,7 @@ _exit:
|
|||
int32_t metaCacheUpsert(SMeta* pMeta, SMetaInfo* pInfo) {
|
||||
int32_t code = 0;
|
||||
|
||||
// ASSERT(metaIsWLocked(pMeta));
|
||||
// meta is wlocked for calling this func.
|
||||
|
||||
// search
|
||||
SMetaCache* pCache = pMeta->pCache;
|
||||
|
@ -222,7 +222,10 @@ int32_t metaCacheUpsert(SMeta* pMeta, SMetaInfo* pInfo) {
|
|||
}
|
||||
|
||||
if (*ppEntry) { // update
|
||||
ASSERT(pInfo->suid == (*ppEntry)->info.suid);
|
||||
if (pInfo->suid != (*ppEntry)->info.suid) {
|
||||
metaError("meta/cache: suid should be same as the one in cache.");
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
if (pInfo->version > (*ppEntry)->info.version) {
|
||||
(*ppEntry)->info.version = pInfo->version;
|
||||
(*ppEntry)->info.skmVer = pInfo->skmVer;
|
||||
|
@ -341,7 +344,7 @@ _exit:
|
|||
int32_t metaStatsCacheUpsert(SMeta* pMeta, SMetaStbStats* pInfo) {
|
||||
int32_t code = 0;
|
||||
|
||||
// ASSERT(metaIsWLocked(pMeta));
|
||||
// meta is wlocked for calling this func.
|
||||
|
||||
// search
|
||||
SMetaCache* pCache = pMeta->pCache;
|
||||
|
@ -450,7 +453,11 @@ int32_t metaGetCachedTableUidList(SMeta* pMeta, tb_uid_t suid, const uint8_t* pK
|
|||
|
||||
// do some book mark work after acquiring the filter result from cache
|
||||
STagFilterResEntry** pEntry = taosHashGet(pTableMap, &suid, sizeof(uint64_t));
|
||||
ASSERT(pEntry != NULL);
|
||||
if (NULL == pEntry) {
|
||||
metaError("meta/cache: pEntry should not be NULL.");
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
*acquireRes = 1;
|
||||
|
||||
const char* p = taosLRUCacheValue(pCache, pHandle);
|
||||
|
@ -495,7 +502,7 @@ int32_t metaGetCachedTableUidList(SMeta* pMeta, tb_uid_t suid, const uint8_t* pK
|
|||
taosMemoryFree(*p1);
|
||||
}
|
||||
|
||||
atomic_store_32(&(*pEntry)->qTimes, 0); // reset the query times
|
||||
atomic_store_32(&(*pEntry)->qTimes, 0); // reset the query times
|
||||
taosArrayDestroy(pInvalidRes);
|
||||
|
||||
taosThreadMutexUnlock(pLock);
|
||||
|
@ -551,7 +558,10 @@ int32_t metaUidFilterCachePut(SMeta* pMeta, uint64_t suid, const void* pKey, int
|
|||
pBuf[0] = suid;
|
||||
|
||||
memcpy(&pBuf[1], pKey, keyLen);
|
||||
ASSERT(sizeof(uint64_t) + keyLen == 24);
|
||||
if (sizeof(uint64_t) + keyLen != 24) {
|
||||
metaError("meta/cache: incorrect keyLen:%" PRId32 " length.", keyLen);
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
// add to cache.
|
||||
taosLRUCacheInsert(pCache, pBuf, sizeof(uint64_t) + keyLen, pPayload, payloadLen, freePayload, NULL,
|
||||
|
|
|
@ -51,7 +51,9 @@ int metaEncodeEntry(SEncoder *pCoder, const SMetaEntry *pME) {
|
|||
} else if (pME->type == TSDB_TSMA_TABLE) {
|
||||
if (tEncodeTSma(pCoder, pME->smaEntry.tsma) < 0) return -1;
|
||||
} else {
|
||||
ASSERT(0);
|
||||
metaError("meta/entry: invalide table type: %" PRId8 " encode failed.", pME->type);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
tEndEncode(pCoder);
|
||||
|
@ -99,7 +101,9 @@ int metaDecodeEntry(SDecoder *pCoder, SMetaEntry *pME) {
|
|||
}
|
||||
if (tDecodeTSma(pCoder, pME->smaEntry.tsma, true) < 0) return -1;
|
||||
} else {
|
||||
ASSERT(0);
|
||||
metaError("meta/entry: invalide table type: %" PRId8 " decode failed.", pME->type);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
tEndDecode(pCoder);
|
||||
|
|
|
@ -358,7 +358,10 @@ static int tagIdxKeyCmpr(const void *pKey1, int kLen1, const void *pKey2, int kL
|
|||
return -1;
|
||||
}
|
||||
|
||||
ASSERT(pTagIdxKey1->type == pTagIdxKey2->type);
|
||||
if (pTagIdxKey1->type != pTagIdxKey2->type) {
|
||||
metaError("meta/open: incorrect tag idx type.");
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
// check NULL, NULL is always the smallest
|
||||
if (pTagIdxKey1->isNull && !pTagIdxKey2->isNull) {
|
||||
|
|
|
@ -661,7 +661,11 @@ int32_t metaGetTbTSchemaEx(SMeta *pMeta, tb_uid_t suid, tb_uid_t uid, int32_t sv
|
|||
goto _exit;
|
||||
}
|
||||
|
||||
ASSERT(c);
|
||||
if (c == 0) {
|
||||
metaError("meta/query: incorrect c: %" PRId32 ".", c);
|
||||
code = TSDB_CODE_FAILED;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
if (c < 0) {
|
||||
tdbTbcMoveToPrev(pSkmDbC);
|
||||
|
@ -685,7 +689,11 @@ int32_t metaGetTbTSchemaEx(SMeta *pMeta, tb_uid_t suid, tb_uid_t uid, int32_t sv
|
|||
}
|
||||
}
|
||||
|
||||
ASSERT(sver > 0);
|
||||
if (sver <= 0) {
|
||||
metaError("meta/query: incorrect sver: %" PRId32 ".", sver);
|
||||
code = TSDB_CODE_FAILED;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
skmDbKey.uid = suid ? suid : uid;
|
||||
skmDbKey.sver = sver;
|
||||
|
|
|
@ -100,7 +100,10 @@ int32_t metaSnapRead(SMetaSnapReader* pReader, uint8_t** ppData) {
|
|||
break;
|
||||
}
|
||||
|
||||
ASSERT(pData && nData);
|
||||
if (!pData || !nData) {
|
||||
metaError("meta/snap: invalide nData: %" PRId32 " meta snap read failed.", nData);
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
*ppData = taosMemoryMalloc(sizeof(SSnapDataHdr) + nData);
|
||||
if (*ppData == NULL) {
|
||||
|
@ -356,7 +359,11 @@ int32_t buildSnapContext(SMeta* pMeta, int64_t snapVersion, int64_t suid, int8_t
|
|||
for (int i = 0; i < taosArrayGetSize(ctx->idList); i++) {
|
||||
int64_t* uid = taosArrayGet(ctx->idList, i);
|
||||
SIdInfo* idData = (SIdInfo*)taosHashGet(ctx->idVersion, uid, sizeof(int64_t));
|
||||
ASSERT(idData);
|
||||
if (!idData) {
|
||||
metaError("meta/snap: null idData");
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
idData->index = i;
|
||||
metaDebug("tmqsnap init idVersion uid:%" PRIi64 " version:%" PRIi64 " index:%d", *uid, idData->version,
|
||||
idData->index);
|
||||
|
@ -473,7 +480,10 @@ int32_t getMetafromSnapShot(SSnapContext* ctx, void** pBuf, int32_t* contLen, in
|
|||
int64_t* uidTmp = taosArrayGet(ctx->idList, ctx->index);
|
||||
ctx->index++;
|
||||
SIdInfo* idInfo = (SIdInfo*)taosHashGet(ctx->idVersion, uidTmp, sizeof(tb_uid_t));
|
||||
ASSERT(idInfo);
|
||||
if (!idInfo) {
|
||||
metaError("meta/snap: null idInfo");
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
*uid = *uidTmp;
|
||||
ret = MoveToPosition(ctx, idInfo->version, *uidTmp);
|
||||
|
@ -507,7 +517,11 @@ int32_t getMetafromSnapShot(SSnapContext* ctx, void** pBuf, int32_t* contLen, in
|
|||
(ctx->subType == TOPIC_SUB_TYPE__TABLE && me.type == TSDB_CHILD_TABLE && me.ctbEntry.suid == ctx->suid)) {
|
||||
STableInfoForChildTable* data =
|
||||
(STableInfoForChildTable*)taosHashGet(ctx->suidInfo, &me.ctbEntry.suid, sizeof(tb_uid_t));
|
||||
ASSERT(data);
|
||||
if (!data) {
|
||||
metaError("meta/snap: null data");
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
SVCreateTbReq req = {0};
|
||||
|
||||
req.type = TSDB_CHILD_TABLE;
|
||||
|
@ -528,7 +542,8 @@ int32_t getMetafromSnapShot(SSnapContext* ctx, void** pBuf, int32_t* contLen, in
|
|||
} else {
|
||||
SArray* pTagVals = NULL;
|
||||
if (tTagToValArray((const STag*)p, &pTagVals) != 0) {
|
||||
ASSERT(0);
|
||||
metaError("meta/snap: tag to val array failed.");
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
int16_t nCols = taosArrayGetSize(pTagVals);
|
||||
for (int j = 0; j < nCols; ++j) {
|
||||
|
@ -572,7 +587,8 @@ int32_t getMetafromSnapShot(SSnapContext* ctx, void** pBuf, int32_t* contLen, in
|
|||
ret = buildNormalChildTableInfo(&req, pBuf, contLen);
|
||||
*type = TDMT_VND_CREATE_TABLE;
|
||||
} else {
|
||||
ASSERT(0);
|
||||
metaError("meta/snap: invalid topic sub type: %" PRId8 " get meta from snap failed.", ctx->subType);
|
||||
ret = -1;
|
||||
}
|
||||
tDecoderClear(&dc);
|
||||
|
||||
|
@ -593,7 +609,10 @@ SMetaTableInfo getUidfromSnapShot(SSnapContext* ctx) {
|
|||
int64_t* uidTmp = taosArrayGet(ctx->idList, ctx->index);
|
||||
ctx->index++;
|
||||
SIdInfo* idInfo = (SIdInfo*)taosHashGet(ctx->idVersion, uidTmp, sizeof(tb_uid_t));
|
||||
ASSERT(idInfo);
|
||||
if (!idInfo) {
|
||||
metaError("meta/snap: null idInfo");
|
||||
return result;
|
||||
}
|
||||
|
||||
int32_t ret = MoveToPosition(ctx, idInfo->version, *uidTmp);
|
||||
if (ret != 0) {
|
||||
|
|
|
@ -46,7 +46,7 @@ static void metaGetEntryInfo(const SMetaEntry *pEntry, SMetaInfo *pInfo) {
|
|||
pInfo->suid = 0;
|
||||
pInfo->skmVer = pEntry->ntbEntry.schemaRow.version;
|
||||
} else {
|
||||
ASSERT(0);
|
||||
metaError("meta/table: invalide table type: %" PRId8 " get entry info failed.", pEntry->type);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -342,10 +342,18 @@ int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
|||
|
||||
tdbTbcOpen(pMeta->pTbDb, &pTbDbc, NULL);
|
||||
ret = tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = pReq->suid, .version = oversion}), sizeof(STbDbKey), &c);
|
||||
ASSERT(ret == 0 && c == 0);
|
||||
if (!(ret == 0 && c == 0)) {
|
||||
metaError("meta/table: invalide ret: %" PRId32 " or c: %" PRId32 "alter stb failed.", ret, c);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = tdbTbcGet(pTbDbc, NULL, NULL, &pData, &nData);
|
||||
ASSERT(ret == 0);
|
||||
if (ret < 0) {
|
||||
tdbTbcClose(pTbDbc);
|
||||
|
||||
terrno = TSDB_CODE_TDB_STB_NOT_EXIST;
|
||||
return -1;
|
||||
}
|
||||
|
||||
oStbEntry.pBuf = taosMemoryMalloc(nData);
|
||||
memcpy(oStbEntry.pBuf, pData, nData);
|
||||
|
@ -558,7 +566,8 @@ static void metaBuildTtlIdxKey(STtlIdxKey *ttlKey, const SMetaEntry *pME) {
|
|||
ctime = pME->ntbEntry.ctime;
|
||||
ttlDays = pME->ntbEntry.ttlDays;
|
||||
} else {
|
||||
ASSERT(0);
|
||||
metaError("meta/table: invalide table type: %" PRId8 " build ttl idx key failed.", pME->type);
|
||||
return;
|
||||
}
|
||||
|
||||
if (ttlDays <= 0) return;
|
||||
|
@ -773,7 +782,10 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
|
|||
|
||||
tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, NULL);
|
||||
tdbTbcMoveTo(pUidIdxc, &uid, sizeof(uid), &c);
|
||||
ASSERT(c == 0);
|
||||
if (c != 0) {
|
||||
metaError("meta/table: invalide c: %" PRId32 " alt tb column failed.", c);
|
||||
return -1;
|
||||
}
|
||||
|
||||
tdbTbcGet(pUidIdxc, NULL, NULL, &pData, &nData);
|
||||
oversion = ((SUidIdxVal *)pData)[0].version;
|
||||
|
@ -783,7 +795,11 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
|
|||
|
||||
tdbTbcOpen(pMeta->pTbDb, &pTbDbc, NULL);
|
||||
tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = uid, .version = oversion}), sizeof(STbDbKey), &c);
|
||||
ASSERT(c == 0);
|
||||
if (c != 0) {
|
||||
metaError("meta/table: invalide c: %" PRId32 " alt tb column failed.", c);
|
||||
return -1;
|
||||
}
|
||||
|
||||
tdbTbcGet(pTbDbc, NULL, NULL, &pData, &nData);
|
||||
|
||||
// get table entry
|
||||
|
@ -792,7 +808,11 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
|
|||
memcpy(entry.pBuf, pData, nData);
|
||||
tDecoderInit(&dc, entry.pBuf, nData);
|
||||
ret = metaDecodeEntry(&dc, &entry);
|
||||
ASSERT(ret == 0);
|
||||
if (ret != 0) {
|
||||
tDecoderClear(&dc);
|
||||
metaError("meta/table: invalide ret: %" PRId32 " alt tb column failed.", ret);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (entry.type != TSDB_NORMAL_TABLE) {
|
||||
terrno = TSDB_CODE_VND_INVALID_TABLE_ACTION;
|
||||
|
@ -812,7 +832,11 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
|
|||
if (iCol >= pSchema->nCols) break;
|
||||
pColumn = &pSchema->pSchema[iCol];
|
||||
|
||||
ASSERT(pAlterTbReq->colName);
|
||||
if (NULL == pAlterTbReq->colName) {
|
||||
metaError("meta/table: null pAlterTbReq->colName");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (strcmp(pColumn->name, pAlterTbReq->colName) == 0) break;
|
||||
iCol++;
|
||||
}
|
||||
|
@ -964,7 +988,10 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
|
|||
|
||||
tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, NULL);
|
||||
tdbTbcMoveTo(pUidIdxc, &uid, sizeof(uid), &c);
|
||||
ASSERT(c == 0);
|
||||
if (c != 0) {
|
||||
metaError("meta/table: invalide c: %" PRId32 " update tb tag val failed.", c);
|
||||
return -1;
|
||||
}
|
||||
|
||||
tdbTbcGet(pUidIdxc, NULL, NULL, &pData, &nData);
|
||||
oversion = ((SUidIdxVal *)pData)[0].version;
|
||||
|
@ -977,7 +1004,11 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
|
|||
/* get ctbEntry */
|
||||
tdbTbcOpen(pMeta->pTbDb, &pTbDbc, NULL);
|
||||
tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = uid, .version = oversion}), sizeof(STbDbKey), &c);
|
||||
ASSERT(c == 0);
|
||||
if (c != 0) {
|
||||
metaError("meta/table: invalide c: %" PRId32 " update tb tag val failed.", c);
|
||||
return -1;
|
||||
}
|
||||
|
||||
tdbTbcGet(pTbDbc, NULL, NULL, &pData, &nData);
|
||||
|
||||
ctbEntry.pBuf = taosMemoryMalloc(nData);
|
||||
|
@ -1075,7 +1106,11 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
|
|||
metaUpdateTagIdx(pMeta, &ctbEntry);
|
||||
}
|
||||
|
||||
ASSERT(ctbEntry.ctbEntry.pTags);
|
||||
if (NULL == ctbEntry.ctbEntry.pTags) {
|
||||
metaError("meta/table: null tags, update tag val failed.");
|
||||
goto _err;
|
||||
}
|
||||
|
||||
SCtbIdxKey ctbIdxKey = {.suid = ctbEntry.ctbEntry.suid, .uid = uid};
|
||||
tdbTbUpsert(pMeta->pCtbIdx, &ctbIdxKey, sizeof(ctbIdxKey), ctbEntry.ctbEntry.pTags,
|
||||
((STag *)(ctbEntry.ctbEntry.pTags))->len, pMeta->txn);
|
||||
|
@ -1130,7 +1165,10 @@ static int metaUpdateTableOptions(SMeta *pMeta, int64_t version, SVAlterTbReq *p
|
|||
|
||||
tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, NULL);
|
||||
tdbTbcMoveTo(pUidIdxc, &uid, sizeof(uid), &c);
|
||||
ASSERT(c == 0);
|
||||
if (c != 0) {
|
||||
metaError("meta/table: invalide c: %" PRId32 " update tb options failed.", c);
|
||||
return -1;
|
||||
}
|
||||
|
||||
tdbTbcGet(pUidIdxc, NULL, NULL, &pData, &nData);
|
||||
oversion = ((SUidIdxVal *)pData)[0].version;
|
||||
|
@ -1140,7 +1178,11 @@ static int metaUpdateTableOptions(SMeta *pMeta, int64_t version, SVAlterTbReq *p
|
|||
|
||||
tdbTbcOpen(pMeta->pTbDb, &pTbDbc, NULL);
|
||||
tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = uid, .version = oversion}), sizeof(STbDbKey), &c);
|
||||
ASSERT(c == 0);
|
||||
if (c != 0) {
|
||||
metaError("meta/table: invalide c: %" PRId32 " update tb options failed.", c);
|
||||
return -1;
|
||||
}
|
||||
|
||||
tdbTbcGet(pTbDbc, NULL, NULL, &pData, &nData);
|
||||
|
||||
// get table entry
|
||||
|
@ -1149,7 +1191,11 @@ static int metaUpdateTableOptions(SMeta *pMeta, int64_t version, SVAlterTbReq *p
|
|||
memcpy(entry.pBuf, pData, nData);
|
||||
tDecoderInit(&dc, entry.pBuf, nData);
|
||||
ret = metaDecodeEntry(&dc, &entry);
|
||||
ASSERT(ret == 0);
|
||||
if (ret != 0) {
|
||||
tDecoderClear(&dc);
|
||||
metaError("meta/table: invalide ret: %" PRId32 " alt tb options failed.", ret);
|
||||
return -1;
|
||||
}
|
||||
|
||||
entry.version = version;
|
||||
metaWLock(pMeta);
|
||||
|
@ -1408,7 +1454,8 @@ static int metaSaveToSkmDb(SMeta *pMeta, const SMetaEntry *pME) {
|
|||
} else if (pME->type == TSDB_NORMAL_TABLE) {
|
||||
pSW = &pME->ntbEntry.schemaRow;
|
||||
} else {
|
||||
ASSERT(0);
|
||||
metaError("meta/table: invalide table type: %" PRId8 " save skm db failed.", pME->type);
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
skmDbKey.uid = pME->uid;
|
||||
|
|
Loading…
Reference in New Issue