Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion include/libs/new-stream/streamReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ typedef struct SStreamTriggerReaderInfo {
SSDataBlock* triggerResBlock;
SSDataBlock* calcResBlock;
SSDataBlock* tsBlock;
SSDataBlock* calcResBlockTmp;
SExprInfo* pExprInfo;
int32_t numOfExpr;
SArray* uidList; // for virtual table stream, uid list
Expand Down
8 changes: 7 additions & 1 deletion source/common/src/ttime.c
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,13 @@ int64_t taosTimeAdd(int64_t t, int64_t duration, char unit, int32_t precision, t
}

if (!IS_CALENDAR_TIME_DURATION(unit)) {
return t + duration;
double tmp = t;
if (tmp + duration >= (double)INT64_MAX || tmp + duration <= (double)INT64_MIN) {
uError("time overflow, t:%" PRId64 ", duration:%" PRId64 ", unit:%c, precision:%d", t, duration, unit, precision);
return t;
} else {
return t + duration;
}
}

// The following code handles the y/n time duration
Expand Down
18 changes: 8 additions & 10 deletions source/dnode/vnode/src/vnd/vnodeStream.c
Original file line number Diff line number Diff line change
Expand Up @@ -1371,8 +1371,6 @@ static int32_t vnodeProcessStreamTsdbTsDataReq(SVnode* pVnode, SRpcMsg* pMsg, SS
STREAM_CHECK_RET_GOTO(createOneDataBlock(sStreamReaderInfo->triggerResBlock, false, &pTaskInner->pResBlockDst));
STREAM_CHECK_RET_GOTO(createOneDataBlock(sStreamReaderInfo->tsBlock, false, &pBlockRes));

// STREAM_CHECK_RET_GOTO(createOneDataBlock(sStreamReaderInfo->tsBlock, false, pBlock));

while (1) {
bool hasNext = false;
STREAM_CHECK_RET_GOTO(getTableDataInfo(pTaskInner, &hasNext));
Expand Down Expand Up @@ -1489,6 +1487,7 @@ static int32_t vnodeProcessStreamTsdbCalcDataReq(SVnode* pVnode, SRpcMsg* pMsg,
int32_t lino = 0;
void* buf = NULL;
size_t size = 0;
SSDataBlock* pBlockRes = NULL;

STREAM_CHECK_NULL_GOTO(sStreamReaderInfo, terrno);
void* pTask = sStreamReaderInfo->pTask;
Expand All @@ -1507,9 +1506,8 @@ static int32_t vnodeProcessStreamTsdbCalcDataReq(SVnode* pVnode, SRpcMsg* pMsg,
STREAM_CHECK_RET_GOTO(createStreamTask(pVnode, &options, &pTaskInner, sStreamReaderInfo->triggerResBlock, NULL, &api));

STREAM_CHECK_RET_GOTO(taosHashPut(sStreamReaderInfo->streamTaskMap, &key, LONG_BYTES, &pTaskInner, sizeof(pTaskInner)));

STREAM_CHECK_RET_GOTO(createOneDataBlock(sStreamReaderInfo->calcResBlock, false, &pTaskInner->pResBlockDst));

STREAM_CHECK_RET_GOTO(createOneDataBlock(sStreamReaderInfo->triggerResBlock, false, &pTaskInner->pResBlockDst));
STREAM_CHECK_RET_GOTO(createOneDataBlock(sStreamReaderInfo->calcResBlock, false, &pBlockRes));
} else {
void** tmp = taosHashGet(sStreamReaderInfo->streamTaskMap, &key, LONG_BYTES);
STREAM_CHECK_NULL_GOTO(tmp, TSDB_CODE_STREAM_NO_CONTEXT);
Expand All @@ -1529,14 +1527,14 @@ static int32_t vnodeProcessStreamTsdbCalcDataReq(SVnode* pVnode, SRpcMsg* pMsg,
SSDataBlock* pBlock = NULL;
STREAM_CHECK_RET_GOTO(getTableData(pTaskInner, &pBlock));
STREAM_CHECK_RET_GOTO(qStreamFilter(pBlock, pTaskInner->pFilterInfo));
blockDataTransform(sStreamReaderInfo->calcResBlockTmp, pBlock);
STREAM_CHECK_RET_GOTO(blockDataMerge(pTaskInner->pResBlockDst, sStreamReaderInfo->calcResBlockTmp));
STREAM_CHECK_RET_GOTO(blockDataMerge(pTaskInner->pResBlockDst, pBlock));
if (pTaskInner->pResBlockDst->info.rows >= STREAM_RETURN_ROWS_NUM) {
break;
}
}
STREAM_CHECK_RET_GOTO(buildRsp(pTaskInner->pResBlockDst, &buf, &size));
ST_TASK_DLOG("vgId:%d %s get result rows:%" PRId64, TD_VID(pVnode), __func__, pTaskInner->pResBlockDst->info.rows);
blockDataTransform(pBlockRes, pTaskInner->pResBlockDst);
STREAM_CHECK_RET_GOTO(buildRsp(pBlockRes, &buf, &size));
ST_TASK_DLOG("vgId:%d %s get result rows:%" PRId64, TD_VID(pVnode), __func__, pBlockRes->info.rows);
if (!hasNext) {
taosHashRemove(sStreamReaderInfo->streamTaskMap, &key, LONG_BYTES);
}
Expand All @@ -1546,7 +1544,7 @@ static int32_t vnodeProcessStreamTsdbCalcDataReq(SVnode* pVnode, SRpcMsg* pMsg,
SRpcMsg rsp = {
.msgType = TDMT_STREAM_TRIGGER_PULL_RSP, .info = pMsg->info, .pCont = buf, .contLen = size, .code = code};
tmsgSendRsp(&rsp);

blockDataDestroy(pBlockRes);
return code;
}

Expand Down
23 changes: 2 additions & 21 deletions source/libs/executor/src/dynqueryctrloperator.c
Original file line number Diff line number Diff line change
Expand Up @@ -1782,32 +1782,13 @@ static int32_t resetDynQueryCtrlOperState(SOperatorInfo* pOper) {
case DYN_QTYPE_STB_HASH:{
pDyn->stbJoin.execInfo = (SDynQueryCtrlExecInfo){0};
SStbJoinDynCtrlInfo* pStbJoin = &pDyn->stbJoin;
if (pStbJoin->basic.batchFetch) {
if (pStbJoin->ctx.prev.leftHash) {
tSimpleHashSetFreeFp(pStbJoin->ctx.prev.leftHash, freeVgTableList);
tSimpleHashClear(pStbJoin->ctx.prev.leftHash);
}
if (pStbJoin->ctx.prev.rightHash) {
tSimpleHashSetFreeFp(pStbJoin->ctx.prev.rightHash, freeVgTableList);
tSimpleHashClear(pStbJoin->ctx.prev.rightHash);
}
} else {
if (pStbJoin->ctx.prev.leftCache) {
tSimpleHashClear(pStbJoin->ctx.prev.leftCache);
}
if (pStbJoin->ctx.prev.rightCache) {
tSimpleHashClear(pStbJoin->ctx.prev.rightCache);
}
if (pStbJoin->ctx.prev.onceTable) {
tSimpleHashClear(pStbJoin->ctx.prev.onceTable);
}
}
destroyStbJoinDynCtrlInfo(&pDyn->stbJoin);

int32_t code = initSeqStbJoinTableHash(&pDyn->stbJoin.ctx.prev, pDyn->stbJoin.basic.batchFetch);
if (TSDB_CODE_SUCCESS != code) {
qError("initSeqStbJoinTableHash failed since %s", tstrerror(code));
return code;
}
destroyStbJoinTableList(pStbJoin->ctx.prev.pListHead);
pStbJoin->ctx.prev.pListHead = NULL;
pStbJoin->ctx.prev.joinBuild = false;
pStbJoin->ctx.prev.pListTail = NULL;
Expand Down
10 changes: 5 additions & 5 deletions source/libs/executor/src/groupcacheoperator.c
Original file line number Diff line number Diff line change
Expand Up @@ -641,8 +641,8 @@ static int32_t retrieveBlkFromBufCache(SGroupCacheOperatorInfo* pGCache, SGroupC
static FORCE_INLINE void initGcVgroupCtx(SOperatorInfo* pOperator, SGcVgroupCtx* pVgCtx, int32_t downstreamId, int32_t vgId, SArray* pTbList) {
pVgCtx->pTbList = pTbList;
pVgCtx->id = vgId;
(void)snprintf(pVgCtx->fileCtx.baseFilename, sizeof(pVgCtx->fileCtx.baseFilename) - 1, "%s/gc_%d_%" PRIx64 "_%" PRIu64 "_%d_%d",
tsTempDir, taosGetPId(), pOperator->pTaskInfo->id.queryId, pOperator->pTaskInfo->id.taskId, downstreamId, vgId);
(void)snprintf(pVgCtx->fileCtx.baseFilename, sizeof(pVgCtx->fileCtx.baseFilename) - 1, "%s/gc_%d_%" PRIx64 "_%" PRIu64 "_%p_%d_%d",
tsTempDir, taosGetPId(), pOperator->pTaskInfo->id.queryId, pOperator->pTaskInfo->id.taskId, pOperator, downstreamId, vgId);
pVgCtx->fileCtx.baseFilename[sizeof(pVgCtx->fileCtx.baseFilename) - 1] = 0;

pVgCtx->fileCtx.baseNameLen = strlen(pVgCtx->fileCtx.baseFilename);
Expand Down Expand Up @@ -1454,8 +1454,8 @@ static int32_t initGroupCacheDownstreamCtx(SOperatorInfo* pOperator) {
return terrno;
}

(void)snprintf(pCtx->fileCtx.baseFilename, sizeof(pCtx->fileCtx.baseFilename) - 1, "%s/gc_%d_%" PRIx64 "_%" PRIu64 "_%d",
tsTempDir, taosGetPId(), pOperator->pTaskInfo->id.queryId, pOperator->pTaskInfo->id.taskId, pCtx->id);
(void)snprintf(pCtx->fileCtx.baseFilename, sizeof(pCtx->fileCtx.baseFilename) - 1, "%s/gc_%d_%" PRIx64 "_%" PRIu64 "_%p_%d",
tsTempDir, taosGetPId(), pOperator->pTaskInfo->id.queryId, pOperator->pTaskInfo->id.taskId, pOperator, pCtx->id);
pCtx->fileCtx.baseFilename[sizeof(pCtx->fileCtx.baseFilename) - 1] = 0;
pCtx->fileCtx.baseNameLen = strlen(pCtx->fileCtx.baseFilename);
}
Expand Down Expand Up @@ -1542,7 +1542,7 @@ static int32_t resetGroupCacheDownstreamCtx(SOperatorInfo* pOper) {
tSimpleHashPut(pCtx->pVgTbHash, &defaultVg, sizeof(defaultVg), &vgCtx, sizeof(vgCtx));
}

taosArrayClear(pCtx->pFreeBlock);
taosArrayClearEx(pCtx->pFreeBlock, freeGcBlockInList);
taosHashClear(pCtx->pSessions);
taosHashClear(pCtx->pWaitSessions);
freeSGcFileCacheCtx(&pCtx->fileCtx);
Expand Down
2 changes: 0 additions & 2 deletions source/libs/new-stream/src/streamReader.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ static void releaseStreamReaderInfo(void* p) {
blockDataDestroy(pInfo->triggerResBlock);
blockDataDestroy(pInfo->calcResBlock);
blockDataDestroy(pInfo->tsBlock);
blockDataDestroy(pInfo->calcResBlockTmp);
destroyExprInfo(pInfo->pExprInfo, pInfo->numOfExpr);
taosMemoryFreeClear(pInfo->pExprInfo);
taosArrayDestroy(pInfo->uidList);
Expand Down Expand Up @@ -349,7 +348,6 @@ static SStreamTriggerReaderInfo* createStreamReaderInfo(void* pTask, const SStre
SNodeList* pScanCols = ((STableScanPhysiNode*)(sStreamReaderInfo->calcAst->pNode))->scan.pScanCols;
setColIdForCalcResBlock(pseudoCols, sStreamReaderInfo->calcResBlock->pDataBlock);
setColIdForCalcResBlock(pScanCols, sStreamReaderInfo->calcResBlock->pDataBlock);
STREAM_CHECK_RET_GOTO(createOneDataBlock(sStreamReaderInfo->calcResBlock, false, &sStreamReaderInfo->calcResBlockTmp));
}

STREAM_CHECK_RET_GOTO(createDataBlockForTs(&sStreamReaderInfo->tsBlock));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def test_three_gorges_second_case18(self):
self.checkStreamRunning()
self.sxny_data2()
self.dataIn()
tdSql.checkRowsLoop(500,f"select val,tablename,point, ps_code, cnstationno, index_code from {self.dbname}.{self.outTbname} order by tablename;",100,1)
tdSql.checkRowsLoop(500,f"select val,tablename,point, ps_code, cnstationno, index_code from {self.dbname}.{self.outTbname} order by tablename;",200,1)
self.checkResultWithResultFile()


Expand Down