enh: clear useless asserts
This commit is contained in:
parent
0c23f625f8
commit
720ab67431
|
@ -1403,7 +1403,6 @@ void tRowKeyAssign(SRowKey *pDst, SRowKey *pSrc) {
|
||||||
pVal->val = pSrc->pks[i].val;
|
pVal->val = pSrc->pks[i].val;
|
||||||
} else {
|
} else {
|
||||||
pVal->nData = pSrc->pks[i].nData;
|
pVal->nData = pSrc->pks[i].nData;
|
||||||
ASSERT(pSrc->pks[i].pData != NULL);
|
|
||||||
(void)memcpy(pVal->pData, pSrc->pks[i].pData, pVal->nData);
|
(void)memcpy(pVal->pData, pSrc->pks[i].pData, pVal->nData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2517,7 +2516,7 @@ static FORCE_INLINE int32_t tColDataUpdateValue70(SColData *pColData, uint8_t *p
|
||||||
return tColDataPutValue(pColData, pData, nData);
|
return tColDataPutValue(pColData, pData, nData);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ASSERT(0);
|
return TSDB_CODE_INVALID_PARA;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -2760,7 +2759,9 @@ int32_t tColDataCompress(SColData *colData, SColDataCompressInfo *info, SBuffer
|
||||||
int32_t code;
|
int32_t code;
|
||||||
SBuffer local;
|
SBuffer local;
|
||||||
|
|
||||||
ASSERT(colData->nVal > 0);
|
if (!(colData->nVal > 0)) {
|
||||||
|
return TSDB_CODE_INVALID_PARA;
|
||||||
|
}
|
||||||
|
|
||||||
(*info) = (SColDataCompressInfo){
|
(*info) = (SColDataCompressInfo){
|
||||||
.cmprAlg = info->cmprAlg,
|
.cmprAlg = info->cmprAlg,
|
||||||
|
@ -3217,7 +3218,6 @@ void tColDataArrGetRowKey(SColData *aColData, int32_t nColData, int32_t iRow, SR
|
||||||
|
|
||||||
for (int i = 1; i < nColData; i++) {
|
for (int i = 1; i < nColData; i++) {
|
||||||
if (aColData[i].cflag & COL_IS_KEY) {
|
if (aColData[i].cflag & COL_IS_KEY) {
|
||||||
ASSERT(aColData->flag == HAS_VALUE);
|
|
||||||
tColDataGetValue4(&aColData[i], iRow, &cv);
|
tColDataGetValue4(&aColData[i], iRow, &cv);
|
||||||
key->pks[key->numOfPKs++] = cv.value;
|
key->pks[key->numOfPKs++] = cv.value;
|
||||||
} else {
|
} else {
|
||||||
|
@ -3379,8 +3379,6 @@ static void tColDataMergeImpl(SColData *pColData, int32_t iStart, int32_t iEnd /
|
||||||
iv < (pColData->nVal - 1) ? pColData->aOffset[iv + 1] - pColData->aOffset[iv]
|
iv < (pColData->nVal - 1) ? pColData->aOffset[iv + 1] - pColData->aOffset[iv]
|
||||||
: pColData->nData - pColData->aOffset[iv]);
|
: pColData->nData - pColData->aOffset[iv]);
|
||||||
}
|
}
|
||||||
// TODO
|
|
||||||
ASSERT(0);
|
|
||||||
} else {
|
} else {
|
||||||
if (iv != iStart) {
|
if (iv != iStart) {
|
||||||
(void)memcpy(&pColData->pData[TYPE_BYTES[pColData->type] * iStart],
|
(void)memcpy(&pColData->pData[TYPE_BYTES[pColData->type] * iStart],
|
||||||
|
|
|
@ -92,7 +92,6 @@ static int32_t tsdbTFileSetToFSetPartition(STFileSet* fset, STsdbFSetPartition**
|
||||||
for (int32_t ftype = TSDB_FTYPE_MIN; ftype < TSDB_FTYPE_MAX; ++ftype) {
|
for (int32_t ftype = TSDB_FTYPE_MIN; ftype < TSDB_FTYPE_MAX; ++ftype) {
|
||||||
if (fset->farr[ftype] == NULL) continue;
|
if (fset->farr[ftype] == NULL) continue;
|
||||||
typ = tsdbFTypeToFRangeType(ftype);
|
typ = tsdbFTypeToFRangeType(ftype);
|
||||||
ASSERT(typ < TSDB_FSET_RANGE_TYP_MAX);
|
|
||||||
STFile* f = fset->farr[ftype]->f;
|
STFile* f = fset->farr[ftype]->f;
|
||||||
if (f->maxVer > fset->maxVerValid) {
|
if (f->maxVer > fset->maxVerValid) {
|
||||||
corrupt = true;
|
corrupt = true;
|
||||||
|
@ -103,8 +102,7 @@ static int32_t tsdbTFileSetToFSetPartition(STFileSet* fset, STsdbFSetPartition**
|
||||||
}
|
}
|
||||||
count++;
|
count++;
|
||||||
SVersionRange vr = {.minVer = f->minVer, .maxVer = f->maxVer};
|
SVersionRange vr = {.minVer = f->minVer, .maxVer = f->maxVer};
|
||||||
code = TARRAY2_SORT_INSERT(&p->verRanges[typ], vr, tVersionRangeCmprFn);
|
(void)TARRAY2_SORT_INSERT(&p->verRanges[typ], vr, tVersionRangeCmprFn);
|
||||||
ASSERT(code == 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
typ = TSDB_FSET_RANGE_TYP_STT;
|
typ = TSDB_FSET_RANGE_TYP_STT;
|
||||||
|
@ -122,14 +120,12 @@ static int32_t tsdbTFileSetToFSetPartition(STFileSet* fset, STsdbFSetPartition**
|
||||||
}
|
}
|
||||||
count++;
|
count++;
|
||||||
SVersionRange vr = {.minVer = f->minVer, .maxVer = f->maxVer};
|
SVersionRange vr = {.minVer = f->minVer, .maxVer = f->maxVer};
|
||||||
code = TARRAY2_SORT_INSERT(&p->verRanges[typ], vr, tVersionRangeCmprFn);
|
(void)TARRAY2_SORT_INSERT(&p->verRanges[typ], vr, tVersionRangeCmprFn);
|
||||||
ASSERT(code == 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (corrupt && count == 0) {
|
if (corrupt && count == 0) {
|
||||||
SVersionRange vr = {.minVer = VERSION_MIN, .maxVer = fset->maxVerValid};
|
SVersionRange vr = {.minVer = VERSION_MIN, .maxVer = fset->maxVerValid};
|
||||||
code = TARRAY2_SORT_INSERT(&p->verRanges[typ], vr, tVersionRangeCmprFn);
|
(void)TARRAY2_SORT_INSERT(&p->verRanges[typ], vr, tVersionRangeCmprFn);
|
||||||
ASSERT(code == 0);
|
|
||||||
}
|
}
|
||||||
ppSP[0] = p;
|
ppSP[0] = p;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -186,8 +182,7 @@ int32_t tsdbFSetPartListToRangeDiff(STsdbFSetPartList* pList, TFileSetRangeArray
|
||||||
r->sver = maxVerValid + 1;
|
r->sver = maxVerValid + 1;
|
||||||
r->ever = VERSION_MAX;
|
r->ever = VERSION_MAX;
|
||||||
tsdbDebug("range diff fid:%" PRId64 ", sver:%" PRId64 ", ever:%" PRId64, part->fid, r->sver, r->ever);
|
tsdbDebug("range diff fid:%" PRId64 ", sver:%" PRId64 ", ever:%" PRId64, part->fid, r->sver, r->ever);
|
||||||
int32_t code = TARRAY2_SORT_INSERT(pDiff, r, tsdbTFileSetRangeCmprFn);
|
(void)TARRAY2_SORT_INSERT(pDiff, r, tsdbTFileSetRangeCmprFn);
|
||||||
ASSERT(code == 0);
|
|
||||||
}
|
}
|
||||||
ppRanges[0] = pDiff;
|
ppRanges[0] = pDiff;
|
||||||
|
|
||||||
|
@ -360,9 +355,7 @@ static STsdbFSetPartList* tsdbSnapGetFSetPartList(STFileSystem* fs) {
|
||||||
terrno = code;
|
terrno = code;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ASSERT(pItem != NULL);
|
(void)TARRAY2_SORT_INSERT(pList, pItem, tsdbFSetPartCmprFn);
|
||||||
code = TARRAY2_SORT_INSERT(pList, pItem, tsdbFSetPartCmprFn);
|
|
||||||
ASSERT(code == 0);
|
|
||||||
}
|
}
|
||||||
(void)taosThreadMutexUnlock(&fs->tsdb->mutex);
|
(void)taosThreadMutexUnlock(&fs->tsdb->mutex);
|
||||||
|
|
||||||
|
@ -400,7 +393,9 @@ static int32_t tsdbPartitionInfoInit(SVnode* pVnode, STsdbPartitionInfo* pInfo)
|
||||||
pInfo->vgId = TD_VID(pVnode);
|
pInfo->vgId = TD_VID(pVnode);
|
||||||
pInfo->tsdbMaxCnt = (!VND_IS_RSMA(pVnode) ? 1 : TSDB_RETENTION_MAX);
|
pInfo->tsdbMaxCnt = (!VND_IS_RSMA(pVnode) ? 1 : TSDB_RETENTION_MAX);
|
||||||
|
|
||||||
ASSERT(sizeof(pInfo->subTyps) == sizeof(subTyps));
|
if (!(sizeof(pInfo->subTyps) == sizeof(subTyps))) {
|
||||||
|
return TSDB_CODE_INVALID_PARA;
|
||||||
|
}
|
||||||
memcpy(pInfo->subTyps, (char*)subTyps, sizeof(subTyps));
|
memcpy(pInfo->subTyps, (char*)subTyps, sizeof(subTyps));
|
||||||
|
|
||||||
// fset partition list
|
// fset partition list
|
||||||
|
@ -437,8 +432,7 @@ static int32_t tsdbPartitionInfoSerialize(STsdbPartitionInfo* pInfo, uint8_t* bu
|
||||||
for (int32_t j = 0; j < pInfo->tsdbMaxCnt; ++j) {
|
for (int32_t j = 0; j < pInfo->tsdbMaxCnt; ++j) {
|
||||||
SSyncTLV* pSubHead = (void*)((char*)buf + offset);
|
SSyncTLV* pSubHead = (void*)((char*)buf + offset);
|
||||||
int32_t valOffset = offset + sizeof(*pSubHead);
|
int32_t valOffset = offset + sizeof(*pSubHead);
|
||||||
ASSERT(pSubHead->val == (char*)buf + valOffset);
|
int32_t code = tSerializeTsdbFSetPartList(pSubHead->val, bufLen - valOffset, pInfo->pLists[j], &tlen);
|
||||||
int32_t code = tSerializeTsdbFSetPartList(pSubHead->val, bufLen - valOffset, pInfo->pLists[j], &tlen);
|
|
||||||
if (code) {
|
if (code) {
|
||||||
tsdbError("vgId:%d, failed to serialize fset partition list of tsdb %d since %s", pInfo->vgId, j, terrstr());
|
tsdbError("vgId:%d, failed to serialize fset partition list of tsdb %d since %s", pInfo->vgId, j, terrstr());
|
||||||
return code;
|
return code;
|
||||||
|
@ -574,7 +568,6 @@ static int32_t tsdbSnapPrepDealWithSnapInfo(SVnode* pVnode, SSnapshot* pSnap, ST
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tsdbSnapPrepDescription(SVnode* pVnode, SSnapshot* pSnap) {
|
int32_t tsdbSnapPrepDescription(SVnode* pVnode, SSnapshot* pSnap) {
|
||||||
ASSERT(pSnap->type == TDMT_SYNC_PREP_SNAPSHOT || pSnap->type == TDMT_SYNC_PREP_SNAPSHOT_REPLY);
|
|
||||||
STsdbPartitionInfo partitionInfo = {0};
|
STsdbPartitionInfo partitionInfo = {0};
|
||||||
int code = 0;
|
int code = 0;
|
||||||
STsdbPartitionInfo* pInfo = &partitionInfo;
|
STsdbPartitionInfo* pInfo = &partitionInfo;
|
||||||
|
@ -616,7 +609,6 @@ int32_t tsdbSnapPrepDescription(SVnode* pVnode, SSnapshot* pSnap) {
|
||||||
goto _out;
|
goto _out;
|
||||||
}
|
}
|
||||||
offset += tlen;
|
offset += tlen;
|
||||||
ASSERT(offset <= bufLen);
|
|
||||||
|
|
||||||
if ((tlen = tsdbRepOptsSerialize(&opts, buf + offset, bufLen - offset)) < 0) {
|
if ((tlen = tsdbRepOptsSerialize(&opts, buf + offset, bufLen - offset)) < 0) {
|
||||||
code = tlen;
|
code = tlen;
|
||||||
|
@ -624,7 +616,6 @@ int32_t tsdbSnapPrepDescription(SVnode* pVnode, SSnapshot* pSnap) {
|
||||||
goto _out;
|
goto _out;
|
||||||
}
|
}
|
||||||
offset += tlen;
|
offset += tlen;
|
||||||
ASSERT(offset <= bufLen);
|
|
||||||
|
|
||||||
// set header of info data
|
// set header of info data
|
||||||
SSyncTLV* pHead = pSnap->data;
|
SSyncTLV* pHead = pSnap->data;
|
||||||
|
|
|
@ -170,11 +170,8 @@ static int64_t tsdbSnapRAWReadPeek(SDataFileRAWReader* reader) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDataFileRAWReader* tsdbSnapRAWReaderIterNext(STsdbSnapRAWReader* reader) {
|
static SDataFileRAWReader* tsdbSnapRAWReaderIterNext(STsdbSnapRAWReader* reader) {
|
||||||
ASSERT(reader->dataIter->idx <= reader->dataIter->count);
|
|
||||||
|
|
||||||
while (reader->dataIter->idx < reader->dataIter->count) {
|
while (reader->dataIter->idx < reader->dataIter->count) {
|
||||||
SDataFileRAWReader* dataReader = TARRAY2_GET(reader->dataReaderArr, reader->dataIter->idx);
|
SDataFileRAWReader* dataReader = TARRAY2_GET(reader->dataReaderArr, reader->dataIter->idx);
|
||||||
ASSERT(dataReader);
|
|
||||||
if (dataReader->ctx->offset < dataReader->config->file.size) {
|
if (dataReader->ctx->offset < dataReader->config->file.size) {
|
||||||
return dataReader;
|
return dataReader;
|
||||||
}
|
}
|
||||||
|
@ -196,7 +193,6 @@ static int32_t tsdbSnapRAWReadNext(STsdbSnapRAWReader* reader, SSnapDataHdr** pp
|
||||||
|
|
||||||
// prepare
|
// prepare
|
||||||
int64_t dataLength = tsdbSnapRAWReadPeek(dataReader);
|
int64_t dataLength = tsdbSnapRAWReadPeek(dataReader);
|
||||||
ASSERT(dataLength > 0);
|
|
||||||
|
|
||||||
void* pBuf = taosMemoryCalloc(1, sizeof(SSnapDataHdr) + sizeof(STsdbDataRAWBlockHeader) + dataLength);
|
void* pBuf = taosMemoryCalloc(1, sizeof(SSnapDataHdr) + sizeof(STsdbDataRAWBlockHeader) + dataLength);
|
||||||
if (pBuf == NULL) {
|
if (pBuf == NULL) {
|
||||||
|
@ -217,7 +213,6 @@ static int32_t tsdbSnapRAWReadNext(STsdbSnapRAWReader* reader, SSnapDataHdr** pp
|
||||||
|
|
||||||
// finish
|
// finish
|
||||||
dataReader->ctx->offset += pBlock->dataLength;
|
dataReader->ctx->offset += pBlock->dataLength;
|
||||||
ASSERT(dataReader->ctx->offset <= dataReader->config->file.size);
|
|
||||||
ppData[0] = pBuf;
|
ppData[0] = pBuf;
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
|
@ -247,8 +242,6 @@ static int32_t tsdbSnapRAWReadBegin(STsdbSnapRAWReader* reader) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int32_t lino = 0;
|
int32_t lino = 0;
|
||||||
|
|
||||||
ASSERT(reader->ctx->fset == NULL);
|
|
||||||
|
|
||||||
if (reader->ctx->fsetArrIdx < TARRAY2_SIZE(reader->fsetArr)) {
|
if (reader->ctx->fsetArrIdx < TARRAY2_SIZE(reader->fsetArr)) {
|
||||||
reader->ctx->fset = TARRAY2_GET(reader->fsetArr, reader->ctx->fsetArrIdx++);
|
reader->ctx->fset = TARRAY2_GET(reader->fsetArr, reader->ctx->fsetArrIdx++);
|
||||||
reader->ctx->isDataDone = false;
|
reader->ctx->isDataDone = false;
|
||||||
|
@ -409,8 +402,6 @@ static int32_t tsdbSnapRAWWriteFileSetBegin(STsdbSnapRAWWriter* writer, int32_t
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int32_t lino = 0;
|
int32_t lino = 0;
|
||||||
|
|
||||||
ASSERT(writer->ctx->fsetWriteBegin == false);
|
|
||||||
|
|
||||||
STFileSet* fset = &(STFileSet){.fid = fid};
|
STFileSet* fset = &(STFileSet){.fid = fid};
|
||||||
|
|
||||||
writer->ctx->fid = fid;
|
writer->ctx->fid = fid;
|
||||||
|
@ -555,8 +546,6 @@ _exit:
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tsdbSnapRAWWrite(STsdbSnapRAWWriter* writer, SSnapDataHdr* hdr) {
|
int32_t tsdbSnapRAWWrite(STsdbSnapRAWWriter* writer, SSnapDataHdr* hdr) {
|
||||||
ASSERT(hdr->type == SNAP_DATA_RAW);
|
|
||||||
|
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int32_t lino = 0;
|
int32_t lino = 0;
|
||||||
|
|
||||||
|
|
|
@ -403,8 +403,6 @@ static const int32_t BLOCK_WITH_ALG_VER = 2;
|
||||||
int32_t tPutBlockCol(SBuffer *buffer, const SBlockCol *pBlockCol, int32_t ver, uint32_t defaultCmprAlg) {
|
int32_t tPutBlockCol(SBuffer *buffer, const SBlockCol *pBlockCol, int32_t ver, uint32_t defaultCmprAlg) {
|
||||||
int32_t code;
|
int32_t code;
|
||||||
|
|
||||||
ASSERT(pBlockCol->flag && (pBlockCol->flag != HAS_NONE));
|
|
||||||
|
|
||||||
if ((code = tBufferPutI16v(buffer, pBlockCol->cid))) return code;
|
if ((code = tBufferPutI16v(buffer, pBlockCol->cid))) return code;
|
||||||
if ((code = tBufferPutI8(buffer, pBlockCol->type))) return code;
|
if ((code = tBufferPutI8(buffer, pBlockCol->type))) return code;
|
||||||
if ((code = tBufferPutI8(buffer, pBlockCol->cflag))) return code;
|
if ((code = tBufferPutI8(buffer, pBlockCol->cflag))) return code;
|
||||||
|
@ -443,8 +441,6 @@ int32_t tGetBlockCol(SBufferReader *br, SBlockCol *pBlockCol, int32_t ver, uint3
|
||||||
if ((code = tBufferGetI8(br, &pBlockCol->flag))) return code;
|
if ((code = tBufferGetI8(br, &pBlockCol->flag))) return code;
|
||||||
if ((code = tBufferGetI32v(br, &pBlockCol->szOrigin))) return code;
|
if ((code = tBufferGetI32v(br, &pBlockCol->szOrigin))) return code;
|
||||||
|
|
||||||
ASSERT(pBlockCol->flag && (pBlockCol->flag != HAS_NONE));
|
|
||||||
|
|
||||||
pBlockCol->szBitmap = 0;
|
pBlockCol->szBitmap = 0;
|
||||||
pBlockCol->szOffset = 0;
|
pBlockCol->szOffset = 0;
|
||||||
pBlockCol->szValue = 0;
|
pBlockCol->szValue = 0;
|
||||||
|
@ -647,7 +643,6 @@ void tColRowGetPrimaryKey(SBlockData *pBlock, int32_t irow, SRowKey *key) {
|
||||||
if (pColData->cflag & COL_IS_KEY) {
|
if (pColData->cflag & COL_IS_KEY) {
|
||||||
SColVal cv;
|
SColVal cv;
|
||||||
tColDataGetValue(pColData, irow, &cv);
|
tColDataGetValue(pColData, irow, &cv);
|
||||||
ASSERT(COL_VAL_IS_VALUE(&cv));
|
|
||||||
key->pks[key->numOfPKs] = cv.value;
|
key->pks[key->numOfPKs] = cv.value;
|
||||||
key->numOfPKs++;
|
key->numOfPKs++;
|
||||||
} else {
|
} else {
|
||||||
|
@ -748,8 +743,6 @@ int32_t tsdbRowMergerAdd(SRowMerger *pMerger, TSDBROW *pRow, STSchema *pTSchema)
|
||||||
jCol = 0;
|
jCol = 0;
|
||||||
pTColumn = &pTSchema->columns[jCol++];
|
pTColumn = &pTSchema->columns[jCol++];
|
||||||
|
|
||||||
ASSERT(pTColumn->type == TSDB_DATA_TYPE_TIMESTAMP);
|
|
||||||
|
|
||||||
*pColVal = COL_VAL_VALUE(pTColumn->colId, ((SValue){.type = pTColumn->type, .val = key.ts}));
|
*pColVal = COL_VAL_VALUE(pTColumn->colId, ((SValue){.type = pTColumn->type, .val = key.ts}));
|
||||||
if (taosArrayPush(pMerger->pArray, pColVal) == NULL) {
|
if (taosArrayPush(pMerger->pArray, pColVal) == NULL) {
|
||||||
code = terrno;
|
code = terrno;
|
||||||
|
@ -800,8 +793,6 @@ int32_t tsdbRowMergerAdd(SRowMerger *pMerger, TSDBROW *pRow, STSchema *pTSchema)
|
||||||
pMerger->version = key.version;
|
pMerger->version = key.version;
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
ASSERT(((SColVal *)pMerger->pArray->pData)->value.val == key.ts);
|
|
||||||
|
|
||||||
for (iCol = 1; iCol < pMerger->pTSchema->numOfCols && jCol < pTSchema->numOfCols; ++iCol) {
|
for (iCol = 1; iCol < pMerger->pTSchema->numOfCols && jCol < pTSchema->numOfCols; ++iCol) {
|
||||||
pTColumn = &pMerger->pTSchema->columns[iCol];
|
pTColumn = &pMerger->pTSchema->columns[iCol];
|
||||||
if (pTSchema->columns[jCol].colId < pTColumn->colId) {
|
if (pTSchema->columns[jCol].colId < pTColumn->colId) {
|
||||||
|
@ -852,7 +843,7 @@ int32_t tsdbRowMergerAdd(SRowMerger *pMerger, TSDBROW *pRow, STSchema *pTSchema)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ASSERT(0 && "dup versions not allowed");
|
return TSDB_CODE_INVALID_PARA;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1164,7 +1155,9 @@ int32_t tBlockDataInit(SBlockData *pBlockData, TABLEID *pId, STSchema *pTSchema,
|
||||||
|
|
||||||
while (pTColumn->colId < aCid[iCid]) {
|
while (pTColumn->colId < aCid[iCid]) {
|
||||||
iColumn++;
|
iColumn++;
|
||||||
ASSERT(iColumn < pTSchema->numOfCols);
|
if (!(iColumn < pTSchema->numOfCols)) {
|
||||||
|
return TSDB_CODE_INVALID_PARA;
|
||||||
|
}
|
||||||
pTColumn = &pTSchema->columns[iColumn];
|
pTColumn = &pTSchema->columns[iColumn];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1272,7 +1265,9 @@ _exit:
|
||||||
int32_t tBlockDataAppendRow(SBlockData *pBlockData, TSDBROW *pRow, STSchema *pTSchema, int64_t uid) {
|
int32_t tBlockDataAppendRow(SBlockData *pBlockData, TSDBROW *pRow, STSchema *pTSchema, int64_t uid) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
ASSERT(pBlockData->suid || pBlockData->uid);
|
if (!(pBlockData->suid || pBlockData->uid)) {
|
||||||
|
return TSDB_CODE_INVALID_PARA;
|
||||||
|
}
|
||||||
|
|
||||||
// uid
|
// uid
|
||||||
if (pBlockData->uid == 0) {
|
if (pBlockData->uid == 0) {
|
||||||
|
@ -1299,7 +1294,7 @@ int32_t tBlockDataAppendRow(SBlockData *pBlockData, TSDBROW *pRow, STSchema *pTS
|
||||||
code = tBlockDataUpsertBlockRow(pBlockData, pRow->pBlockData, pRow->iRow, 0 /* append */);
|
code = tBlockDataUpsertBlockRow(pBlockData, pRow->pBlockData, pRow->iRow, 0 /* append */);
|
||||||
if (code) goto _exit;
|
if (code) goto _exit;
|
||||||
} else {
|
} else {
|
||||||
ASSERT(0);
|
return TSDB_CODE_INVALID_PARA;
|
||||||
}
|
}
|
||||||
pBlockData->nRow++;
|
pBlockData->nRow++;
|
||||||
|
|
||||||
|
@ -1357,7 +1352,6 @@ int32_t tBlockDataUpsertRow(SBlockData *pBlockData, TSDBROW *pRow, STSchema *pTS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SColData *tBlockDataGetColData(SBlockData *pBlockData, int16_t cid) {
|
SColData *tBlockDataGetColData(SBlockData *pBlockData, int16_t cid) {
|
||||||
ASSERT(cid != PRIMARYKEY_TIMESTAMP_COL_ID);
|
|
||||||
int32_t lidx = 0;
|
int32_t lidx = 0;
|
||||||
int32_t ridx = pBlockData->nColData - 1;
|
int32_t ridx = pBlockData->nColData - 1;
|
||||||
|
|
||||||
|
@ -1627,7 +1621,9 @@ static int32_t tBlockDataCompressKeyPart(SBlockData *bData, SDiskDataHdr *hdr, S
|
||||||
|
|
||||||
// primary keys
|
// primary keys
|
||||||
for (hdr->numOfPKs = 0; hdr->numOfPKs < bData->nColData; hdr->numOfPKs++) {
|
for (hdr->numOfPKs = 0; hdr->numOfPKs < bData->nColData; hdr->numOfPKs++) {
|
||||||
ASSERT(hdr->numOfPKs <= TD_MAX_PK_COLS);
|
if (!(hdr->numOfPKs <= TD_MAX_PK_COLS)) {
|
||||||
|
return TSDB_CODE_INVALID_PARA;
|
||||||
|
}
|
||||||
|
|
||||||
SBlockCol *blockCol = &hdr->primaryBlockCols[hdr->numOfPKs];
|
SBlockCol *blockCol = &hdr->primaryBlockCols[hdr->numOfPKs];
|
||||||
SColData *colData = tBlockDataGetColDataByIdx(bData, hdr->numOfPKs);
|
SColData *colData = tBlockDataGetColDataByIdx(bData, hdr->numOfPKs);
|
||||||
|
@ -1762,8 +1758,12 @@ int32_t tBlockDataDecompressKeyPart(const SDiskDataHdr *hdr, SBufferReader *br,
|
||||||
for (int i = 0; i < hdr->numOfPKs; i++) {
|
for (int i = 0; i < hdr->numOfPKs; i++) {
|
||||||
const SBlockCol *blockCol = &hdr->primaryBlockCols[i];
|
const SBlockCol *blockCol = &hdr->primaryBlockCols[i];
|
||||||
|
|
||||||
ASSERT(blockCol->flag == HAS_VALUE);
|
if (!(blockCol->flag == HAS_VALUE)) {
|
||||||
ASSERT(blockCol->cflag & COL_IS_KEY);
|
TSDB_CHECK_CODE(code = TSDB_CODE_FILE_CORRUPTED, lino, _exit);
|
||||||
|
}
|
||||||
|
if (!(blockCol->cflag & COL_IS_KEY)) {
|
||||||
|
TSDB_CHECK_CODE(code = TSDB_CODE_FILE_CORRUPTED, lino, _exit);
|
||||||
|
}
|
||||||
|
|
||||||
code = tBlockDataDecompressColData(hdr, blockCol, br, blockData, assist);
|
code = tBlockDataDecompressColData(hdr, blockCol, br, blockData, assist);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
|
@ -248,7 +248,6 @@ int vnodeDecodeConfig(const SJson *pJson, void *pObj) {
|
||||||
}
|
}
|
||||||
for (int32_t i = 0; i < nRetention; ++i) {
|
for (int32_t i = 0; i < nRetention; ++i) {
|
||||||
SJson *pNodeRetention = tjsonGetArrayItem(pNodeRetentions, i);
|
SJson *pNodeRetention = tjsonGetArrayItem(pNodeRetentions, i);
|
||||||
ASSERT(pNodeRetention != NULL);
|
|
||||||
tjsonGetNumberValue(pNodeRetention, "freq", (pCfg->tsdbCfg.retentions)[i].freq, code);
|
tjsonGetNumberValue(pNodeRetention, "freq", (pCfg->tsdbCfg.retentions)[i].freq, code);
|
||||||
if (code) return code;
|
if (code) return code;
|
||||||
tjsonGetNumberValue(pNodeRetention, "freqUnit", (pCfg->tsdbCfg.retentions)[i].freqUnit, code);
|
tjsonGetNumberValue(pNodeRetention, "freqUnit", (pCfg->tsdbCfg.retentions)[i].freqUnit, code);
|
||||||
|
|
|
@ -73,7 +73,10 @@ struct SVSnapReader {
|
||||||
};
|
};
|
||||||
|
|
||||||
static TFileSetRangeArray **vnodeSnapReaderGetTsdbRanges(SVSnapReader *pReader, int32_t tsdbTyp) {
|
static TFileSetRangeArray **vnodeSnapReaderGetTsdbRanges(SVSnapReader *pReader, int32_t tsdbTyp) {
|
||||||
ASSERTS(sizeof(pReader->pRsmaRanges) / sizeof(pReader->pRsmaRanges[0]) == 2, "Unexpected array size");
|
if (!(sizeof(pReader->pRsmaRanges) / sizeof(pReader->pRsmaRanges[0]) == 2)) {
|
||||||
|
terrno = TSDB_CODE_INVALID_PARA;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
switch (tsdbTyp) {
|
switch (tsdbTyp) {
|
||||||
case SNAP_DATA_TSDB:
|
case SNAP_DATA_TSDB:
|
||||||
return &pReader->pRanges;
|
return &pReader->pRanges;
|
||||||
|
@ -147,7 +150,6 @@ static int32_t vnodeSnapReaderDealWithSnapInfo(SVSnapReader *pReader, SSnapshotP
|
||||||
pReader->tsdbRAWDone = true;
|
pReader->tsdbRAWDone = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT(pReader->tsdbDone != pReader->tsdbRAWDone);
|
|
||||||
vInfo("vgId:%d, vnode snap writer enabled replication mode: %s", TD_VID(pVnode),
|
vInfo("vgId:%d, vnode snap writer enabled replication mode: %s", TD_VID(pVnode),
|
||||||
(pReader->tsdbDone ? "raw" : "normal"));
|
(pReader->tsdbDone ? "raw" : "normal"));
|
||||||
}
|
}
|
||||||
|
@ -177,7 +179,6 @@ int32_t vnodeSnapReaderOpen(SVnode *pVnode, SSnapshotParam *pParam, SVSnapReader
|
||||||
|
|
||||||
// open tsdb snapshot raw reader
|
// open tsdb snapshot raw reader
|
||||||
if (!pReader->tsdbRAWDone) {
|
if (!pReader->tsdbRAWDone) {
|
||||||
ASSERT(pReader->sver == 0);
|
|
||||||
code = tsdbSnapRAWReaderOpen(pVnode->pTsdb, ever, SNAP_DATA_RAW, &pReader->pTsdbRAWReader);
|
code = tsdbSnapRAWReaderOpen(pVnode->pTsdb, ever, SNAP_DATA_RAW, &pReader->pTsdbRAWReader);
|
||||||
if (code) goto _exit;
|
if (code) goto _exit;
|
||||||
}
|
}
|
||||||
|
@ -339,7 +340,6 @@ int32_t vnodeSnapRead(SVSnapReader *pReader, uint8_t **ppData, uint32_t *nData)
|
||||||
if (!pReader->tsdbRAWDone) {
|
if (!pReader->tsdbRAWDone) {
|
||||||
// open if not
|
// open if not
|
||||||
if (pReader->pTsdbRAWReader == NULL) {
|
if (pReader->pTsdbRAWReader == NULL) {
|
||||||
ASSERT(pReader->sver == 0);
|
|
||||||
code = tsdbSnapRAWReaderOpen(pReader->pVnode->pTsdb, pReader->ever, SNAP_DATA_RAW, &pReader->pTsdbRAWReader);
|
code = tsdbSnapRAWReaderOpen(pReader->pVnode->pTsdb, pReader->ever, SNAP_DATA_RAW, &pReader->pTsdbRAWReader);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
}
|
}
|
||||||
|
@ -518,7 +518,6 @@ struct SVSnapWriter {
|
||||||
};
|
};
|
||||||
|
|
||||||
TFileSetRangeArray **vnodeSnapWriterGetTsdbRanges(SVSnapWriter *pWriter, int32_t tsdbTyp) {
|
TFileSetRangeArray **vnodeSnapWriterGetTsdbRanges(SVSnapWriter *pWriter, int32_t tsdbTyp) {
|
||||||
ASSERTS(sizeof(pWriter->pRsmaRanges) / sizeof(pWriter->pRsmaRanges[0]) == 2, "Unexpected array size");
|
|
||||||
switch (tsdbTyp) {
|
switch (tsdbTyp) {
|
||||||
case SNAP_DATA_TSDB:
|
case SNAP_DATA_TSDB:
|
||||||
return &pWriter->pRanges;
|
return &pWriter->pRanges;
|
||||||
|
@ -674,7 +673,6 @@ int32_t vnodeSnapWriterClose(SVSnapWriter *pWriter, int8_t rollback, SSnapshot *
|
||||||
|
|
||||||
// commit json
|
// commit json
|
||||||
if (!rollback) {
|
if (!rollback) {
|
||||||
ASSERT(pVnode->config.vgId == pWriter->info.config.vgId);
|
|
||||||
pWriter->info.state.committed = pWriter->ever;
|
pWriter->info.state.committed = pWriter->ever;
|
||||||
pVnode->config = pWriter->info.config;
|
pVnode->config = pWriter->info.config;
|
||||||
pVnode->state = (SVState){.committed = pWriter->info.state.committed,
|
pVnode->state = (SVState){.committed = pWriter->info.state.committed,
|
||||||
|
@ -794,7 +792,9 @@ int32_t vnodeSnapWrite(SVSnapWriter *pWriter, uint8_t *pData, uint32_t nData) {
|
||||||
SSnapDataHdr *pHdr = (SSnapDataHdr *)pData;
|
SSnapDataHdr *pHdr = (SSnapDataHdr *)pData;
|
||||||
SVnode *pVnode = pWriter->pVnode;
|
SVnode *pVnode = pWriter->pVnode;
|
||||||
|
|
||||||
ASSERT(pHdr->size + sizeof(SSnapDataHdr) == nData);
|
if (!(pHdr->size + sizeof(SSnapDataHdr) == nData)) {
|
||||||
|
return TSDB_CODE_INVALID_PARA;
|
||||||
|
}
|
||||||
|
|
||||||
if (pHdr->index != pWriter->index + 1) {
|
if (pHdr->index != pWriter->index + 1) {
|
||||||
vError("vgId:%d, unexpected vnode snapshot msg. index:%" PRId64 ", expected index:%" PRId64, TD_VID(pVnode),
|
vError("vgId:%d, unexpected vnode snapshot msg. index:%" PRId64 ", expected index:%" PRId64, TD_VID(pVnode),
|
||||||
|
@ -837,7 +837,6 @@ int32_t vnodeSnapWrite(SVSnapWriter *pWriter, uint8_t *pData, uint32_t nData) {
|
||||||
case SNAP_DATA_RAW: {
|
case SNAP_DATA_RAW: {
|
||||||
// tsdb
|
// tsdb
|
||||||
if (pWriter->pTsdbSnapRAWWriter == NULL) {
|
if (pWriter->pTsdbSnapRAWWriter == NULL) {
|
||||||
ASSERT(pWriter->sver == 0);
|
|
||||||
code = tsdbSnapRAWWriterOpen(pVnode->pTsdb, pWriter->ever, &pWriter->pTsdbSnapRAWWriter);
|
code = tsdbSnapRAWWriterOpen(pVnode->pTsdb, pWriter->ever, &pWriter->pTsdbSnapRAWWriter);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
}
|
}
|
||||||
|
|
|
@ -540,8 +540,13 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t ver, SRpcMsg
|
||||||
TD_VID(pVnode), TMSG_INFO(pMsg->msgType), ver, pVnode->state.applied, pVnode->state.applyTerm,
|
TD_VID(pVnode), TMSG_INFO(pMsg->msgType), ver, pVnode->state.applied, pVnode->state.applyTerm,
|
||||||
pMsg->info.conn.applyTerm);
|
pMsg->info.conn.applyTerm);
|
||||||
|
|
||||||
ASSERT(pVnode->state.applyTerm <= pMsg->info.conn.applyTerm);
|
if (!(pVnode->state.applyTerm <= pMsg->info.conn.applyTerm)) {
|
||||||
ASSERTS(pVnode->state.applied + 1 == ver, "applied:%" PRId64 ", ver:%" PRId64, pVnode->state.applied, ver);
|
return terrno = TSDB_CODE_INTERNAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(pVnode->state.applied + 1 == ver)) {
|
||||||
|
return terrno = TSDB_CODE_INTERNAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
atomic_store_64(&pVnode->state.applied, ver);
|
atomic_store_64(&pVnode->state.applied, ver);
|
||||||
atomic_store_64(&pVnode->state.applyTerm, pMsg->info.conn.applyTerm);
|
atomic_store_64(&pVnode->state.applyTerm, pMsg->info.conn.applyTerm);
|
||||||
|
@ -981,7 +986,10 @@ static int32_t vnodeProcessFetchTtlExpiredTbs(SVnode *pVnode, int64_t ver, void
|
||||||
goto _end;
|
goto _end;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT(ttlReq.nUids == taosArrayGetSize(ttlReq.pTbUids));
|
if (!(ttlReq.nUids == taosArrayGetSize(ttlReq.pTbUids))) {
|
||||||
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
|
goto _end;
|
||||||
|
}
|
||||||
|
|
||||||
tb_uid_t suid;
|
tb_uid_t suid;
|
||||||
char ctbName[TSDB_TABLE_NAME_LEN];
|
char ctbName[TSDB_TABLE_NAME_LEN];
|
||||||
|
|
|
@ -117,7 +117,9 @@ static int32_t inline vnodeProposeMsg(SVnode *pVnode, SRpcMsg *pMsg, bool isWeak
|
||||||
int32_t code = syncPropose(pVnode->sync, pMsg, isWeak, &seq);
|
int32_t code = syncPropose(pVnode->sync, pMsg, isWeak, &seq);
|
||||||
bool wait = (code == 0 && vnodeIsMsgBlock(pMsg->msgType));
|
bool wait = (code == 0 && vnodeIsMsgBlock(pMsg->msgType));
|
||||||
if (wait) {
|
if (wait) {
|
||||||
ASSERT(!pVnode->blocked);
|
if (pVnode->blocked) {
|
||||||
|
return TSDB_CODE_INTERNAL_ERROR;
|
||||||
|
}
|
||||||
pVnode->blocked = true;
|
pVnode->blocked = true;
|
||||||
pVnode->blockSec = taosGetTimestampSec();
|
pVnode->blockSec = taosGetTimestampSec();
|
||||||
pVnode->blockSeq = seq;
|
pVnode->blockSeq = seq;
|
||||||
|
@ -175,7 +177,6 @@ static void inline vnodeProposeBatchMsg(SVnode *pVnode, SRpcMsg **pMsgArr, bool
|
||||||
int32_t code = syncProposeBatch(pVnode->sync, pMsgArr, pIsWeakArr, *arrSize);
|
int32_t code = syncProposeBatch(pVnode->sync, pMsgArr, pIsWeakArr, *arrSize);
|
||||||
bool wait = (code == 0 && vnodeIsBlockMsg(pLastMsg->msgType));
|
bool wait = (code == 0 && vnodeIsBlockMsg(pLastMsg->msgType));
|
||||||
if (wait) {
|
if (wait) {
|
||||||
ASSERT(!pVnode->blocked);
|
|
||||||
pVnode->blocked = true;
|
pVnode->blocked = true;
|
||||||
}
|
}
|
||||||
(void)taosThreadMutexUnlock(&pVnode->lock);
|
(void)taosThreadMutexUnlock(&pVnode->lock);
|
||||||
|
@ -543,7 +544,11 @@ static void vnodeRestoreFinish(const SSyncFSM *pFsm, const SyncIndex commitIdx)
|
||||||
|
|
||||||
do {
|
do {
|
||||||
appliedIdx = vnodeSyncAppliedIndex(pFsm);
|
appliedIdx = vnodeSyncAppliedIndex(pFsm);
|
||||||
ASSERT(appliedIdx <= commitIdx);
|
if (appliedIdx > commitIdx) {
|
||||||
|
vError("vgId:%d, restore failed since applied-index:%" PRId64 " is larger than commit-index:%" PRId64, vgId,
|
||||||
|
appliedIdx, commitIdx);
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (appliedIdx == commitIdx) {
|
if (appliedIdx == commitIdx) {
|
||||||
vInfo("vgId:%d, no items to be applied, restore finish", pVnode->config.vgId);
|
vInfo("vgId:%d, no items to be applied, restore finish", pVnode->config.vgId);
|
||||||
break;
|
break;
|
||||||
|
@ -555,7 +560,6 @@ static void vnodeRestoreFinish(const SSyncFSM *pFsm, const SyncIndex commitIdx)
|
||||||
}
|
}
|
||||||
} while (true);
|
} while (true);
|
||||||
|
|
||||||
ASSERT(commitIdx == vnodeSyncAppliedIndex(pFsm));
|
|
||||||
(void)walApplyVer(pVnode->pWal, commitIdx);
|
(void)walApplyVer(pVnode->pWal, commitIdx);
|
||||||
pVnode->restored = true;
|
pVnode->restored = true;
|
||||||
|
|
||||||
|
|
|
@ -87,14 +87,11 @@ struct SLRUEntry {
|
||||||
#define TAOS_LRU_ENTRY_REF(h) (++(h)->refs)
|
#define TAOS_LRU_ENTRY_REF(h) (++(h)->refs)
|
||||||
|
|
||||||
static bool taosLRUEntryUnref(SLRUEntry *entry) {
|
static bool taosLRUEntryUnref(SLRUEntry *entry) {
|
||||||
// ASSERT(entry->refs > 0);
|
|
||||||
--entry->refs;
|
--entry->refs;
|
||||||
return entry->refs == 0;
|
return entry->refs == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void taosLRUEntryFree(SLRUEntry *entry) {
|
static void taosLRUEntryFree(SLRUEntry *entry) {
|
||||||
// ASSERT(entry->refs == 0);
|
|
||||||
|
|
||||||
if (entry->deleter) {
|
if (entry->deleter) {
|
||||||
(*entry->deleter)(entry->keyData, entry->keyLength, entry->value, entry->ud);
|
(*entry->deleter)(entry->keyData, entry->keyLength, entry->value, entry->ud);
|
||||||
}
|
}
|
||||||
|
@ -129,7 +126,6 @@ static void taosLRUEntryTableApply(SLRUEntryTable *table, _taos_lru_table_func_t
|
||||||
SLRUEntry *h = table->list[i];
|
SLRUEntry *h = table->list[i];
|
||||||
while (h) {
|
while (h) {
|
||||||
SLRUEntry *n = h->nextHash;
|
SLRUEntry *n = h->nextHash;
|
||||||
// ASSERT(TAOS_LRU_ENTRY_IN_CACHE(h));
|
|
||||||
func(h);
|
func(h);
|
||||||
h = n;
|
h = n;
|
||||||
}
|
}
|
||||||
|
@ -155,7 +151,6 @@ static int taosLRUEntryTableApplyF(SLRUEntryTable *table, _taos_lru_functor_t fu
|
||||||
SLRUEntry *h = table->list[i];
|
SLRUEntry *h = table->list[i];
|
||||||
while (h) {
|
while (h) {
|
||||||
SLRUEntry *n = h->nextHash;
|
SLRUEntry *n = h->nextHash;
|
||||||
// ASSERT(TAOS_LRU_ENTRY_IN_CACHE(h));
|
|
||||||
ret = functor(h->keyData, h->keyLength, h->value, ud);
|
ret = functor(h->keyData, h->keyLength, h->value, ud);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -205,7 +200,6 @@ static void taosLRUEntryTableResize(SLRUEntryTable *table) {
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ASSERT(table->elems == count);
|
|
||||||
|
|
||||||
taosMemoryFree(table->list);
|
taosMemoryFree(table->list);
|
||||||
table->list = newList;
|
table->list = newList;
|
||||||
|
@ -261,17 +255,13 @@ struct SLRUCacheShard {
|
||||||
static void taosLRUCacheShardMaintainPoolSize(SLRUCacheShard *shard) {
|
static void taosLRUCacheShardMaintainPoolSize(SLRUCacheShard *shard) {
|
||||||
while (shard->highPriPoolUsage > shard->highPriPoolCapacity) {
|
while (shard->highPriPoolUsage > shard->highPriPoolCapacity) {
|
||||||
shard->lruLowPri = shard->lruLowPri->next;
|
shard->lruLowPri = shard->lruLowPri->next;
|
||||||
// ASSERT(shard->lruLowPri != &shard->lru);
|
|
||||||
TAOS_LRU_ENTRY_SET_IN_HIGH_POOL(shard->lruLowPri, false);
|
TAOS_LRU_ENTRY_SET_IN_HIGH_POOL(shard->lruLowPri, false);
|
||||||
|
|
||||||
// ASSERT(shard->highPriPoolUsage >= shard->lruLowPri->totalCharge);
|
|
||||||
shard->highPriPoolUsage -= shard->lruLowPri->totalCharge;
|
shard->highPriPoolUsage -= shard->lruLowPri->totalCharge;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void taosLRUCacheShardLRUInsert(SLRUCacheShard *shard, SLRUEntry *e) {
|
static void taosLRUCacheShardLRUInsert(SLRUCacheShard *shard, SLRUEntry *e) {
|
||||||
// ASSERT(e->next == NULL && e->prev == NULL);
|
|
||||||
|
|
||||||
if (shard->highPriPoolRatio > 0 && (TAOS_LRU_ENTRY_IS_HIGH_PRI(e) || TAOS_LRU_ENTRY_HAS_HIT(e))) {
|
if (shard->highPriPoolRatio > 0 && (TAOS_LRU_ENTRY_IS_HIGH_PRI(e) || TAOS_LRU_ENTRY_HAS_HIT(e))) {
|
||||||
e->next = &shard->lru;
|
e->next = &shard->lru;
|
||||||
e->prev = shard->lru.prev;
|
e->prev = shard->lru.prev;
|
||||||
|
@ -297,8 +287,6 @@ static void taosLRUCacheShardLRUInsert(SLRUCacheShard *shard, SLRUEntry *e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void taosLRUCacheShardLRURemove(SLRUCacheShard *shard, SLRUEntry *e) {
|
static void taosLRUCacheShardLRURemove(SLRUCacheShard *shard, SLRUEntry *e) {
|
||||||
// ASSERT(e->next && e->prev);
|
|
||||||
|
|
||||||
if (shard->lruLowPri == e) {
|
if (shard->lruLowPri == e) {
|
||||||
shard->lruLowPri = e->prev;
|
shard->lruLowPri = e->prev;
|
||||||
}
|
}
|
||||||
|
@ -306,10 +294,8 @@ static void taosLRUCacheShardLRURemove(SLRUCacheShard *shard, SLRUEntry *e) {
|
||||||
e->prev->next = e->next;
|
e->prev->next = e->next;
|
||||||
e->prev = e->next = NULL;
|
e->prev = e->next = NULL;
|
||||||
|
|
||||||
// ASSERT(shard->lruUsage >= e->totalCharge);
|
|
||||||
shard->lruUsage -= e->totalCharge;
|
shard->lruUsage -= e->totalCharge;
|
||||||
if (TAOS_LRU_ENTRY_IN_HIGH_POOL(e)) {
|
if (TAOS_LRU_ENTRY_IN_HIGH_POOL(e)) {
|
||||||
// ASSERT(shard->highPriPoolUsage >= e->totalCharge);
|
|
||||||
shard->highPriPoolUsage -= e->totalCharge;
|
shard->highPriPoolUsage -= e->totalCharge;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -317,13 +303,11 @@ static void taosLRUCacheShardLRURemove(SLRUCacheShard *shard, SLRUEntry *e) {
|
||||||
static void taosLRUCacheShardEvictLRU(SLRUCacheShard *shard, size_t charge, SArray *deleted) {
|
static void taosLRUCacheShardEvictLRU(SLRUCacheShard *shard, size_t charge, SArray *deleted) {
|
||||||
while (shard->usage + charge > shard->capacity && shard->lru.next != &shard->lru) {
|
while (shard->usage + charge > shard->capacity && shard->lru.next != &shard->lru) {
|
||||||
SLRUEntry *old = shard->lru.next;
|
SLRUEntry *old = shard->lru.next;
|
||||||
// ASSERT(TAOS_LRU_ENTRY_IN_CACHE(old) && !TAOS_LRU_ENTRY_HAS_REFS(old));
|
|
||||||
|
|
||||||
taosLRUCacheShardLRURemove(shard, old);
|
taosLRUCacheShardLRURemove(shard, old);
|
||||||
(void)taosLRUEntryTableRemove(&shard->table, old->keyData, old->keyLength, old->hash);
|
(void)taosLRUEntryTableRemove(&shard->table, old->keyData, old->keyLength, old->hash);
|
||||||
|
|
||||||
TAOS_LRU_ENTRY_SET_IN_CACHE(old, false);
|
TAOS_LRU_ENTRY_SET_IN_CACHE(old, false);
|
||||||
// ASSERT(shard->usage >= old->totalCharge);
|
|
||||||
shard->usage -= old->totalCharge;
|
shard->usage -= old->totalCharge;
|
||||||
|
|
||||||
(void)taosArrayPush(deleted, &old);
|
(void)taosArrayPush(deleted, &old);
|
||||||
|
@ -414,11 +398,9 @@ static LRUStatus taosLRUCacheShardInsertEntry(SLRUCacheShard *shard, SLRUEntry *
|
||||||
if (old != NULL) {
|
if (old != NULL) {
|
||||||
status = TAOS_LRU_STATUS_OK_OVERWRITTEN;
|
status = TAOS_LRU_STATUS_OK_OVERWRITTEN;
|
||||||
|
|
||||||
// ASSERT(TAOS_LRU_ENTRY_IN_CACHE(old));
|
|
||||||
TAOS_LRU_ENTRY_SET_IN_CACHE(old, false);
|
TAOS_LRU_ENTRY_SET_IN_CACHE(old, false);
|
||||||
if (!TAOS_LRU_ENTRY_HAS_REFS(old)) {
|
if (!TAOS_LRU_ENTRY_HAS_REFS(old)) {
|
||||||
taosLRUCacheShardLRURemove(shard, old);
|
taosLRUCacheShardLRURemove(shard, old);
|
||||||
// ASSERT(shard->usage >= old->totalCharge);
|
|
||||||
shard->usage -= old->totalCharge;
|
shard->usage -= old->totalCharge;
|
||||||
|
|
||||||
(void)taosArrayPush(lastReferenceList, &old);
|
(void)taosArrayPush(lastReferenceList, &old);
|
||||||
|
@ -479,7 +461,6 @@ static LRUHandle *taosLRUCacheShardLookup(SLRUCacheShard *shard, const void *key
|
||||||
(void)taosThreadMutexLock(&shard->mutex);
|
(void)taosThreadMutexLock(&shard->mutex);
|
||||||
e = taosLRUEntryTableLookup(&shard->table, key, keyLen, hash);
|
e = taosLRUEntryTableLookup(&shard->table, key, keyLen, hash);
|
||||||
if (e != NULL) {
|
if (e != NULL) {
|
||||||
// ASSERT(TAOS_LRU_ENTRY_IN_CACHE(e));
|
|
||||||
if (!TAOS_LRU_ENTRY_HAS_REFS(e)) {
|
if (!TAOS_LRU_ENTRY_HAS_REFS(e)) {
|
||||||
taosLRUCacheShardLRURemove(shard, e);
|
taosLRUCacheShardLRURemove(shard, e);
|
||||||
}
|
}
|
||||||
|
@ -498,12 +479,10 @@ static void taosLRUCacheShardErase(SLRUCacheShard *shard, const void *key, size_
|
||||||
|
|
||||||
SLRUEntry *e = taosLRUEntryTableRemove(&shard->table, key, keyLen, hash);
|
SLRUEntry *e = taosLRUEntryTableRemove(&shard->table, key, keyLen, hash);
|
||||||
if (e != NULL) {
|
if (e != NULL) {
|
||||||
// ASSERT(TAOS_LRU_ENTRY_IN_CACHE(e));
|
|
||||||
TAOS_LRU_ENTRY_SET_IN_CACHE(e, false);
|
TAOS_LRU_ENTRY_SET_IN_CACHE(e, false);
|
||||||
if (!TAOS_LRU_ENTRY_HAS_REFS(e)) {
|
if (!TAOS_LRU_ENTRY_HAS_REFS(e)) {
|
||||||
taosLRUCacheShardLRURemove(shard, e);
|
taosLRUCacheShardLRURemove(shard, e);
|
||||||
|
|
||||||
// ASSERT(shard->usage >= e->totalCharge);
|
|
||||||
shard->usage -= e->totalCharge;
|
shard->usage -= e->totalCharge;
|
||||||
lastReference = true;
|
lastReference = true;
|
||||||
}
|
}
|
||||||
|
@ -535,11 +514,9 @@ static void taosLRUCacheShardEraseUnrefEntries(SLRUCacheShard *shard) {
|
||||||
|
|
||||||
while (shard->lru.next != &shard->lru) {
|
while (shard->lru.next != &shard->lru) {
|
||||||
SLRUEntry *old = shard->lru.next;
|
SLRUEntry *old = shard->lru.next;
|
||||||
// ASSERT(TAOS_LRU_ENTRY_IN_CACHE(old) && !TAOS_LRU_ENTRY_HAS_REFS(old));
|
|
||||||
taosLRUCacheShardLRURemove(shard, old);
|
taosLRUCacheShardLRURemove(shard, old);
|
||||||
(void)taosLRUEntryTableRemove(&shard->table, old->keyData, old->keyLength, old->hash);
|
(void)taosLRUEntryTableRemove(&shard->table, old->keyData, old->keyLength, old->hash);
|
||||||
TAOS_LRU_ENTRY_SET_IN_CACHE(old, false);
|
TAOS_LRU_ENTRY_SET_IN_CACHE(old, false);
|
||||||
// ASSERT(shard->usage >= old->totalCharge);
|
|
||||||
shard->usage -= old->totalCharge;
|
shard->usage -= old->totalCharge;
|
||||||
|
|
||||||
(void)taosArrayPush(lastReferenceList, &old);
|
(void)taosArrayPush(lastReferenceList, &old);
|
||||||
|
@ -560,7 +537,6 @@ static bool taosLRUCacheShardRef(SLRUCacheShard *shard, LRUHandle *handle) {
|
||||||
SLRUEntry *e = (SLRUEntry *)handle;
|
SLRUEntry *e = (SLRUEntry *)handle;
|
||||||
(void)taosThreadMutexLock(&shard->mutex);
|
(void)taosThreadMutexLock(&shard->mutex);
|
||||||
|
|
||||||
// ASSERT(TAOS_LRU_ENTRY_HAS_REFS(e));
|
|
||||||
TAOS_LRU_ENTRY_REF(e);
|
TAOS_LRU_ENTRY_REF(e);
|
||||||
|
|
||||||
(void)taosThreadMutexUnlock(&shard->mutex);
|
(void)taosThreadMutexUnlock(&shard->mutex);
|
||||||
|
@ -581,8 +557,6 @@ static bool taosLRUCacheShardRelease(SLRUCacheShard *shard, LRUHandle *handle, b
|
||||||
lastReference = taosLRUEntryUnref(e);
|
lastReference = taosLRUEntryUnref(e);
|
||||||
if (lastReference && TAOS_LRU_ENTRY_IN_CACHE(e)) {
|
if (lastReference && TAOS_LRU_ENTRY_IN_CACHE(e)) {
|
||||||
if (shard->usage > shard->capacity || eraseIfLastRef) {
|
if (shard->usage > shard->capacity || eraseIfLastRef) {
|
||||||
// ASSERT(shard->lru.next == &shard->lru || eraseIfLastRef);
|
|
||||||
|
|
||||||
(void)taosLRUEntryTableRemove(&shard->table, e->keyData, e->keyLength, e->hash);
|
(void)taosLRUEntryTableRemove(&shard->table, e->keyData, e->keyLength, e->hash);
|
||||||
TAOS_LRU_ENTRY_SET_IN_CACHE(e, false);
|
TAOS_LRU_ENTRY_SET_IN_CACHE(e, false);
|
||||||
} else {
|
} else {
|
||||||
|
@ -593,7 +567,6 @@ static bool taosLRUCacheShardRelease(SLRUCacheShard *shard, LRUHandle *handle, b
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lastReference && e->value) {
|
if (lastReference && e->value) {
|
||||||
// ASSERT(shard->usage >= e->totalCharge);
|
|
||||||
shard->usage -= e->totalCharge;
|
shard->usage -= e->totalCharge;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -631,7 +604,6 @@ static size_t taosLRUCacheShardGetPinnedUsage(SLRUCacheShard *shard) {
|
||||||
|
|
||||||
(void)taosThreadMutexLock(&shard->mutex);
|
(void)taosThreadMutexLock(&shard->mutex);
|
||||||
|
|
||||||
// ASSERT(shard->usage >= shard->lruUsage);
|
|
||||||
usage = shard->usage - shard->lruUsage;
|
usage = shard->usage - shard->lruUsage;
|
||||||
|
|
||||||
(void)taosThreadMutexUnlock(&shard->mutex);
|
(void)taosThreadMutexUnlock(&shard->mutex);
|
||||||
|
@ -723,7 +695,6 @@ void taosLRUCacheCleanup(SLRUCache *cache) {
|
||||||
if (cache) {
|
if (cache) {
|
||||||
if (cache->shards) {
|
if (cache->shards) {
|
||||||
int numShards = cache->numShards;
|
int numShards = cache->numShards;
|
||||||
// ASSERT(numShards > 0);
|
|
||||||
for (int i = 0; i < numShards; ++i) {
|
for (int i = 0; i < numShards; ++i) {
|
||||||
taosLRUCacheShardCleanup(&cache->shards[i]);
|
taosLRUCacheShardCleanup(&cache->shards[i]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue