fix issue
This commit is contained in:
parent
dc2f7872f8
commit
410a177637
|
@ -80,6 +80,7 @@ SStreamStateCur* streamStateSeekKeyNext(SStreamState* pState, const SWinKey* key
|
||||||
SStreamStateCur* streamStateFillSeekKeyNext(SStreamState* pState, const SWinKey* key);
|
SStreamStateCur* streamStateFillSeekKeyNext(SStreamState* pState, const SWinKey* key);
|
||||||
SStreamStateCur* streamStateFillSeekKeyPrev(SStreamState* pState, const SWinKey* key);
|
SStreamStateCur* streamStateFillSeekKeyPrev(SStreamState* pState, const SWinKey* key);
|
||||||
void streamStateFreeCur(SStreamStateCur* pCur);
|
void streamStateFreeCur(SStreamStateCur* pCur);
|
||||||
|
void streamStateResetCur(SStreamStateCur* pCur);
|
||||||
|
|
||||||
int32_t streamStateGetGroupKVByCur(SStreamStateCur* pCur, SWinKey* pKey, const void** pVal, int32_t* pVLen);
|
int32_t streamStateGetGroupKVByCur(SStreamStateCur* pCur, SWinKey* pKey, const void** pVal, int32_t* pVLen);
|
||||||
int32_t streamStateGetKVByCur(SStreamStateCur* pCur, SWinKey* pKey, const void** pVal, int32_t* pVLen);
|
int32_t streamStateGetKVByCur(SStreamStateCur* pCur, SWinKey* pKey, const void** pVal, int32_t* pVLen);
|
||||||
|
|
|
@ -2680,6 +2680,9 @@ void streamSessionReloadState(SOperatorInfo* pOperator) {
|
||||||
for (int32_t i = 0; i < num; i++) {
|
for (int32_t i = 0; i < num; i++) {
|
||||||
SResultWindowInfo winInfo = {0};
|
SResultWindowInfo winInfo = {0};
|
||||||
getSessionWindowInfoByKey(pAggSup, pSeKeyBuf + i, &winInfo);
|
getSessionWindowInfoByKey(pAggSup, pSeKeyBuf + i, &winInfo);
|
||||||
|
if (!IS_VALID_SESSION_WIN(winInfo)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
int32_t winNum = compactSessionWindow(pOperator, &winInfo, pInfo->pStUpdated, pInfo->pStDeleted, true);
|
int32_t winNum = compactSessionWindow(pOperator, &winInfo, pInfo->pStUpdated, pInfo->pStDeleted, true);
|
||||||
if (winNum > 0) {
|
if (winNum > 0) {
|
||||||
qDebug("===stream=== reload state. save result %" PRId64 ", %" PRIu64, winInfo.sessionWin.win.skey,
|
qDebug("===stream=== reload state. save result %" PRId64 ", %" PRIu64, winInfo.sessionWin.win.skey,
|
||||||
|
|
|
@ -266,11 +266,11 @@ SStreamStateCur* sessionWinStateSeekKeyCurrentPrev(SStreamFileState* pFileState,
|
||||||
pCur->pStreamFileState = pFileState;
|
pCur->pStreamFileState = pFileState;
|
||||||
return pCur;
|
return pCur;
|
||||||
}
|
}
|
||||||
static void transformCursor(SStreamFileState* pFileState, SStreamStateCur** ppCur) {
|
static void transformCursor(SStreamFileState* pFileState, SStreamStateCur* pCur) {
|
||||||
SStreamStateCur* pCur = *ppCur;
|
if (!pCur) {
|
||||||
streamStateFreeCur(pCur);
|
return;
|
||||||
pCur = createStreamStateCursor();
|
}
|
||||||
(*ppCur) = pCur;
|
streamStateResetCur(pCur);
|
||||||
pCur->buffIndex = 0;
|
pCur->buffIndex = 0;
|
||||||
pCur->pStreamFileState = pFileState;
|
pCur->pStreamFileState = pFileState;
|
||||||
}
|
}
|
||||||
|
@ -278,12 +278,14 @@ static void transformCursor(SStreamFileState* pFileState, SStreamStateCur** ppCu
|
||||||
static void checkAndTransformCursor(SStreamFileState* pFileState, const uint64_t groupId, SArray* pWinStates, SStreamStateCur** ppCur) {
|
static void checkAndTransformCursor(SStreamFileState* pFileState, const uint64_t groupId, SArray* pWinStates, SStreamStateCur** ppCur) {
|
||||||
SSessionKey key = {.groupId = groupId};
|
SSessionKey key = {.groupId = groupId};
|
||||||
int32_t code = streamStateSessionGetKVByCur_rocksdb(*ppCur, &key, NULL, NULL);
|
int32_t code = streamStateSessionGetKVByCur_rocksdb(*ppCur, &key, NULL, NULL);
|
||||||
if (code == TSDB_CODE_FAILED || sessionStateKeyCompare(&key, pWinStates, 0) >= 0) {
|
if (taosArrayGetSize(pWinStates) > 0 && (code == TSDB_CODE_FAILED || sessionStateKeyCompare(&key, pWinStates, 0) >= 0)) {
|
||||||
transformCursor(pFileState, ppCur);
|
if ( !(*ppCur) ) {
|
||||||
} else {
|
(*ppCur) = createStreamStateCursor();
|
||||||
SStreamStateCur* pCur = *ppCur;
|
}
|
||||||
pCur->buffIndex = -1;
|
transformCursor(pFileState, *ppCur);
|
||||||
pCur->pStreamFileState = pFileState;
|
} else if (*ppCur) {
|
||||||
|
(*ppCur)->buffIndex = -1;
|
||||||
|
(*ppCur)->pStreamFileState = pFileState;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -323,6 +325,7 @@ int32_t sessionWinStateGetKVByCur(SStreamStateCur* pCur, SSessionKey* pKey, void
|
||||||
if (!pCur) {
|
if (!pCur) {
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
SSHashObj* pSessionBuff = getRowStateBuff(pCur->pStreamFileState);
|
SSHashObj* pSessionBuff = getRowStateBuff(pCur->pStreamFileState);
|
||||||
void** ppBuff = tSimpleHashGet(pSessionBuff, &pKey->groupId, sizeof(uint64_t));
|
void** ppBuff = tSimpleHashGet(pSessionBuff, &pKey->groupId, sizeof(uint64_t));
|
||||||
|
@ -342,20 +345,25 @@ int32_t sessionWinStateGetKVByCur(SStreamStateCur* pCur, SSessionKey* pKey, void
|
||||||
}
|
}
|
||||||
*pKey = *(SSessionKey*)(pPos->pKey);
|
*pKey = *(SSessionKey*)(pPos->pKey);
|
||||||
} else {
|
} else {
|
||||||
int32_t code = streamStateSessionGetKVByCur_rocksdb(pCur, pKey, pVal, pVLen);
|
void* pData = NULL;
|
||||||
if (code == TSDB_CODE_FAILED || sessionStateKeyCompare(pKey, pWinStates, 0) >= 0) {
|
code = streamStateSessionGetKVByCur_rocksdb(pCur, pKey, &pData, pVLen);
|
||||||
transformCursor(pCur->pStreamFileState, &pCur);
|
if (taosArrayGetSize(pWinStates) > 0 && (code == TSDB_CODE_FAILED || sessionStateKeyCompare(pKey, pWinStates, 0) >= 0)) {
|
||||||
if (pCur->buffIndex >= size) {
|
transformCursor(pCur->pStreamFileState, pCur);
|
||||||
return TSDB_CODE_FAILED;
|
|
||||||
}
|
|
||||||
SRowBuffPos* pPos = taosArrayGetP(pWinStates, pCur->buffIndex);
|
SRowBuffPos* pPos = taosArrayGetP(pWinStates, pCur->buffIndex);
|
||||||
if (pVal) {
|
if (pVal) {
|
||||||
*pVal = pPos;
|
*pVal = pPos;
|
||||||
}
|
}
|
||||||
*pKey = *(SSessionKey*)(pPos->pKey);
|
*pKey = *(SSessionKey*)(pPos->pKey);
|
||||||
|
code = TSDB_CODE_SUCCESS;
|
||||||
|
} else if (code == TSDB_CODE_SUCCESS && pVal) {
|
||||||
|
SRowBuffPos* pNewPos = getNewRowPosForWrite(pCur->pStreamFileState);
|
||||||
|
pNewPos->needFree = true;
|
||||||
|
memcpy(pNewPos->pRowBuff, pData, *pVLen);
|
||||||
|
(*pVal) = pNewPos;
|
||||||
}
|
}
|
||||||
|
taosMemoryFreeClear(pData);
|
||||||
}
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t sessionWinStateMoveToNext(SStreamStateCur* pCur) {
|
int32_t sessionWinStateMoveToNext(SStreamStateCur* pCur) {
|
||||||
|
|
|
@ -678,17 +678,29 @@ int32_t streamStateCurPrev(SStreamState* pState, SStreamStateCur* pCur) {
|
||||||
return tdbTbcMoveToPrev(pCur->pCur);
|
return tdbTbcMoveToPrev(pCur->pCur);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void streamStateResetCur(SStreamStateCur* pCur) {
|
||||||
|
if (!pCur) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (pCur->iter) rocksdb_iter_destroy(pCur->iter);
|
||||||
|
if (pCur->snapshot) rocksdb_release_snapshot(pCur->db, pCur->snapshot);
|
||||||
|
if (pCur->readOpt) rocksdb_readoptions_destroy(pCur->readOpt);
|
||||||
|
|
||||||
|
tdbTbcClose(pCur->pCur);
|
||||||
|
|
||||||
|
memset(pCur, 0, sizeof(SStreamStateCur));
|
||||||
|
|
||||||
|
pCur->buffIndex = -1;
|
||||||
|
}
|
||||||
|
|
||||||
void streamStateFreeCur(SStreamStateCur* pCur) {
|
void streamStateFreeCur(SStreamStateCur* pCur) {
|
||||||
if (!pCur || pCur->buffIndex >= 0) {
|
if (!pCur || pCur->buffIndex >= 0) {
|
||||||
taosMemoryFree(pCur);
|
taosMemoryFree(pCur);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
qDebug("streamStateFreeCur");
|
qDebug("streamStateFreeCur");
|
||||||
rocksdb_iter_destroy(pCur->iter);
|
streamStateResetCur(pCur);
|
||||||
if (pCur->snapshot) rocksdb_release_snapshot(pCur->db, pCur->snapshot);
|
|
||||||
rocksdb_readoptions_destroy(pCur->readOpt);
|
|
||||||
|
|
||||||
tdbTbcClose(pCur->pCur);
|
|
||||||
taosMemoryFree(pCur);
|
taosMemoryFree(pCur);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue