Merge pull request #27320 from taosdata/enh/TD-31543-1
enh: remove some asserts
This commit is contained in:
commit
34f65ad158
|
@ -213,7 +213,6 @@ static FORCE_INLINE int32_t taosEncodeVariantU16(void **buf, uint16_t value) {
|
|||
if (buf != NULL) ((uint8_t *)(*buf))[i] = (uint8_t)(value | ENCODE_LIMIT);
|
||||
value >>= 7;
|
||||
i++;
|
||||
ASSERT(i < 3);
|
||||
}
|
||||
|
||||
if (buf != NULL) {
|
||||
|
@ -261,7 +260,6 @@ static FORCE_INLINE int32_t taosEncodeVariantU32(void **buf, uint32_t value) {
|
|||
if (buf != NULL) ((uint8_t *)(*buf))[i] = (value | ENCODE_LIMIT);
|
||||
value >>= 7;
|
||||
i++;
|
||||
ASSERT(i < 5);
|
||||
}
|
||||
|
||||
if (buf != NULL) {
|
||||
|
@ -309,7 +307,6 @@ static FORCE_INLINE int32_t taosEncodeVariantU64(void **buf, uint64_t value) {
|
|||
if (buf != NULL) ((uint8_t *)(*buf))[i] = (uint8_t)(value | ENCODE_LIMIT);
|
||||
value >>= 7;
|
||||
i++;
|
||||
ASSERT(i < 10);
|
||||
}
|
||||
|
||||
if (buf != NULL) {
|
||||
|
|
|
@ -61,7 +61,9 @@ int32_t tsdbSttFileReaderOpen(const char *fname, const SSttFileReaderConfig *con
|
|||
|
||||
// // open each segment reader
|
||||
int64_t offset = config->file->size - sizeof(SSttFooter);
|
||||
ASSERT(offset >= TSDB_FHDR_SIZE);
|
||||
if (offset < TSDB_FHDR_SIZE) {
|
||||
TSDB_CHECK_CODE(code = TSDB_CODE_FILE_CORRUPTED, lino, _exit);
|
||||
}
|
||||
|
||||
int32_t encryptAlgoirthm = config->tsdb->pVnode->config.tsdbCfg.encryptAlgorithm;
|
||||
char *encryptKey = config->tsdb->pVnode->config.tsdbCfg.encryptKey;
|
||||
|
@ -115,7 +117,9 @@ int32_t tsdbSttFileReaderClose(SSttFileReader **reader) {
|
|||
int32_t tsdbSttFileReadStatisBlk(SSttFileReader *reader, const TStatisBlkArray **statisBlkArray) {
|
||||
if (!reader->ctx->statisBlkLoaded) {
|
||||
if (reader->footer->statisBlkPtr->size > 0) {
|
||||
ASSERT(reader->footer->statisBlkPtr->size % sizeof(SStatisBlk) == 0);
|
||||
if (reader->footer->statisBlkPtr->size % sizeof(SStatisBlk) != 0) {
|
||||
return TSDB_CODE_FILE_CORRUPTED;
|
||||
}
|
||||
|
||||
int32_t size = reader->footer->statisBlkPtr->size / sizeof(SStatisBlk);
|
||||
void *data = taosMemoryMalloc(reader->footer->statisBlkPtr->size);
|
||||
|
@ -147,7 +151,9 @@ int32_t tsdbSttFileReadStatisBlk(SSttFileReader *reader, const TStatisBlkArray *
|
|||
int32_t tsdbSttFileReadTombBlk(SSttFileReader *reader, const TTombBlkArray **tombBlkArray) {
|
||||
if (!reader->ctx->tombBlkLoaded) {
|
||||
if (reader->footer->tombBlkPtr->size > 0) {
|
||||
ASSERT(reader->footer->tombBlkPtr->size % sizeof(STombBlk) == 0);
|
||||
if (reader->footer->tombBlkPtr->size % sizeof(STombBlk) != 0) {
|
||||
return TSDB_CODE_FILE_CORRUPTED;
|
||||
}
|
||||
|
||||
int32_t size = reader->footer->tombBlkPtr->size / sizeof(STombBlk);
|
||||
void *data = taosMemoryMalloc(reader->footer->tombBlkPtr->size);
|
||||
|
@ -179,7 +185,9 @@ int32_t tsdbSttFileReadTombBlk(SSttFileReader *reader, const TTombBlkArray **tom
|
|||
int32_t tsdbSttFileReadSttBlk(SSttFileReader *reader, const TSttBlkArray **sttBlkArray) {
|
||||
if (!reader->ctx->sttBlkLoaded) {
|
||||
if (reader->footer->sttBlkPtr->size > 0) {
|
||||
ASSERT(reader->footer->sttBlkPtr->size % sizeof(SSttBlk) == 0);
|
||||
if (reader->footer->sttBlkPtr->size % sizeof(SSttBlk) != 0) {
|
||||
return TSDB_CODE_FILE_CORRUPTED;
|
||||
}
|
||||
|
||||
int32_t size = reader->footer->sttBlkPtr->size / sizeof(SSttBlk);
|
||||
void *data = taosMemoryMalloc(reader->footer->sttBlkPtr->size);
|
||||
|
@ -256,7 +264,9 @@ int32_t tsdbSttFileReadBlockDataByColumn(SSttFileReader *reader, const SSttBlk *
|
|||
SBufferReader br = BUFFER_READER_INITIALIZER(0, buffer0);
|
||||
TAOS_CHECK_GOTO(tGetDiskDataHdr(&br, &hdr), &lino, _exit);
|
||||
|
||||
ASSERT(hdr.delimiter == TSDB_FILE_DLMT);
|
||||
if (hdr.delimiter != TSDB_FILE_DLMT) {
|
||||
TSDB_CHECK_CODE(code = TSDB_CODE_FILE_CORRUPTED, lino, _exit);
|
||||
}
|
||||
|
||||
// set data container
|
||||
tBlockDataReset(bData);
|
||||
|
@ -266,7 +276,9 @@ int32_t tsdbSttFileReadBlockDataByColumn(SSttFileReader *reader, const SSttBlk *
|
|||
|
||||
// key part
|
||||
TAOS_CHECK_GOTO(tBlockDataDecompressKeyPart(&hdr, &br, bData, assist), &lino, _exit);
|
||||
ASSERT(br.offset == buffer0->size);
|
||||
if (br.offset != buffer0->size) {
|
||||
TSDB_CHECK_CODE(code = TSDB_CODE_FILE_CORRUPTED, lino, _exit);
|
||||
}
|
||||
|
||||
bool loadExtra = false;
|
||||
for (int i = 0; i < ncid; i++) {
|
||||
|
@ -376,7 +388,10 @@ int32_t tsdbSttFileReadTombBlock(SSttFileReader *reader, const STombBlk *tombBlk
|
|||
br.offset += tombBlk->size[i];
|
||||
}
|
||||
|
||||
ASSERT(br.offset == tombBlk->dp->size);
|
||||
if (br.offset != tombBlk->dp->size) {
|
||||
TSDB_CHECK_CODE(code = TSDB_CODE_FILE_CORRUPTED, lino, _exit);
|
||||
}
|
||||
|
||||
_exit:
|
||||
if (code) {
|
||||
tsdbError("vgId:%d %s failed at %s:%d since %s", TD_VID(reader->config->tsdb->pVnode), __func__, __FILE__, lino,
|
||||
|
@ -444,7 +459,9 @@ int32_t tsdbSttFileReadStatisBlock(SSttFileReader *reader, const SStatisBlk *sta
|
|||
}
|
||||
}
|
||||
|
||||
ASSERT(br.offset == buffer0->size);
|
||||
if (br.offset != buffer0->size) {
|
||||
TSDB_CHECK_CODE(code = TSDB_CODE_FILE_CORRUPTED, lino, _exit);
|
||||
}
|
||||
|
||||
_exit:
|
||||
if (code) {
|
||||
|
@ -814,8 +831,6 @@ _exit:
|
|||
}
|
||||
|
||||
static void tsdbSttFWriterDoClose(SSttFileWriter *writer) {
|
||||
ASSERT(writer->fd == NULL);
|
||||
|
||||
for (int32_t i = 0; i < ARRAY_SIZE(writer->local); ++i) {
|
||||
tBufferDestroy(writer->local + i);
|
||||
}
|
||||
|
@ -854,7 +869,6 @@ static int32_t tsdbSttFWriterCloseCommit(SSttFileWriter *writer, TFileOpArray *o
|
|||
|
||||
tsdbCloseFile(&writer->fd);
|
||||
|
||||
ASSERT(writer->file->size > 0);
|
||||
STFileOp op = (STFileOp){
|
||||
.optype = TSDB_FOP_CREATE,
|
||||
.fid = writer->config->fid,
|
||||
|
|
|
@ -171,7 +171,7 @@ static int32_t tStatisBlockUpdate(STbStatisBlock *block, SRowInfo *row) {
|
|||
TAOS_CHECK_RETURN(tBufferPutAt(&block->counts, (block->numOfRecords - 1) * sizeof(record.count), &record.count,
|
||||
sizeof(record.count)));
|
||||
} else {
|
||||
ASSERT(0);
|
||||
return TSDB_CODE_INVALID_PARA;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -165,9 +165,7 @@ static int32_t vnodeAsyncTaskDone(SVAsync *async, SVATask *task) {
|
|||
}
|
||||
|
||||
ret = vHashDrop(async->taskTable, task);
|
||||
if (ret != 0) {
|
||||
ASSERT(0);
|
||||
}
|
||||
TAOS_UNUSED(ret);
|
||||
async->numTasks--;
|
||||
|
||||
if (task->numWait == 0) {
|
||||
|
@ -403,7 +401,6 @@ static int32_t vnodeAsyncDestroy(SVAsync **async) {
|
|||
}
|
||||
|
||||
(void)taosThreadJoin((*async)->workers[i].thread, NULL);
|
||||
ASSERT((*async)->workers[i].state == EVA_WORKER_STATE_STOP);
|
||||
(*async)->workers[i].state = EVA_WORKER_STATE_UINIT;
|
||||
}
|
||||
|
||||
|
@ -413,18 +410,11 @@ static int32_t vnodeAsyncDestroy(SVAsync **async) {
|
|||
channel->prev->next = channel->next;
|
||||
|
||||
int32_t ret = vHashDrop((*async)->channelTable, channel);
|
||||
if (ret) {
|
||||
ASSERT(0);
|
||||
}
|
||||
TAOS_UNUSED(ret);
|
||||
(*async)->numChannels--;
|
||||
taosMemoryFree(channel);
|
||||
}
|
||||
|
||||
ASSERT((*async)->numLaunchWorkers == 0);
|
||||
ASSERT((*async)->numIdleWorkers == 0);
|
||||
ASSERT((*async)->numChannels == 0);
|
||||
ASSERT((*async)->numTasks == 0);
|
||||
|
||||
(void)taosThreadMutexDestroy(&(*async)->mutex);
|
||||
(void)taosThreadCondDestroy(&(*async)->hasTask);
|
||||
|
||||
|
@ -438,7 +428,6 @@ static int32_t vnodeAsyncDestroy(SVAsync **async) {
|
|||
|
||||
static int32_t vnodeAsyncLaunchWorker(SVAsync *async) {
|
||||
for (int32_t i = 0; i < async->numWorkers; i++) {
|
||||
ASSERT(async->workers[i].state != EVA_WORKER_STATE_IDLE);
|
||||
if (async->workers[i].state == EVA_WORKER_STATE_ACTIVE) {
|
||||
continue;
|
||||
} else if (async->workers[i].state == EVA_WORKER_STATE_STOP) {
|
||||
|
|
|
@ -302,7 +302,6 @@ static int32_t vnodePrepareCommit(SVnode *pVnode, SCommitInfo *pInfo) {
|
|||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
(void)taosThreadMutexLock(&pVnode->mutex);
|
||||
ASSERT(pVnode->onCommit == NULL);
|
||||
pVnode->onCommit = pVnode->inUse;
|
||||
pVnode->inUse = NULL;
|
||||
(void)taosThreadMutexUnlock(&pVnode->mutex);
|
||||
|
@ -339,7 +338,7 @@ static void vnodeReturnBufPool(SVnode *pVnode) {
|
|||
pVnode->recycleTail = pPool;
|
||||
}
|
||||
} else {
|
||||
ASSERT(0);
|
||||
vError("vgId:%d, buffer pool %p of id %d nRef:%d", TD_VID(pVnode), pPool, pPool->id, nRef);
|
||||
}
|
||||
|
||||
(void)taosThreadMutexUnlock(&pVnode->mutex);
|
||||
|
|
|
@ -77,7 +77,6 @@ int32_t vHashDestroy(SVHashTable** ht) {
|
|||
}
|
||||
|
||||
if (*ht) {
|
||||
ASSERT((*ht)->numEntries == 0);
|
||||
taosMemoryFree((*ht)->buckets);
|
||||
taosMemoryFree(*ht);
|
||||
(*ht) = NULL;
|
||||
|
|
|
@ -558,7 +558,9 @@ void vnodeClose(SVnode *pVnode) {
|
|||
|
||||
// start the sync timer after the queue is ready
|
||||
int32_t vnodeStart(SVnode *pVnode) {
|
||||
ASSERT(pVnode);
|
||||
if (pVnode == NULL) {
|
||||
return TSDB_CODE_INVALID_PARA;
|
||||
}
|
||||
return vnodeSyncStart(pVnode);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue