enh: error code handle

This commit is contained in:
Hongze Cheng 2024-09-19 11:36:29 +08:00
parent bdf97634e4
commit b21e162f19
4 changed files with 289 additions and 80 deletions

View File

@ -27,15 +27,15 @@ static int taskIdxKeyCmpr(const void *pKey1, int kLen1, const void *pKey2, int k
static int btimeIdxCmpr(const void *pKey1, int kLen1, const void *pKey2, int kLen2); static int btimeIdxCmpr(const void *pKey1, int kLen1, const void *pKey2, int kLen2);
static int ncolIdxCmpr(const void *pKey1, int kLen1, const void *pKey2, int kLen2); static int ncolIdxCmpr(const void *pKey1, int kLen1, const void *pKey2, int kLen2);
static int32_t metaInitLock(SMeta *pMeta) { static void metaInitLock(SMeta *pMeta) {
TdThreadRwlockAttr attr; TdThreadRwlockAttr attr;
(void)taosThreadRwlockAttrInit(&attr); (void)taosThreadRwlockAttrInit(&attr);
(void)taosThreadRwlockAttrSetKindNP(&attr, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP); (void)taosThreadRwlockAttrSetKindNP(&attr, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP);
(void)taosThreadRwlockInit(&pMeta->lock, &attr); (void)taosThreadRwlockInit(&pMeta->lock, &attr);
(void)taosThreadRwlockAttrDestroy(&attr); (void)taosThreadRwlockAttrDestroy(&attr);
return 0; return;
} }
static int32_t metaDestroyLock(SMeta *pMeta) { return taosThreadRwlockDestroy(&pMeta->lock); } static void metaDestroyLock(SMeta *pMeta) { (void)taosThreadRwlockDestroy(&pMeta->lock); }
static void metaCleanup(SMeta **ppMeta); static void metaCleanup(SMeta **ppMeta);
@ -56,7 +56,7 @@ int32_t metaOpen(SVnode *pVnode, SMeta **ppMeta, int8_t rollback) {
TSDB_CHECK_CODE(code = terrno, lino, _exit); TSDB_CHECK_CODE(code = terrno, lino, _exit);
} }
(void)metaInitLock(pMeta); metaInitLock(pMeta);
pMeta->path = (char *)&pMeta[1]; pMeta->path = (char *)&pMeta[1];
strcpy(pMeta->path, path); strcpy(pMeta->path, path);
@ -188,17 +188,23 @@ int metaAlterCache(SMeta *pMeta, int32_t nPage) {
void metaRLock(SMeta *pMeta) { void metaRLock(SMeta *pMeta) {
metaTrace("meta rlock %p", &pMeta->lock); metaTrace("meta rlock %p", &pMeta->lock);
(void)taosThreadRwlockRdlock(&pMeta->lock); if (taosThreadRwlockRdlock(&pMeta->lock) != 0) {
metaError("vgId:%d failed to lock %p", TD_VID(pMeta->pVnode), &pMeta->lock);
}
} }
void metaWLock(SMeta *pMeta) { void metaWLock(SMeta *pMeta) {
metaTrace("meta wlock %p", &pMeta->lock); metaTrace("meta wlock %p", &pMeta->lock);
(void)taosThreadRwlockWrlock(&pMeta->lock); if (taosThreadRwlockWrlock(&pMeta->lock) != 0) {
metaError("vgId:%d failed to lock %p", TD_VID(pMeta->pVnode), &pMeta->lock);
}
} }
void metaULock(SMeta *pMeta) { void metaULock(SMeta *pMeta) {
metaTrace("meta ulock %p", &pMeta->lock); metaTrace("meta ulock %p", &pMeta->lock);
(void)taosThreadRwlockUnlock(&pMeta->lock); if (taosThreadRwlockUnlock(&pMeta->lock) != 0) {
metaError("vgId:%d failed to unlock %p", TD_VID(pMeta->pVnode), &pMeta->lock);
}
} }
static void metaCleanup(SMeta **ppMeta) { static void metaCleanup(SMeta **ppMeta) {
@ -223,7 +229,7 @@ static void metaCleanup(SMeta **ppMeta) {
if (pMeta->pSkmDb) tdbTbClose(pMeta->pSkmDb); if (pMeta->pSkmDb) tdbTbClose(pMeta->pSkmDb);
if (pMeta->pTbDb) tdbTbClose(pMeta->pTbDb); if (pMeta->pTbDb) tdbTbClose(pMeta->pTbDb);
if (pMeta->pEnv) tdbClose(pMeta->pEnv); if (pMeta->pEnv) tdbClose(pMeta->pEnv);
(void)metaDestroyLock(pMeta); metaDestroyLock(pMeta);
taosMemoryFreeClear(*ppMeta); taosMemoryFreeClear(*ppMeta);
} }

View File

@ -353,7 +353,11 @@ int32_t metaTbCursorPrev(SMTbCursor *pTbCur, ETableType jumpTableType) {
tDecoderClear(&pTbCur->mr.coder); tDecoderClear(&pTbCur->mr.coder);
(void)metaGetTableEntryByVersion(&pTbCur->mr, ((SUidIdxVal *)pTbCur->pVal)[0].version, *(tb_uid_t *)pTbCur->pKey); ret = metaGetTableEntryByVersion(&pTbCur->mr, ((SUidIdxVal *)pTbCur->pVal)[0].version, *(tb_uid_t *)pTbCur->pKey);
if (ret < 0) {
return ret;
}
if (pTbCur->mr.me.type == jumpTableType) { if (pTbCur->mr.me.type == jumpTableType) {
continue; continue;
} }
@ -387,7 +391,10 @@ _query:
SMetaEntry me = {0}; SMetaEntry me = {0};
tDecoderInit(&dc, pData, nData); tDecoderInit(&dc, pData, nData);
(void)metaDecodeEntry(&dc, &me); int32_t code = metaDecodeEntry(&dc, &me);
if (code) {
goto _err;
}
if (me.type == TSDB_SUPER_TABLE) { if (me.type == TSDB_SUPER_TABLE) {
if (sver == -1 || sver == me.stbEntry.schemaRow.version) { if (sver == -1 || sver == me.stbEntry.schemaRow.version) {
pSchema = tCloneSSchemaWrapper(&me.stbEntry.schemaRow); pSchema = tCloneSSchemaWrapper(&me.stbEntry.schemaRow);
@ -502,17 +509,17 @@ int32_t metaResumeCtbCursor(SMCtbCursor *pCtbCur, int8_t first) {
ctbIdxKey.suid = pCtbCur->suid; ctbIdxKey.suid = pCtbCur->suid;
ctbIdxKey.uid = INT64_MIN; ctbIdxKey.uid = INT64_MIN;
int c = 0; int c = 0;
(void)tdbTbcMoveTo(pCtbCur->pCur, &ctbIdxKey, sizeof(ctbIdxKey), &c); ret = tdbTbcMoveTo(pCtbCur->pCur, &ctbIdxKey, sizeof(ctbIdxKey), &c);
if (c > 0) { if (c > 0) {
(void)tdbTbcMoveToNext(pCtbCur->pCur); ret = tdbTbcMoveToNext(pCtbCur->pCur);
} }
} else { } else {
int c = 0; int c = 0;
ret = tdbTbcMoveTo(pCtbCur->pCur, pCtbCur->pKey, pCtbCur->kLen, &c); ret = tdbTbcMoveTo(pCtbCur->pCur, pCtbCur->pKey, pCtbCur->kLen, &c);
if (c < 0) { if (c < 0) {
(void)tdbTbcMoveToPrev(pCtbCur->pCur); ret = tdbTbcMoveToPrev(pCtbCur->pCur);
} else { } else {
(void)tdbTbcMoveToNext(pCtbCur->pCur); ret = tdbTbcMoveToNext(pCtbCur->pCur);
} }
} }
} }
@ -570,9 +577,9 @@ SMStbCursor *metaOpenStbCursor(SMeta *pMeta, tb_uid_t suid) {
} }
// move to the suid // move to the suid
(void)tdbTbcMoveTo(pStbCur->pCur, &suid, sizeof(suid), &c); ret = tdbTbcMoveTo(pStbCur->pCur, &suid, sizeof(suid), &c);
if (c > 0) { if (c > 0) {
(void)tdbTbcMoveToNext(pStbCur->pCur); ret = tdbTbcMoveToNext(pStbCur->pCur);
} }
return pStbCur; return pStbCur;
@ -670,12 +677,12 @@ int32_t metaGetTbTSchemaEx(SMeta *pMeta, tb_uid_t suid, tb_uid_t uid, int32_t sv
} }
if (c < 0) { if (c < 0) {
(void)tdbTbcMoveToPrev(pSkmDbC); int32_t ret = tdbTbcMoveToPrev(pSkmDbC);
} }
const void *pKey = NULL; const void *pKey = NULL;
int32_t nKey = 0; int32_t nKey = 0;
(void)tdbTbcGet(pSkmDbC, &pKey, &nKey, NULL, NULL); int32_t ret = tdbTbcGet(pSkmDbC, &pKey, &nKey, NULL, NULL);
if (((SSkmDbKey *)pKey)->uid != skmDbKey.uid) { if (((SSkmDbKey *)pKey)->uid != skmDbKey.uid) {
metaULock(pMeta); metaULock(pMeta);
@ -805,9 +812,9 @@ SMSmaCursor *metaOpenSmaCursor(SMeta *pMeta, tb_uid_t uid) {
// move to the suid // move to the suid
smaIdxKey.uid = uid; smaIdxKey.uid = uid;
smaIdxKey.smaUid = INT64_MIN; smaIdxKey.smaUid = INT64_MIN;
(void)tdbTbcMoveTo(pSmaCur->pCur, &smaIdxKey, sizeof(smaIdxKey), &c); ret = tdbTbcMoveTo(pSmaCur->pCur, &smaIdxKey, sizeof(smaIdxKey), &c);
if (c > 0) { if (c > 0) {
(void)tdbTbcMoveToNext(pSmaCur->pCur); ret = tdbTbcMoveToNext(pSmaCur->pCur);
} }
return pSmaCur; return pSmaCur;
@ -916,7 +923,7 @@ STSmaWrapper *metaGetSmaInfoByTable(SMeta *pMeta, tb_uid_t uid, bool deepCopy) {
_err: _err:
metaReaderClear(&mr); metaReaderClear(&mr);
taosArrayDestroy(pSmaIds); taosArrayDestroy(pSmaIds);
(void)tFreeTSmaWrapper(pSW, deepCopy); pSW = tFreeTSmaWrapper(pSW, deepCopy);
return NULL; return NULL;
} }
@ -1583,7 +1590,10 @@ int32_t metaGetInfo(SMeta *pMeta, int64_t uid, SMetaInfo *pInfo, SMetaReader *pR
} }
// upsert the cache // upsert the cache
metaWLock(pMeta); metaWLock(pMeta);
(void)metaCacheUpsert(pMeta, pInfo); int32_t ret = metaCacheUpsert(pMeta, pInfo);
if (ret != 0) {
metaError("vgId:%d, failed to upsert cache, uid:%" PRId64, TD_VID(pMeta->pVnode), uid);
}
metaULock(pMeta); metaULock(pMeta);
if (lock) { if (lock) {
@ -1633,7 +1643,12 @@ int32_t metaGetStbStats(void *pVnode, int64_t uid, int64_t *numOfTables, int32_t
// upsert the cache // upsert the cache
metaWLock(pVnodeObj->pMeta); metaWLock(pVnodeObj->pMeta);
(void)metaStatsCacheUpsert(pVnodeObj->pMeta, &state);
int32_t ret = metaStatsCacheUpsert(pVnodeObj->pMeta, &state);
if (ret) {
metaError("failed to upsert stats, uid:%" PRId64 ", ctbNum:%" PRId64 ", colNum:%d", uid, ctbNum, colNum);
}
metaULock(pVnodeObj->pMeta); metaULock(pVnodeObj->pMeta);
_exit: _exit:
@ -1646,6 +1661,10 @@ void metaUpdateStbStats(SMeta *pMeta, int64_t uid, int64_t deltaCtb, int32_t del
if (metaStatsCacheGet(pMeta, uid, &stats) == TSDB_CODE_SUCCESS) { if (metaStatsCacheGet(pMeta, uid, &stats) == TSDB_CODE_SUCCESS) {
stats.ctbNum += deltaCtb; stats.ctbNum += deltaCtb;
stats.colNum += deltaCol; stats.colNum += deltaCol;
(void)metaStatsCacheUpsert(pMeta, &stats); int32_t code = metaStatsCacheUpsert(pMeta, &stats);
if (code) {
metaError("vgId:%d, failed to update stats, uid:%" PRId64 ", ctbNum:%" PRId64 ", colNum:%d",
TD_VID(pMeta->pVnode), uid, deltaCtb, deltaCol);
}
} }
} }

View File

@ -175,7 +175,11 @@ static int metaSaveJsonVarToIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const
} }
if (term != NULL) { if (term != NULL) {
(void)indexMultiTermAdd(terms, term); int32_t ret = indexMultiTermAdd(terms, term);
if (ret < 0) {
metaError("vgId:%d, failed to add term to multi term, uid: %" PRId64 ", key: %s, type: %d, ret: %d",
TD_VID(pMeta->pVnode), tuid, key, type, ret);
}
} else { } else {
code = terrno; code = terrno;
goto _exception; goto _exception;
@ -254,7 +258,11 @@ int metaDelJsonVarFromIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const SSche
term = indexTermCreate(suid, DEL_VALUE, TSDB_DATA_TYPE_BOOL, key, nKey, (const char *)&val, len); term = indexTermCreate(suid, DEL_VALUE, TSDB_DATA_TYPE_BOOL, key, nKey, (const char *)&val, len);
} }
if (term != NULL) { if (term != NULL) {
(void)indexMultiTermAdd(terms, term); int32_t ret = indexMultiTermAdd(terms, term);
if (ret < 0) {
metaError("vgId:%d, failed to add term to multi term, uid: %" PRId64 ", key: %s, type: %d, ret: %d",
TD_VID(pMeta->pVnode), tuid, key, type, ret);
}
} else { } else {
code = terrno; code = terrno;
goto _exception; goto _exception;
@ -351,6 +359,7 @@ int metaDropSTable(SMeta *pMeta, int64_t verison, SVDropStbReq *pReq, SArray *tb
int c = 0; int c = 0;
int rc = 0; int rc = 0;
int32_t lino; int32_t lino;
int32_t ret;
// check if super table exists // check if super table exists
rc = tdbTbGet(pMeta->pNameIdx, pReq->name, strlen(pReq->name) + 1, &pData, &nData); rc = tdbTbGet(pMeta->pNameIdx, pReq->name, strlen(pReq->name) + 1, &pData, &nData);
@ -393,25 +402,56 @@ int metaDropSTable(SMeta *pMeta, int64_t verison, SVDropStbReq *pReq, SArray *tb
tdbTbcClose(pCtbIdxc); tdbTbcClose(pCtbIdxc);
(void)tsdbCacheDropSubTables(pMeta->pVnode->pTsdb, tbUidList, pReq->suid); ret = tsdbCacheDropSubTables(pMeta->pVnode->pTsdb, tbUidList, pReq->suid);
if (ret < 0) {
metaError("vgId:%d, failed to drop stb:%s uid:%" PRId64 " since %s", TD_VID(pMeta->pVnode), pReq->name, pReq->suid,
tstrerror(terrno));
}
metaWLock(pMeta); metaWLock(pMeta);
for (int32_t iChild = 0; iChild < taosArrayGetSize(tbUidList); iChild++) { for (int32_t iChild = 0; iChild < taosArrayGetSize(tbUidList); iChild++) {
tb_uid_t uid = *(tb_uid_t *)taosArrayGet(tbUidList, iChild); tb_uid_t uid = *(tb_uid_t *)taosArrayGet(tbUidList, iChild);
(void)metaDropTableByUid(pMeta, uid, NULL, NULL, NULL); ret = metaDropTableByUid(pMeta, uid, NULL, NULL, NULL);
if (ret < 0) {
metaError("vgId:%d, failed to drop stb:%s uid:%" PRId64 " since %s", TD_VID(pMeta->pVnode), pReq->name,
pReq->suid, tstrerror(terrno));
}
} }
// drop super table // drop super table
_drop_super_table: _drop_super_table:
tdbTbGet(pMeta->pUidIdx, &pReq->suid, sizeof(tb_uid_t), &pData, &nData); tdbTbGet(pMeta->pUidIdx, &pReq->suid, sizeof(tb_uid_t), &pData, &nData);
(void)tdbTbDelete(pMeta->pTbDb, &(STbDbKey){.version = ((SUidIdxVal *)pData)[0].version, .uid = pReq->suid}, ret = tdbTbDelete(pMeta->pTbDb, &(STbDbKey){.version = ((SUidIdxVal *)pData)[0].version, .uid = pReq->suid},
sizeof(STbDbKey), pMeta->txn); sizeof(STbDbKey), pMeta->txn);
(void)tdbTbDelete(pMeta->pNameIdx, pReq->name, strlen(pReq->name) + 1, pMeta->txn); if (ret < 0) {
(void)tdbTbDelete(pMeta->pUidIdx, &pReq->suid, sizeof(tb_uid_t), pMeta->txn); metaError("vgId:%d, failed to drop stb:%s uid:%" PRId64 " since %s", TD_VID(pMeta->pVnode), pReq->name, pReq->suid,
(void)tdbTbDelete(pMeta->pSuidIdx, &pReq->suid, sizeof(tb_uid_t), pMeta->txn); tstrerror(terrno));
}
(void)metaStatsCacheDrop(pMeta, pReq->suid); ret = tdbTbDelete(pMeta->pNameIdx, pReq->name, strlen(pReq->name) + 1, pMeta->txn);
if (ret < 0) {
metaError("vgId:%d, failed to drop stb:%s uid:%" PRId64 " since %s", TD_VID(pMeta->pVnode), pReq->name, pReq->suid,
tstrerror(terrno));
}
ret = tdbTbDelete(pMeta->pUidIdx, &pReq->suid, sizeof(tb_uid_t), pMeta->txn);
if (ret < 0) {
metaError("vgId:%d, failed to drop stb:%s uid:%" PRId64 " since %s", TD_VID(pMeta->pVnode), pReq->name, pReq->suid,
tstrerror(terrno));
}
ret = tdbTbDelete(pMeta->pSuidIdx, &pReq->suid, sizeof(tb_uid_t), pMeta->txn);
if (ret < 0) {
metaError("vgId:%d, failed to drop stb:%s uid:%" PRId64 " since %s", TD_VID(pMeta->pVnode), pReq->name, pReq->suid,
tstrerror(terrno));
}
ret = metaStatsCacheDrop(pMeta, pReq->suid);
if (ret < 0) {
metaError("vgId:%d, failed to drop stb:%s uid:%" PRId64 " since %s", TD_VID(pMeta->pVnode), pReq->name, pReq->suid,
tstrerror(terrno));
}
metaULock(pMeta); metaULock(pMeta);
@ -519,7 +559,14 @@ int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
} }
memcpy(oStbEntry.pBuf, pData, nData); memcpy(oStbEntry.pBuf, pData, nData);
tDecoderInit(&dc, oStbEntry.pBuf, nData); tDecoderInit(&dc, oStbEntry.pBuf, nData);
(void)metaDecodeEntry(&dc, &oStbEntry); ret = metaDecodeEntry(&dc, &oStbEntry);
if (ret < 0) {
metaError("vgId:%d, failed to decode stb:%s uid:%" PRId64 " since %s", TD_VID(pMeta->pVnode), pReq->name,
pReq->suid, tstrerror(ret));
tdbTbcClose(pTbDbc);
tdbTbcClose(pUidIdxc);
return terrno;
}
nStbEntry.version = version; nStbEntry.version = version;
nStbEntry.type = TSDB_SUPER_TABLE; nStbEntry.type = TSDB_SUPER_TABLE;
@ -550,7 +597,7 @@ int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
int8_t col_type = pReq->schemaRow.pSchema[nCols - 1].type; int8_t col_type = pReq->schemaRow.pSchema[nCols - 1].type;
TAOS_CHECK_RETURN(metaGetSubtables(pMeta, pReq->suid, uids)); TAOS_CHECK_RETURN(metaGetSubtables(pMeta, pReq->suid, uids));
(void)tsdbCacheNewSTableColumn(pTsdb, uids, cid, col_type); TAOS_CHECK_RETURN(tsdbCacheNewSTableColumn(pTsdb, uids, cid, col_type));
} else if (deltaCol == -1) { } else if (deltaCol == -1) {
int16_t cid = -1; int16_t cid = -1;
bool hasPrimaryKey = false; bool hasPrimaryKey = false;
@ -566,7 +613,7 @@ int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
if (cid != -1) { if (cid != -1) {
TAOS_CHECK_RETURN(metaGetSubtables(pMeta, pReq->suid, uids)); TAOS_CHECK_RETURN(metaGetSubtables(pMeta, pReq->suid, uids));
(void)tsdbCacheDropSTableColumn(pTsdb, uids, cid, hasPrimaryKey); TAOS_CHECK_RETURN(tsdbCacheDropSTableColumn(pTsdb, uids, cid, hasPrimaryKey));
} }
} }
if (uids) taosArrayDestroy(uids); if (uids) taosArrayDestroy(uids);
@ -575,25 +622,41 @@ int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
metaWLock(pMeta); metaWLock(pMeta);
// compare two entry // compare two entry
if (oStbEntry.stbEntry.schemaRow.version != pReq->schemaRow.version) { if (oStbEntry.stbEntry.schemaRow.version != pReq->schemaRow.version) {
(void)metaSaveToSkmDb(pMeta, &nStbEntry); ret = metaSaveToSkmDb(pMeta, &nStbEntry);
if (ret < 0) {
metaError("vgId:%d, failed to save skm db:%s uid:%" PRId64 " since %s", TD_VID(pMeta->pVnode), pReq->name,
pReq->suid, tstrerror(ret));
}
} }
// update table.db // update table.db
(void)metaSaveToTbDb(pMeta, &nStbEntry); ret = metaSaveToTbDb(pMeta, &nStbEntry);
if (ret < 0) {
metaError("vgId:%d, failed to save tb db:%s uid:%" PRId64 " since %s", TD_VID(pMeta->pVnode), pReq->name,
pReq->suid, tstrerror(ret));
}
// update uid index // update uid index
(void)metaUpdateUidIdx(pMeta, &nStbEntry); ret = metaUpdateUidIdx(pMeta, &nStbEntry);
if (ret < 0) {
metaError("vgId:%d, failed to update uid idx:%s uid:%" PRId64 " since %s", TD_VID(pMeta->pVnode), pReq->name,
pReq->suid, tstrerror(ret));
}
// metaStatsCacheDrop(pMeta, nStbEntry.uid); // metaStatsCacheDrop(pMeta, nStbEntry.uid);
if (updStat) { if (updStat) {
(void)metaUpdateStbStats(pMeta, pReq->suid, 0, deltaCol); metaUpdateStbStats(pMeta, pReq->suid, 0, deltaCol);
} }
metaULock(pMeta); metaULock(pMeta);
if (updStat) { if (updStat) {
int64_t ctbNum; int64_t ctbNum;
(void)metaGetStbStats(pMeta->pVnode, pReq->suid, &ctbNum, NULL); ret = metaGetStbStats(pMeta->pVnode, pReq->suid, &ctbNum, NULL);
if (ret < 0) {
metaError("vgId:%d, failed to get stb stats:%s uid:%" PRId64 " since %s", TD_VID(pMeta->pVnode), pReq->name,
pReq->suid, tstrerror(ret));
}
pMeta->pVnode->config.vndStats.numOfTimeSeries += (ctbNum * deltaCol); pMeta->pVnode->config.vndStats.numOfTimeSeries += (ctbNum * deltaCol);
metaTimeSeriesNotifyCheck(pMeta); metaTimeSeriesNotifyCheck(pMeta);
} }
@ -745,7 +808,11 @@ int metaAddIndexToSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
} }
metaWLock(pMeta); metaWLock(pMeta);
(void)tdbTbUpsert(pMeta->pTagIdx, pTagIdxKey, nTagIdxKey, NULL, 0, pMeta->txn); ret = tdbTbUpsert(pMeta->pTagIdx, pTagIdxKey, nTagIdxKey, NULL, 0, pMeta->txn);
if (ret < 0) {
metaError("vgId:%d, failed to upsert tag idx key:%s uid:%" PRId64 " since %s", TD_VID(pMeta->pVnode), pReq->name,
pReq->suid, tstrerror(ret));
}
metaULock(pMeta); metaULock(pMeta);
metaDestroyTagIdxKey(pTagIdxKey); metaDestroyTagIdxKey(pTagIdxKey);
@ -762,9 +829,17 @@ int metaAddIndexToSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
metaWLock(pMeta); metaWLock(pMeta);
// update table.db // update table.db
(void)metaSaveToTbDb(pMeta, &nStbEntry); ret = metaSaveToTbDb(pMeta, &nStbEntry);
if (ret < 0) {
metaError("vgId:%d, failed to save tb db:%s uid:%" PRId64 " since %s", TD_VID(pMeta->pVnode), pReq->name,
pReq->suid, tstrerror(ret));
}
// update uid index // update uid index
(void)metaUpdateUidIdx(pMeta, &nStbEntry); ret = metaUpdateUidIdx(pMeta, &nStbEntry);
if (ret < 0) {
metaError("vgId:%d, failed to update uid idx:%s uid:%" PRId64 " since %s", TD_VID(pMeta->pVnode), pReq->name,
pReq->suid, tstrerror(ret));
}
metaULock(pMeta); metaULock(pMeta);
if (oStbEntry.pBuf) taosMemoryFree(oStbEntry.pBuf); if (oStbEntry.pBuf) taosMemoryFree(oStbEntry.pBuf);
@ -896,7 +971,11 @@ int metaDropIndexFromSTable(SMeta *pMeta, int64_t version, SDropIndexReq *pReq)
} }
metaWLock(pMeta); metaWLock(pMeta);
(void)tdbTbDelete(pMeta->pTagIdx, pTagIdxKey, nTagIdxKey, pMeta->txn); ret = tdbTbDelete(pMeta->pTagIdx, pTagIdxKey, nTagIdxKey, pMeta->txn);
if (ret < 0) {
metaError("vgId:%d, failed to delete tag idx key:%s uid:%" PRId64 " since %s", TD_VID(pMeta->pVnode), pReq->stb,
pReq->stbUid, tstrerror(ret));
}
metaULock(pMeta); metaULock(pMeta);
metaDestroyTagIdxKey(pTagIdxKey); metaDestroyTagIdxKey(pTagIdxKey);
pTagIdxKey = NULL; pTagIdxKey = NULL;
@ -932,9 +1011,17 @@ int metaDropIndexFromSTable(SMeta *pMeta, int64_t version, SDropIndexReq *pReq)
metaWLock(pMeta); metaWLock(pMeta);
// update table.db // update table.db
(void)metaSaveToTbDb(pMeta, &nStbEntry); ret = metaSaveToTbDb(pMeta, &nStbEntry);
if (ret < 0) {
metaError("vgId:%d, failed to save tb db:%s uid:%" PRId64 " since %s", TD_VID(pMeta->pVnode), pReq->stb,
pReq->stbUid, tstrerror(ret));
}
// update uid index // update uid index
(void)metaUpdateUidIdx(pMeta, &nStbEntry); ret = metaUpdateUidIdx(pMeta, &nStbEntry);
if (ret < 0) {
metaError("vgId:%d, failed to update uid idx:%s uid:%" PRId64 " since %s", TD_VID(pMeta->pVnode), pReq->stb,
pReq->stbUid, tstrerror(ret));
}
metaULock(pMeta); metaULock(pMeta);
tDeleteSchemaWrapper(tag); tDeleteSchemaWrapper(tag);
@ -958,6 +1045,7 @@ _err:
int metaCreateTable(SMeta *pMeta, int64_t ver, SVCreateTbReq *pReq, STableMetaRsp **pMetaRsp) { int metaCreateTable(SMeta *pMeta, int64_t ver, SVCreateTbReq *pReq, STableMetaRsp **pMetaRsp) {
SMetaEntry me = {0}; SMetaEntry me = {0};
SMetaReader mr = {0}; SMetaReader mr = {0};
int32_t ret;
// validate message // validate message
if (pReq->type != TSDB_CHILD_TABLE && pReq->type != TSDB_NORMAL_TABLE) { if (pReq->type != TSDB_CHILD_TABLE && pReq->type != TSDB_NORMAL_TABLE) {
@ -1033,18 +1121,34 @@ int metaCreateTable(SMeta *pMeta, int64_t ver, SVCreateTbReq *pReq, STableMetaRs
if (!sysTbl) { if (!sysTbl) {
int32_t nCols = 0; int32_t nCols = 0;
(void)metaGetStbStats(pMeta->pVnode, me.ctbEntry.suid, 0, &nCols); ret = metaGetStbStats(pMeta->pVnode, me.ctbEntry.suid, 0, &nCols);
if (ret < 0) {
metaError("vgId:%d, failed to get stb stats:%s uid:%" PRId64 " since %s", TD_VID(pMeta->pVnode), pReq->name,
pReq->ctb.suid, tstrerror(ret));
}
pStats->numOfTimeSeries += nCols - 1; pStats->numOfTimeSeries += nCols - 1;
} }
metaWLock(pMeta); metaWLock(pMeta);
(void)metaUpdateStbStats(pMeta, me.ctbEntry.suid, 1, 0); metaUpdateStbStats(pMeta, me.ctbEntry.suid, 1, 0);
(void)metaUidCacheClear(pMeta, me.ctbEntry.suid); ret = metaUidCacheClear(pMeta, me.ctbEntry.suid);
(void)metaTbGroupCacheClear(pMeta, me.ctbEntry.suid); if (ret < 0) {
metaError("vgId:%d, failed to clear uid cache:%s uid:%" PRId64 " since %s", TD_VID(pMeta->pVnode), pReq->name,
pReq->ctb.suid, tstrerror(ret));
}
ret = metaTbGroupCacheClear(pMeta, me.ctbEntry.suid);
if (ret < 0) {
metaError("vgId:%d, failed to clear group cache:%s uid:%" PRId64 " since %s", TD_VID(pMeta->pVnode), pReq->name,
pReq->ctb.suid, tstrerror(ret));
}
metaULock(pMeta); metaULock(pMeta);
if (!TSDB_CACHE_NO(pMeta->pVnode->config)) { if (!TSDB_CACHE_NO(pMeta->pVnode->config)) {
(void)tsdbCacheNewTable(pMeta->pVnode->pTsdb, me.uid, me.ctbEntry.suid, NULL); ret = tsdbCacheNewTable(pMeta->pVnode->pTsdb, me.uid, me.ctbEntry.suid, NULL);
if (ret < 0) {
metaError("vgId:%d, failed to create table:%s since %s", TD_VID(pMeta->pVnode), pReq->name, tstrerror(ret));
goto _err;
}
} }
} else { } else {
me.ntbEntry.btime = pReq->btime; me.ntbEntry.btime = pReq->btime;
@ -1060,7 +1164,11 @@ int metaCreateTable(SMeta *pMeta, int64_t ver, SVCreateTbReq *pReq, STableMetaRs
pStats->numOfNTimeSeries += me.ntbEntry.schemaRow.nCols - 1; pStats->numOfNTimeSeries += me.ntbEntry.schemaRow.nCols - 1;
if (!TSDB_CACHE_NO(pMeta->pVnode->config)) { if (!TSDB_CACHE_NO(pMeta->pVnode->config)) {
(void)tsdbCacheNewTable(pMeta->pVnode->pTsdb, me.uid, -1, &me.ntbEntry.schemaRow); ret = tsdbCacheNewTable(pMeta->pVnode->pTsdb, me.uid, -1, &me.ntbEntry.schemaRow);
if (ret < 0) {
metaError("vgId:%d, failed to create table:%s since %s", TD_VID(pMeta->pVnode), pReq->name, tstrerror(ret));
goto _err;
}
} }
} }
@ -1078,7 +1186,11 @@ int metaCreateTable(SMeta *pMeta, int64_t ver, SVCreateTbReq *pReq, STableMetaRs
(*pMetaRsp)->suid = pReq->ctb.suid; (*pMetaRsp)->suid = pReq->ctb.suid;
strcpy((*pMetaRsp)->tbName, pReq->name); strcpy((*pMetaRsp)->tbName, pReq->name);
} else { } else {
(void)metaUpdateMetaRsp(pReq->uid, pReq->name, &pReq->ntb.schemaRow, *pMetaRsp); ret = metaUpdateMetaRsp(pReq->uid, pReq->name, &pReq->ntb.schemaRow, *pMetaRsp);
if (ret < 0) {
metaError("vgId:%d, failed to update meta rsp:%s since %s", TD_VID(pMeta->pVnode), pReq->name,
tstrerror(ret));
}
for (int32_t i = 0; i < pReq->colCmpr.nCols; i++) { for (int32_t i = 0; i < pReq->colCmpr.nCols; i++) {
SColCmpr *p = &pReq->colCmpr.pColCmpr[i]; SColCmpr *p = &pReq->colCmpr.pColCmpr[i];
(*pMetaRsp)->pSchemaExt[i].colId = p->id; (*pMetaRsp)->pSchemaExt[i].colId = p->id;
@ -1135,7 +1247,11 @@ int metaDropTable(SMeta *pMeta, int64_t version, SVDropTbReq *pReq, SArray *tbUi
} }
if (!TSDB_CACHE_NO(pMeta->pVnode->config)) { if (!TSDB_CACHE_NO(pMeta->pVnode->config)) {
(void)tsdbCacheDropTable(pMeta->pVnode->pTsdb, uid, suid, NULL); int32_t ret = tsdbCacheDropTable(pMeta->pVnode->pTsdb, uid, suid, NULL);
if (ret < 0) {
metaError("vgId:%d, failed to drop table:%s uid:%" PRId64 " since %s", TD_VID(pMeta->pVnode), pReq->name, uid,
tstrerror(ret));
}
} }
} }
@ -1233,7 +1349,11 @@ static int32_t metaFilterTableByHash(SMeta *pMeta, SArray *uidList) {
SMetaEntry me = {0}; SMetaEntry me = {0};
SDecoder dc = {0}; SDecoder dc = {0};
tDecoderInit(&dc, pData, nData); tDecoderInit(&dc, pData, nData);
(void)metaDecodeEntry(&dc, &me); code = metaDecodeEntry(&dc, &me);
if (code < 0) {
tDecoderClear(&dc);
return code;
}
if (me.type != TSDB_SUPER_TABLE) { if (me.type != TSDB_SUPER_TABLE) {
char tbFName[TSDB_TABLE_FNAME_LEN + 1]; char tbFName[TSDB_TABLE_FNAME_LEN + 1];
@ -1340,6 +1460,7 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type, tb_uid_t *p
int rc = 0; int rc = 0;
SMetaEntry e = {0}; SMetaEntry e = {0};
SDecoder dc = {0}; SDecoder dc = {0};
int32_t ret = 0;
rc = tdbTbGet(pMeta->pUidIdx, &uid, sizeof(uid), &pData, &nData); rc = tdbTbGet(pMeta->pUidIdx, &uid, sizeof(uid), &pData, &nData);
if (rc < 0) { if (rc < 0) {
@ -1347,7 +1468,11 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type, tb_uid_t *p
} }
int64_t version = ((SUidIdxVal *)pData)[0].version; int64_t version = ((SUidIdxVal *)pData)[0].version;
(void)tdbTbGet(pMeta->pTbDb, &(STbDbKey){.version = version, .uid = uid}, sizeof(STbDbKey), &pData, &nData); rc = tdbTbGet(pMeta->pTbDb, &(STbDbKey){.version = version, .uid = uid}, sizeof(STbDbKey), &pData, &nData);
if (rc < 0) {
tdbFree(pData);
return rc;
}
tDecoderInit(&dc, pData, nData); tDecoderInit(&dc, pData, nData);
rc = metaDecodeEntry(&dc, &e); rc = metaDecodeEntry(&dc, &e);
@ -1370,7 +1495,12 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type, tb_uid_t *p
SMetaEntry stbEntry = {0}; SMetaEntry stbEntry = {0};
tDecoderInit(&tdc, tData, tLen); tDecoderInit(&tdc, tData, tLen);
(void)metaDecodeEntry(&tdc, &stbEntry); int32_t ret = metaDecodeEntry(&tdc, &stbEntry);
if (ret < 0) {
metaError("vgId:%d, failed to decode child table:%s uid:%" PRId64 " since %s", TD_VID(pMeta->pVnode), e.name,
e.ctbEntry.suid, tstrerror(ret));
return ret;
}
if (pSysTbl) *pSysTbl = metaTbInFilterCache(pMeta, stbEntry.name, 1) ? 1 : 0; if (pSysTbl) *pSysTbl = metaTbInFilterCache(pMeta, stbEntry.name, 1) ? 1 : 0;
@ -1378,7 +1508,11 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type, tb_uid_t *p
SSchemaWrapper *pTagSchema = &stbEntry.stbEntry.schemaTag; SSchemaWrapper *pTagSchema = &stbEntry.stbEntry.schemaTag;
if (pTagSchema->nCols == 1 && pTagSchema->pSchema[0].type == TSDB_DATA_TYPE_JSON) { if (pTagSchema->nCols == 1 && pTagSchema->pSchema[0].type == TSDB_DATA_TYPE_JSON) {
pTagColumn = &stbEntry.stbEntry.schemaTag.pSchema[0]; pTagColumn = &stbEntry.stbEntry.schemaTag.pSchema[0];
(void)metaDelJsonVarFromIdx(pMeta, &e, pTagColumn); ret = metaDelJsonVarFromIdx(pMeta, &e, pTagColumn);
if (ret < 0) {
metaError("vgId:%d, failed to delete json var from idx:%s uid:%" PRId64 " since %s", TD_VID(pMeta->pVnode),
e.name, e.uid, tstrerror(ret));
}
} else { } else {
for (int i = 0; i < pTagSchema->nCols; i++) { for (int i = 0; i < pTagSchema->nCols; i++) {
pTagColumn = &stbEntry.stbEntry.schemaTag.pSchema[i]; pTagColumn = &stbEntry.stbEntry.schemaTag.pSchema[i];
@ -1406,7 +1540,11 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type, tb_uid_t *p
if (metaCreateTagIdxKey(e.ctbEntry.suid, pTagColumn->colId, pTagData, nTagData, pTagColumn->type, uid, if (metaCreateTagIdxKey(e.ctbEntry.suid, pTagColumn->colId, pTagData, nTagData, pTagColumn->type, uid,
&pTagIdxKey, &nTagIdxKey) == 0) { &pTagIdxKey, &nTagIdxKey) == 0) {
(void)tdbTbDelete(pMeta->pTagIdx, pTagIdxKey, nTagIdxKey, pMeta->txn); ret = tdbTbDelete(pMeta->pTagIdx, pTagIdxKey, nTagIdxKey, pMeta->txn);
if (ret < 0) {
metaError("vgId:%d, failed to delete tag idx key:%s uid:%" PRId64 " since %s", TD_VID(pMeta->pVnode),
e.name, e.uid, tstrerror(ret));
}
} }
metaDestroyTagIdxKey(pTagIdxKey); metaDestroyTagIdxKey(pTagIdxKey);
pTagIdxKey = NULL; pTagIdxKey = NULL;
@ -1418,9 +1556,21 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type, tb_uid_t *p
} }
} }
(void)tdbTbDelete(pMeta->pTbDb, &(STbDbKey){.version = version, .uid = uid}, sizeof(STbDbKey), pMeta->txn); ret = tdbTbDelete(pMeta->pTbDb, &(STbDbKey){.version = version, .uid = uid}, sizeof(STbDbKey), pMeta->txn);
(void)tdbTbDelete(pMeta->pNameIdx, e.name, strlen(e.name) + 1, pMeta->txn); if (ret < 0) {
(void)tdbTbDelete(pMeta->pUidIdx, &uid, sizeof(uid), pMeta->txn); metaError("vgId:%d, failed to delete table:%s uid:%" PRId64 " since %s", TD_VID(pMeta->pVnode), e.name, e.uid,
tstrerror(ret));
}
ret = tdbTbDelete(pMeta->pNameIdx, e.name, strlen(e.name) + 1, pMeta->txn);
if (ret < 0) {
metaError("vgId:%d, failed to delete name idx:%s uid:%" PRId64 " since %s", TD_VID(pMeta->pVnode), e.name, e.uid,
tstrerror(ret));
}
ret = tdbTbDelete(pMeta->pUidIdx, &uid, sizeof(uid), pMeta->txn);
if (ret < 0) {
metaError("vgId:%d, failed to delete uid idx:%s uid:%" PRId64 " since %s", TD_VID(pMeta->pVnode), e.name, e.uid,
tstrerror(ret));
}
if (e.type == TSDB_CHILD_TABLE || e.type == TSDB_NORMAL_TABLE) metaDeleteBtimeIdx(pMeta, &e); if (e.type == TSDB_CHILD_TABLE || e.type == TSDB_NORMAL_TABLE) metaDeleteBtimeIdx(pMeta, &e);
if (e.type == TSDB_NORMAL_TABLE) metaDeleteNcolIdx(pMeta, &e); if (e.type == TSDB_NORMAL_TABLE) metaDeleteNcolIdx(pMeta, &e);
@ -1428,13 +1578,25 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type, tb_uid_t *p
if (e.type != TSDB_SUPER_TABLE) metaDeleteTtl(pMeta, &e); if (e.type != TSDB_SUPER_TABLE) metaDeleteTtl(pMeta, &e);
if (e.type == TSDB_CHILD_TABLE) { if (e.type == TSDB_CHILD_TABLE) {
(void)tdbTbDelete(pMeta->pCtbIdx, &(SCtbIdxKey){.suid = e.ctbEntry.suid, .uid = uid}, sizeof(SCtbIdxKey), ret =
pMeta->txn); tdbTbDelete(pMeta->pCtbIdx, &(SCtbIdxKey){.suid = e.ctbEntry.suid, .uid = uid}, sizeof(SCtbIdxKey), pMeta->txn);
if (ret < 0) {
metaError("vgId:%d, failed to delete ctb idx:%s uid:%" PRId64 " since %s", TD_VID(pMeta->pVnode), e.name, e.uid,
tstrerror(ret));
}
--pMeta->pVnode->config.vndStats.numOfCTables; --pMeta->pVnode->config.vndStats.numOfCTables;
(void)metaUpdateStbStats(pMeta, e.ctbEntry.suid, -1, 0); metaUpdateStbStats(pMeta, e.ctbEntry.suid, -1, 0);
(void)metaUidCacheClear(pMeta, e.ctbEntry.suid); ret = metaUidCacheClear(pMeta, e.ctbEntry.suid);
(void)metaTbGroupCacheClear(pMeta, e.ctbEntry.suid); if (ret < 0) {
metaError("vgId:%d, failed to clear uid cache:%s uid:%" PRId64 " since %s", TD_VID(pMeta->pVnode), e.name,
e.ctbEntry.suid, tstrerror(ret));
}
ret = metaTbGroupCacheClear(pMeta, e.ctbEntry.suid);
if (ret < 0) {
metaError("vgId:%d, failed to clear group cache:%s uid:%" PRId64 " since %s", TD_VID(pMeta->pVnode), e.name,
e.ctbEntry.suid, tstrerror(ret));
}
/* /*
if (!TSDB_CACHE_NO(pMeta->pVnode->config)) { if (!TSDB_CACHE_NO(pMeta->pVnode->config)) {
tsdbCacheDropTable(pMeta->pVnode->pTsdb, e.uid, e.ctbEntry.suid, NULL); tsdbCacheDropTable(pMeta->pVnode->pTsdb, e.uid, e.ctbEntry.suid, NULL);
@ -1452,16 +1614,36 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type, tb_uid_t *p
} }
*/ */
} else if (e.type == TSDB_SUPER_TABLE) { } else if (e.type == TSDB_SUPER_TABLE) {
(void)tdbTbDelete(pMeta->pSuidIdx, &e.uid, sizeof(tb_uid_t), pMeta->txn); ret = tdbTbDelete(pMeta->pSuidIdx, &e.uid, sizeof(tb_uid_t), pMeta->txn);
if (ret < 0) {
metaError("vgId:%d, failed to delete suid idx:%s uid:%" PRId64 " since %s", TD_VID(pMeta->pVnode), e.name, e.uid,
tstrerror(ret));
}
// drop schema.db (todo) // drop schema.db (todo)
(void)metaStatsCacheDrop(pMeta, uid); ret = metaStatsCacheDrop(pMeta, uid);
(void)metaUidCacheClear(pMeta, uid); if (ret < 0) {
(void)metaTbGroupCacheClear(pMeta, uid); metaError("vgId:%d, failed to drop stats cache:%s uid:%" PRId64 " since %s", TD_VID(pMeta->pVnode), e.name, e.uid,
tstrerror(ret));
}
ret = metaUidCacheClear(pMeta, uid);
if (ret < 0) {
metaError("vgId:%d, failed to clear uid cache:%s uid:%" PRId64 " since %s", TD_VID(pMeta->pVnode), e.name, e.uid,
tstrerror(ret));
}
ret = metaTbGroupCacheClear(pMeta, uid);
if (ret < 0) {
metaError("vgId:%d, failed to clear group cache:%s uid:%" PRId64 " since %s", TD_VID(pMeta->pVnode), e.name,
e.uid, tstrerror(ret));
}
--pMeta->pVnode->config.vndStats.numOfSTables; --pMeta->pVnode->config.vndStats.numOfSTables;
} }
(void)metaCacheDrop(pMeta, uid); ret = metaCacheDrop(pMeta, uid);
if (ret < 0) {
metaError("vgId:%d, failed to drop cache:%s uid:%" PRId64 " since %s", TD_VID(pMeta->pVnode), e.name, e.uid,
tstrerror(ret));
}
tDecoderClear(&dc); tDecoderClear(&dc);
tdbFree(pData); tdbFree(pData);
@ -1535,21 +1717,21 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
TBC *pUidIdxc = NULL; TBC *pUidIdxc = NULL;
TAOS_CHECK_RETURN(tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, NULL)); TAOS_CHECK_RETURN(tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, NULL));
(void)tdbTbcMoveTo(pUidIdxc, &uid, sizeof(uid), &c); ret = tdbTbcMoveTo(pUidIdxc, &uid, sizeof(uid), &c);
if (c != 0) { if (c != 0) {
tdbTbcClose(pUidIdxc); tdbTbcClose(pUidIdxc);
metaError("meta/table: invalide c: %" PRId32 " alt tb column failed.", c); metaError("meta/table: invalide c: %" PRId32 " alt tb column failed.", c);
return TSDB_CODE_FAILED; return TSDB_CODE_FAILED;
} }
(void)tdbTbcGet(pUidIdxc, NULL, NULL, &pData, &nData); ret = tdbTbcGet(pUidIdxc, NULL, NULL, &pData, &nData);
oversion = ((SUidIdxVal *)pData)[0].version; oversion = ((SUidIdxVal *)pData)[0].version;
// search table.db // search table.db
TBC *pTbDbc = NULL; TBC *pTbDbc = NULL;
TAOS_CHECK_RETURN(tdbTbcOpen(pMeta->pTbDb, &pTbDbc, NULL)); TAOS_CHECK_RETURN(tdbTbcOpen(pMeta->pTbDb, &pTbDbc, NULL));
(void)tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = uid, .version = oversion}), sizeof(STbDbKey), &c); ret = tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = uid, .version = oversion}), sizeof(STbDbKey), &c);
if (c != 0) { if (c != 0) {
tdbTbcClose(pUidIdxc); tdbTbcClose(pUidIdxc);
tdbTbcClose(pTbDbc); tdbTbcClose(pTbDbc);
@ -1557,13 +1739,13 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
return TSDB_CODE_FAILED; return TSDB_CODE_FAILED;
} }
(void)tdbTbcGet(pTbDbc, NULL, NULL, &pData, &nData); ret = tdbTbcGet(pTbDbc, NULL, NULL, &pData, &nData);
// get table entry // get table entry
SDecoder dc = {0}; SDecoder dc = {0};
if ((entry.pBuf = taosMemoryMalloc(nData)) == NULL) { if ((entry.pBuf = taosMemoryMalloc(nData)) == NULL) {
(void)tdbTbcClose(pUidIdxc); tdbTbcClose(pUidIdxc);
(void)tdbTbcClose(pTbDbc); tdbTbcClose(pTbDbc);
return terrno; return terrno;
} }
memcpy(entry.pBuf, pData, nData); memcpy(entry.pBuf, pData, nData);

View File

@ -1051,7 +1051,9 @@ _end:
return code; return code;
} }
void tMergeTreeAddIter(SMergeTree *pMTree, SLDataIter *pIter) { (void)tRBTreePut(&pMTree->rbt, (SRBTreeNode *)pIter); } void tMergeTreeAddIter(SMergeTree *pMTree, SLDataIter *pIter) {
SRBTreeNode *node = tRBTreePut(&pMTree->rbt, (SRBTreeNode *)pIter);
}
bool tMergeTreeIgnoreEarlierTs(SMergeTree *pMTree) { return pMTree->ignoreEarlierTs; } bool tMergeTreeIgnoreEarlierTs(SMergeTree *pMTree) { return pMTree->ignoreEarlierTs; }