fix(tsdb): record the pinned block iter.
This commit is contained in:
parent
18bb27cdff
commit
ccecf05ff8
|
@ -749,8 +749,7 @@ typedef struct SMergeTree {
|
|||
int8_t backward;
|
||||
SRBTree rbt;
|
||||
SLDataIter *pIter;
|
||||
bool destroyLoadInfo;
|
||||
SSttBlockLoadInfo *pLoadInfo;
|
||||
SLDataIter *pPinnedBlockIter;
|
||||
const char *idStr;
|
||||
bool ignoreEarlierTs;
|
||||
} SMergeTree;
|
||||
|
|
|
@ -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,16 +865,20 @@ 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) {
|
||||
|
@ -880,16 +886,18 @@ void tMergeTreePinSttBlock(SMergeTree *pMTree) {
|
|||
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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue