diff --git a/source/dnode/vnode/src/inc/tsdb.h b/source/dnode/vnode/src/inc/tsdb.h index f6f49575a1..0053e2bea0 100644 --- a/source/dnode/vnode/src/inc/tsdb.h +++ b/source/dnode/vnode/src/inc/tsdb.h @@ -746,13 +746,12 @@ typedef struct SSttBlockLoadInfo { } SSttBlockLoadInfo; typedef struct SMergeTree { - int8_t backward; - SRBTree rbt; - SLDataIter *pIter; - bool destroyLoadInfo; - SSttBlockLoadInfo *pLoadInfo; - const char *idStr; - bool ignoreEarlierTs; + int8_t backward; + SRBTree rbt; + SLDataIter *pIter; + SLDataIter *pPinnedBlockIter; + const char *idStr; + bool ignoreEarlierTs; } SMergeTree; typedef struct { diff --git a/source/dnode/vnode/src/tsdb/tsdbMergeTree.c b/source/dnode/vnode/src/tsdb/tsdbMergeTree.c index 0b9a7ee8d9..d6318de99c 100644 --- a/source/dnode/vnode/src/tsdb/tsdbMergeTree.c +++ b/source/dnode/vnode/src/tsdb/tsdbMergeTree.c @@ -846,16 +846,18 @@ static void tLDataIterPinSttBlock(SLDataIter* pIter, const char* id) { if (pInfo->blockData[0].sttBlockIndex == pIter->iSttBlk) { pInfo->blockData[0].pin = true; ASSERT(!pInfo->blockData[1].pin); + tsdbDebug("pin stt-block, blockIndex:%d, stt-fileVer:%" PRId64 " %s", pIter->iSttBlk, pIter->cid, id); return; } if (pInfo->blockData[1].sttBlockIndex == pIter->iSttBlk) { pInfo->blockData[1].pin = true; ASSERT(!pInfo->blockData[0].pin); + tsdbDebug("pin stt-block, blockIndex:%d, stt-fileVer:%"PRId64" %s", pIter->iSttBlk, pIter->cid, id); return; } - tsdbError("failed to pin any stt block, sttBlock:%d, %s", pIter->iSttBlk, id); + tsdbError("failed to pin any stt block, sttBlock:%d stt-fileVer:%"PRId64" %s", pIter->iSttBlk, pIter->cid, id); } static void tLDataIterUnpinSttBlock(SLDataIter* pIter, const char* id) { @@ -863,33 +865,39 @@ static void tLDataIterUnpinSttBlock(SLDataIter* pIter, const char* id) { if (pInfo->blockData[0].pin) { ASSERT(!pInfo->blockData[1].pin); pInfo->blockData[0].pin = false; + tsdbDebug("unpin stt-block, blockIndex:%d, stt-fileVer:%"PRId64" %s", pInfo->blockData[1].sttBlockIndex, + pIter->cid, id); return; } if (pInfo->blockData[1].pin) { ASSERT(!pInfo->blockData[0].pin); pInfo->blockData[1].pin = false; + tsdbDebug("pin stt-block, blockIndex:%d, stt-fileVer:%" PRId64 " %s", pInfo->blockData[1].sttBlockIndex, pIter->cid, + id); return; } - tsdbError("failed to unpin any stt block, sttBlock:%d, %s", pIter->iSttBlk, id); + tsdbError("failed to unpin any stt block, sttBlock:%d stt-fileVer:%" PRId64 " %s", pIter->iSttBlk, pIter->cid, id); } void tMergeTreePinSttBlock(SMergeTree *pMTree) { if (pMTree->pIter == NULL) { - return; + return; } - SLDataIter* pIter = pMTree->pIter; + SLDataIter *pIter = pMTree->pIter; + pMTree->pPinnedBlockIter = pIter; tLDataIterPinSttBlock(pIter, pMTree->idStr); } void tMergeTreeUnpinSttBlock(SMergeTree *pMTree) { - if (pMTree->pIter == NULL) { + if (pMTree->pPinnedBlockIter == NULL) { return; } - SLDataIter* pIter = pMTree->pIter; + SLDataIter* pIter = pMTree->pPinnedBlockIter; + pMTree->pPinnedBlockIter = NULL; tLDataIterUnpinSttBlock(pIter, pMTree->idStr); } @@ -927,8 +935,5 @@ bool tMergeTreeNext(SMergeTree *pMTree) { void tMergeTreeClose(SMergeTree *pMTree) { pMTree->pIter = NULL; - if (pMTree->destroyLoadInfo) { - pMTree->pLoadInfo = destroyLastBlockLoadInfo(pMTree->pLoadInfo); - pMTree->destroyLoadInfo = false; - } + pMTree->pPinnedBlockIter = NULL; }