From 580b7124cf1a8c35fd0736712e40b9ef58bbf990 Mon Sep 17 00:00:00 2001 From: Minglei Jin Date: Thu, 27 Jul 2023 09:16:28 +0800 Subject: [PATCH] fix(tsdb/commit2): new maxDelKey for commit context --- source/dnode/vnode/src/tsdb/tsdbCommit2.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/source/dnode/vnode/src/tsdb/tsdbCommit2.c b/source/dnode/vnode/src/tsdb/tsdbCommit2.c index ed05d7a6ca..24427d1688 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCommit2.c +++ b/source/dnode/vnode/src/tsdb/tsdbCommit2.c @@ -37,6 +37,7 @@ typedef struct { int64_t cid; int64_t now; TSKEY nextKey; + TSKEY maxDelKey; int32_t fid; int32_t expLevel; SDiskID did; @@ -161,6 +162,9 @@ static int32_t tsdbCommitTombData(SCommitter2 *committer) { SMetaInfo info; if (committer->ctx->fset == NULL && !committer->ctx->hasTSData) { + if (committer->ctx->maxKey < committer->ctx->maxDelKey) { + committer->ctx->nextKey = committer->ctx->maxKey + 1; + } return 0; } @@ -185,16 +189,18 @@ static int32_t tsdbCommitTombData(SCommitter2 *committer) { goto _next; } + TSKEY maxKey = committer->ctx->maxKey; if (record->ekey > committer->ctx->maxKey) { - committer->ctx->maxKey = committer->ctx->maxKey + 1; + maxKey = committer->ctx->maxKey + 1; } - if (record->ekey > committer->ctx->maxKey) { - committer->ctx->nextKey = record->ekey; + if (record->ekey > committer->ctx->maxKey && committer->ctx->nextKey > maxKey) { + committer->ctx->nextKey = maxKey; + committer->ctx->maxDelKey = TMAX(record->ekey, committer->ctx->maxDelKey); } record->skey = TMAX(record->skey, committer->ctx->minKey); - record->ekey = TMIN(record->ekey, committer->ctx->maxKey); + record->ekey = TMIN(record->ekey, maxKey); numRecord++; code = tsdbFSetWriteTombRecord(committer->writer, record);