From 6c7dce7363b631ddcb719766c3690bd7548e471a Mon Sep 17 00:00:00 2001 From: Cary Xu Date: Fri, 17 Jun 2022 18:06:08 +0800 Subject: [PATCH 1/3] fix: merge data in memory and file --- source/dnode/vnode/src/tsdb/tsdbCommit.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/source/dnode/vnode/src/tsdb/tsdbCommit.c b/source/dnode/vnode/src/tsdb/tsdbCommit.c index fe89321ae9..dd278a7953 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCommit.c +++ b/source/dnode/vnode/src/tsdb/tsdbCommit.c @@ -111,7 +111,7 @@ int32_t tsdbBegin(STsdb *pTsdb) { int32_t tsdbCommit(STsdb *pTsdb) { if (!pTsdb) return 0; - + int32_t code = 0; SCommitH commith = {0}; SDFileSet *pSet = NULL; @@ -495,7 +495,9 @@ static int32_t tsdbCommitToFile(SCommitH *pCommith, SDFileSet *pSet, int fid) { break; } - if (pIter && pIter->pTable && (!pIdx || (pIter->pTable->suid <= pIdx->suid || pIter->pTable->uid <= pIdx->uid))) { + if (pIter && pIter->pTable && + (!pIdx || ((pIter->pTable->suid < pIdx->suid) || + (pIter->pTable->suid == pIdx->suid && pIter->pTable->uid <= pIdx->uid)))) { if (tsdbCommitToTable(pCommith, mIter) < 0) { tsdbCloseCommitFile(pCommith, true); // revert the file change @@ -503,7 +505,7 @@ static int32_t tsdbCommitToFile(SCommitH *pCommith, SDFileSet *pSet, int fid) { return -1; } - if (pIdx && (pIter->pTable->uid == pIdx->uid)) { + if (pIdx && ((pIter->pTable->uid == pIdx->uid) && (pIter->pTable->suid == pIdx->suid))) { ++fIter; } ++mIter; @@ -517,7 +519,10 @@ static int32_t tsdbCommitToFile(SCommitH *pCommith, SDFileSet *pSet, int fid) { tsdbApplyDFileSetChange(TSDB_COMMIT_WRITE_FSET(pCommith), pSet); return -1; } + ++fIter; + } else { + ASSERT(0); } } From 715bb6d2e906500978809dca9198951f2d9e6aa7 Mon Sep 17 00:00:00 2001 From: Cary Xu Date: Fri, 17 Jun 2022 18:08:41 +0800 Subject: [PATCH 2/3] other: code optimization --- source/dnode/vnode/src/tsdb/tsdbCommit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/dnode/vnode/src/tsdb/tsdbCommit.c b/source/dnode/vnode/src/tsdb/tsdbCommit.c index dd278a7953..284b6c9a4c 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCommit.c +++ b/source/dnode/vnode/src/tsdb/tsdbCommit.c @@ -497,7 +497,7 @@ static int32_t tsdbCommitToFile(SCommitH *pCommith, SDFileSet *pSet, int fid) { if (pIter && pIter->pTable && (!pIdx || ((pIter->pTable->suid < pIdx->suid) || - (pIter->pTable->suid == pIdx->suid && pIter->pTable->uid <= pIdx->uid)))) { + ((pIter->pTable->suid == pIdx->suid) && (pIter->pTable->uid <= pIdx->uid))))) { if (tsdbCommitToTable(pCommith, mIter) < 0) { tsdbCloseCommitFile(pCommith, true); // revert the file change From 22e62e5cd2e4833302761dc6a6283c2582dadaa3 Mon Sep 17 00:00:00 2001 From: Cary Xu Date: Fri, 17 Jun 2022 18:11:09 +0800 Subject: [PATCH 3/3] other: code optimization --- source/dnode/vnode/src/tsdb/tsdbCommit.c | 1 - 1 file changed, 1 deletion(-) diff --git a/source/dnode/vnode/src/tsdb/tsdbCommit.c b/source/dnode/vnode/src/tsdb/tsdbCommit.c index 284b6c9a4c..e98fd8ae1f 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCommit.c +++ b/source/dnode/vnode/src/tsdb/tsdbCommit.c @@ -519,7 +519,6 @@ static int32_t tsdbCommitToFile(SCommitH *pCommith, SDFileSet *pSet, int fid) { tsdbApplyDFileSetChange(TSDB_COMMIT_WRITE_FSET(pCommith), pSet); return -1; } - ++fIter; } else { ASSERT(0);