diff --git a/source/dnode/vnode/src/tsdb/tsdbCommit2.c b/source/dnode/vnode/src/tsdb/tsdbCommit2.c index 4467102d6f..3c407b31cf 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCommit2.c +++ b/source/dnode/vnode/src/tsdb/tsdbCommit2.c @@ -157,41 +157,35 @@ static int32_t tsdbCommitTombData(SCommitter2 *committer) { int64_t numRecord = 0; SMetaInfo info; - if (committer->tsdb->imem->nDel == 0) { - goto _exit; - } + // if no history data and no new timestamp data, skip tomb data + if (committer->ctx->info->fset || committer->ctx->hasTSData) { + committer->ctx->tbid->suid = 0; + committer->ctx->tbid->uid = 0; + for (STombRecord *record; (record = tsdbIterMergerGetTombRecord(committer->tombIterMerger));) { + if (record->uid != committer->ctx->tbid->uid) { + committer->ctx->tbid->suid = record->suid; + committer->ctx->tbid->uid = record->uid; - // do not need to write tomb data if there is no ts data - bool skip = (committer->ctx->info->fset == NULL && !committer->ctx->hasTSData); - - committer->ctx->tbid->suid = 0; - committer->ctx->tbid->uid = 0; - for (STombRecord *record; (record = tsdbIterMergerGetTombRecord(committer->tombIterMerger));) { - if (record->uid != committer->ctx->tbid->uid) { - committer->ctx->tbid->suid = record->suid; - committer->ctx->tbid->uid = record->uid; - - if (metaGetInfo(committer->tsdb->pVnode->pMeta, record->uid, &info, NULL) != 0) { - TAOS_CHECK_GOTO(tsdbIterMergerSkipTableData(committer->tombIterMerger, committer->ctx->tbid), &lino, _exit); - continue; + if (metaGetInfo(committer->tsdb->pVnode->pMeta, record->uid, &info, NULL) != 0) { + TAOS_CHECK_GOTO(tsdbIterMergerSkipTableData(committer->tombIterMerger, committer->ctx->tbid), &lino, _exit); + continue; + } } - } - if (record->ekey < committer->ctx->minKey) { - // do nothing - } else if (record->skey > committer->ctx->maxKey) { - // committer->ctx->nextKey = TMIN(record->skey, committer->ctx->nextKey); - } else { - record->skey = TMAX(record->skey, committer->ctx->minKey); - record->ekey = TMIN(record->ekey, committer->ctx->maxKey); + if (record->ekey < committer->ctx->minKey) { + // do nothing + } else if (record->skey > committer->ctx->maxKey) { + // committer->ctx->nextKey = TMIN(record->skey, committer->ctx->nextKey); + } else { + record->skey = TMAX(record->skey, committer->ctx->minKey); + record->ekey = TMIN(record->ekey, committer->ctx->maxKey); - if (!skip) { numRecord++; TAOS_CHECK_GOTO(tsdbFSetWriteTombRecord(committer->writer, record), &lino, _exit); } - } - TAOS_CHECK_GOTO(tsdbIterMergerNext(committer->tombIterMerger), &lino, _exit); + TAOS_CHECK_GOTO(tsdbIterMergerNext(committer->tombIterMerger), &lino, _exit); + } } _exit: