diff --git a/src/system/detail/inc/vnodeQueryImpl.h b/src/system/detail/inc/vnodeQueryImpl.h index a26e9b6285af39156edf20d331e0afaaab4bf578..f512dcac207b868b8739a222f7572362ee10ac2f 100644 --- a/src/system/detail/inc/vnodeQueryImpl.h +++ b/src/system/detail/inc/vnodeQueryImpl.h @@ -186,7 +186,7 @@ int32_t vnodeGetVnodeHeaderFileIdx(int32_t* fid, SQueryRuntimeEnv* pRuntimeEnv, int32_t createDataBlocksInfoEx(SMeterDataInfo** pMeterDataInfo, int32_t numOfMeters, SMeterDataBlockInfoEx** pDataBlockInfoEx, int32_t numOfCompBlocks, - int32_t* nAllocBlocksInfoSize, int64_t addr); + int32_t* nAllocBlocksInfoSize, int32_t* realBlocks, int64_t addr); void freeMeterBlockInfoEx(SMeterDataBlockInfoEx* pDataBlockInfoEx, int32_t len); void setExecutionContext(SMeterQuerySupportObj* pSupporter, SOutputRes* outputRes, int32_t meterIdx, int32_t groupIdx, diff --git a/src/system/detail/src/vnodeQueryImpl.c b/src/system/detail/src/vnodeQueryImpl.c index c1653b5dad85689e3fabe1b150dd06cb7c9cdec8..15005c9444f3912ce0861eff99fa706b20b094f2 100644 --- a/src/system/detail/src/vnodeQueryImpl.c +++ b/src/system/detail/src/vnodeQueryImpl.c @@ -6111,7 +6111,7 @@ void cleanBlockOrderSupporter(SBlockOrderSupporter* pSupporter, int32_t numOfTab int32_t createDataBlocksInfoEx(SMeterDataInfo **pMeterDataInfo, int32_t numOfMeters, SMeterDataBlockInfoEx **pDataBlockInfoEx, int32_t numOfCompBlocks, - int32_t *nAllocBlocksInfoSize, int64_t addr) { + int32_t *nAllocBlocksInfoSize, int32_t* realBlocks, int64_t addr) { // release allocated memory first freeDataBlockFieldInfo(*pDataBlockInfoEx, *nAllocBlocksInfoSize); @@ -6174,7 +6174,9 @@ int32_t createDataBlocksInfoEx(SMeterDataInfo **pMeterDataInfo, int32_t numOfMet dTrace("QInfo %p create data blocks info struct completed", addr); - assert(cnt == numOfCompBlocks && numOfQualMeters <= numOfMeters); // the pMeterDataInfo[j]->numOfBlocks may be 0 + assert(cnt <= numOfCompBlocks && numOfQualMeters <= numOfMeters); // the pMeterDataInfo[j]->numOfBlocks may be 0 + *realBlocks = cnt; + supporter.numOfMeters = numOfQualMeters; SLoserTreeInfo *pTree = NULL; diff --git a/src/system/detail/src/vnodeQueryProcess.c b/src/system/detail/src/vnodeQueryProcess.c index 8ad2c3f3094a948580b54ade88283d06f499a674..a68b9245792b606540b9cb43f3bbdeac6585055a 100644 --- a/src/system/detail/src/vnodeQueryProcess.c +++ b/src/system/detail/src/vnodeQueryProcess.c @@ -345,8 +345,9 @@ static void queryOnMultiDataFiles(SQInfo *pQInfo, SMeterDataInfo *pMeterDataInfo continue; } + int32_t realBlocks = 0; ret = createDataBlocksInfoEx(pReqMeterDataInfo, numOfQualifiedMeters, &pDataBlockInfoEx, numOfBlocks, - &nAllocBlocksInfoSize, (int64_t)pQInfo); + &nAllocBlocksInfoSize, &realBlocks, (int64_t)pQInfo); if (ret != TSDB_CODE_SUCCESS) { // failed to create data blocks dError("QInfo:%p build blockInfoEx failed, abort", pQInfo); tfree(pReqMeterDataInfo); @@ -356,6 +357,15 @@ static void queryOnMultiDataFiles(SQInfo *pQInfo, SMeterDataInfo *pMeterDataInfo return; } + assert(realBlocks <= numOfBlocks); + numOfBlocks = realBlocks; + + if (numOfBlocks == 0) { + fid += step; + tfree(pReqMeterDataInfo); + continue; + } + dTrace("QInfo:%p start to load %d blocks and check", pQInfo, numOfBlocks); int64_t TRACE_OUTPUT_BLOCK_CNT = 10000; int64_t stimeUnit = 0;