fix(stream): check return value.
This commit is contained in:
parent
878d77fc7f
commit
79ad7585ef
|
@ -201,7 +201,7 @@ void qStreamSetOpen(qTaskInfo_t tinfo);
|
||||||
|
|
||||||
void qStreamSetSourceExcluded(qTaskInfo_t tinfo, int8_t sourceExcluded);
|
void qStreamSetSourceExcluded(qTaskInfo_t tinfo, int8_t sourceExcluded);
|
||||||
|
|
||||||
void qStreamExtractOffset(qTaskInfo_t tinfo, STqOffsetVal* pOffset);
|
int32_t qStreamExtractOffset(qTaskInfo_t tinfo, STqOffsetVal* pOffset);
|
||||||
|
|
||||||
SMqBatchMetaRsp* qStreamExtractMetaMsg(qTaskInfo_t tinfo);
|
SMqBatchMetaRsp* qStreamExtractMetaMsg(qTaskInfo_t tinfo);
|
||||||
|
|
||||||
|
|
|
@ -115,14 +115,15 @@ int32_t tqScanData(STQ* pTq, STqHandle* pHandle, SMqDataRsp* pRsp, STqOffsetVal*
|
||||||
if (pDataBlock == NULL) {
|
if (pDataBlock == NULL) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
STqOffsetVal offset = {0};
|
STqOffsetVal offset = {0};
|
||||||
qStreamExtractOffset(task, &offset);
|
code = qStreamExtractOffset(task, &offset);
|
||||||
|
TSDB_CHECK_CODE(code, line, END);
|
||||||
|
|
||||||
pHandle->block = NULL;
|
pHandle->block = NULL;
|
||||||
|
|
||||||
code = createOneDataBlock(pDataBlock, true, &pHandle->block);
|
code = createOneDataBlock(pDataBlock, true, &pHandle->block);
|
||||||
if (code) {
|
TSDB_CHECK_CODE(code, line, END);
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
pHandle->blockTime = offset.ts;
|
pHandle->blockTime = offset.ts;
|
||||||
tOffsetDestroy(&offset);
|
tOffsetDestroy(&offset);
|
||||||
|
@ -140,8 +141,11 @@ int32_t tqScanData(STQ* pTq, STqHandle* pHandle, SMqDataRsp* pRsp, STqOffsetVal*
|
||||||
} else {
|
} else {
|
||||||
code = copyDataBlock(pHandle->block, pDataBlock);
|
code = copyDataBlock(pHandle->block, pDataBlock);
|
||||||
TSDB_CHECK_CODE(code, line, END);
|
TSDB_CHECK_CODE(code, line, END);
|
||||||
|
|
||||||
STqOffsetVal offset = {0};
|
STqOffsetVal offset = {0};
|
||||||
qStreamExtractOffset(task, &offset);
|
code = qStreamExtractOffset(task, &offset);
|
||||||
|
TSDB_CHECK_CODE(code, line, END);
|
||||||
|
|
||||||
pRsp->sleepTime = offset.ts - pHandle->blockTime;
|
pRsp->sleepTime = offset.ts - pHandle->blockTime;
|
||||||
pHandle->blockTime = offset.ts;
|
pHandle->blockTime = offset.ts;
|
||||||
tOffsetDestroy(&offset);
|
tOffsetDestroy(&offset);
|
||||||
|
@ -164,10 +168,11 @@ int32_t tqScanData(STQ* pTq, STqHandle* pHandle, SMqDataRsp* pRsp, STqOffsetVal*
|
||||||
|
|
||||||
tqDebug("consumer:0x%" PRIx64 " vgId:%d tmq task executed finished, total blocks:%d, totalRows:%d",
|
tqDebug("consumer:0x%" PRIx64 " vgId:%d tmq task executed finished, total blocks:%d, totalRows:%d",
|
||||||
pHandle->consumerId, vgId, pRsp->common.blockNum, totalRows);
|
pHandle->consumerId, vgId, pRsp->common.blockNum, totalRows);
|
||||||
qStreamExtractOffset(task, &pRsp->common.rspOffset);
|
code = qStreamExtractOffset(task, &pRsp->common.rspOffset);
|
||||||
END:
|
END:
|
||||||
if ( code!= 0){
|
if (code != 0) {
|
||||||
tqError("consumer:0x%" PRIx64 " vgId:%d tmq task executed error, line:%d code:%d", pHandle->consumerId, vgId, line, code);
|
tqError("consumer:0x%" PRIx64 " vgId:%d tmq task executed error, line:%d code:%d", pHandle->consumerId, vgId, line,
|
||||||
|
code);
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -241,31 +246,40 @@ int32_t tqScanTaosx(STQ* pTq, const STqHandle* pHandle, STaosxRsp* pRsp, SMqBatc
|
||||||
// get meta
|
// get meta
|
||||||
SMqBatchMetaRsp* tmp = qStreamExtractMetaMsg(task);
|
SMqBatchMetaRsp* tmp = qStreamExtractMetaMsg(task);
|
||||||
if (taosArrayGetSize(tmp->batchMetaReq) > 0) {
|
if (taosArrayGetSize(tmp->batchMetaReq) > 0) {
|
||||||
qStreamExtractOffset(task, &tmp->rspOffset);
|
code = qStreamExtractOffset(task, &tmp->rspOffset);
|
||||||
|
if (code) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
*pBatchMetaRsp = *tmp;
|
*pBatchMetaRsp = *tmp;
|
||||||
tqDebug("tmqsnap task get meta");
|
tqDebug("tmqsnap task get meta");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pDataBlock == NULL) {
|
if (pDataBlock == NULL) {
|
||||||
qStreamExtractOffset(task, pOffset);
|
code = qStreamExtractOffset(task, pOffset);
|
||||||
|
if (code) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (pOffset->type == TMQ_OFFSET__SNAPSHOT_DATA) {
|
if (pOffset->type == TMQ_OFFSET__SNAPSHOT_DATA) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
tqDebug("tmqsnap vgId: %d, tsdb consume over, switch to wal, ver %" PRId64, TD_VID(pTq->pVnode),
|
tqDebug("tmqsnap vgId: %d, tsdb consume over, switch to wal, ver %" PRId64, TD_VID(pTq->pVnode),
|
||||||
pHandle->snapshotVer + 1);
|
pHandle->snapshotVer + 1);
|
||||||
qStreamExtractOffset(task, &pRsp->common.rspOffset);
|
code = qStreamExtractOffset(task, &pRsp->common.rspOffset);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pRsp->common.blockNum > 0) {
|
if (pRsp->common.blockNum > 0) {
|
||||||
tqDebug("tmqsnap task exec exited, get data");
|
tqDebug("tmqsnap task exec exited, get data");
|
||||||
qStreamExtractOffset(task, &pRsp->common.rspOffset);
|
code = qStreamExtractOffset(task, &pRsp->common.rspOffset);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ typedef struct {
|
||||||
static int32_t getCurrentBlockInfo(SDataBlockIter* pBlockIter, SFileDataBlockInfo** pInfo);
|
static int32_t getCurrentBlockInfo(SDataBlockIter* pBlockIter, SFileDataBlockInfo** pInfo);
|
||||||
static int32_t buildDataBlockFromBufImpl(STableBlockScanInfo* pBlockScanInfo, int64_t endKey, int32_t capacity,
|
static int32_t buildDataBlockFromBufImpl(STableBlockScanInfo* pBlockScanInfo, int64_t endKey, int32_t capacity,
|
||||||
STsdbReader* pReader);
|
STsdbReader* pReader);
|
||||||
static int32_t getValidMemRow(SIterInfo* pIter, const SArray* pDelList, STsdbReader* pReader, TSDBROW** pRes);
|
static void getValidMemRow(SIterInfo* pIter, const SArray* pDelList, STsdbReader* pReader, TSDBROW** pRes);
|
||||||
static int32_t doMergeRowsInFileBlocks(SBlockData* pBlockData, STableBlockScanInfo* pScanInfo, SRowKey* pKey,
|
static int32_t doMergeRowsInFileBlocks(SBlockData* pBlockData, STableBlockScanInfo* pScanInfo, SRowKey* pKey,
|
||||||
STsdbReader* pReader);
|
STsdbReader* pReader);
|
||||||
static int32_t doMergeRowsInSttBlock(SSttBlockReader* pSttBlockReader, STableBlockScanInfo* pScanInfo,
|
static int32_t doMergeRowsInSttBlock(SSttBlockReader* pSttBlockReader, STableBlockScanInfo* pScanInfo,
|
||||||
|
@ -3866,11 +3866,11 @@ bool hasBeenDropped(const SArray* pDelList, int32_t* index, int64_t key, int64_t
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
FORCE_INLINE int32_t getValidMemRow(SIterInfo* pIter, const SArray* pDelList, STsdbReader* pReader, TSDBROW** pRes) {
|
FORCE_INLINE void getValidMemRow(SIterInfo* pIter, const SArray* pDelList, STsdbReader* pReader, TSDBROW** pRes) {
|
||||||
*pRes = NULL;
|
*pRes = NULL;
|
||||||
|
|
||||||
if (!pIter->hasVal) {
|
if (!pIter->hasVal) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t order = pReader->info.order;
|
int32_t order = pReader->info.order;
|
||||||
|
@ -3880,20 +3880,20 @@ FORCE_INLINE int32_t getValidMemRow(SIterInfo* pIter, const SArray* pDelList, ST
|
||||||
TSDBROW_INIT_KEY(pRow, key);
|
TSDBROW_INIT_KEY(pRow, key);
|
||||||
if (outOfTimeWindow(key.ts, &pReader->info.window)) {
|
if (outOfTimeWindow(key.ts, &pReader->info.window)) {
|
||||||
pIter->hasVal = false;
|
pIter->hasVal = false;
|
||||||
return TSDB_CODE_SUCCESS;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// it is a valid data version
|
// it is a valid data version
|
||||||
if (key.version <= pReader->info.verRange.maxVer && key.version >= pReader->info.verRange.minVer) {
|
if (key.version <= pReader->info.verRange.maxVer && key.version >= pReader->info.verRange.minVer) {
|
||||||
if (pDelList == NULL || TARRAY_SIZE(pDelList) == 0) {
|
if (pDelList == NULL || TARRAY_SIZE(pDelList) == 0) {
|
||||||
*pRes = pRow;
|
*pRes = pRow;
|
||||||
return TSDB_CODE_SUCCESS;
|
return;
|
||||||
} else {
|
} else {
|
||||||
bool dropped = hasBeenDropped(pDelList, &pIter->index, key.ts, key.version, order, &pReader->info.verRange,
|
bool dropped = hasBeenDropped(pDelList, &pIter->index, key.ts, key.version, order, &pReader->info.verRange,
|
||||||
pReader->suppInfo.numOfPks > 0);
|
pReader->suppInfo.numOfPks > 0);
|
||||||
if (!dropped) {
|
if (!dropped) {
|
||||||
*pRes = pRow;
|
*pRes = pRow;
|
||||||
return TSDB_CODE_SUCCESS;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3901,7 +3901,7 @@ FORCE_INLINE int32_t getValidMemRow(SIterInfo* pIter, const SArray* pDelList, ST
|
||||||
while (1) {
|
while (1) {
|
||||||
pIter->hasVal = tsdbTbDataIterNext(pIter->iter);
|
pIter->hasVal = tsdbTbDataIterNext(pIter->iter);
|
||||||
if (!pIter->hasVal) {
|
if (!pIter->hasVal) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pRow = tsdbTbDataIterGet(pIter->iter);
|
pRow = tsdbTbDataIterGet(pIter->iter);
|
||||||
|
@ -3909,19 +3909,19 @@ FORCE_INLINE int32_t getValidMemRow(SIterInfo* pIter, const SArray* pDelList, ST
|
||||||
TSDBROW_INIT_KEY(pRow, key);
|
TSDBROW_INIT_KEY(pRow, key);
|
||||||
if (outOfTimeWindow(key.ts, &pReader->info.window)) {
|
if (outOfTimeWindow(key.ts, &pReader->info.window)) {
|
||||||
pIter->hasVal = false;
|
pIter->hasVal = false;
|
||||||
return TSDB_CODE_SUCCESS;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key.version <= pReader->info.verRange.maxVer && key.version >= pReader->info.verRange.minVer) {
|
if (key.version <= pReader->info.verRange.maxVer && key.version >= pReader->info.verRange.minVer) {
|
||||||
if (pDelList == NULL || TARRAY_SIZE(pDelList) == 0) {
|
if (pDelList == NULL || TARRAY_SIZE(pDelList) == 0) {
|
||||||
*pRes = pRow;
|
*pRes = pRow;
|
||||||
return TSDB_CODE_SUCCESS;
|
return;
|
||||||
} else {
|
} else {
|
||||||
bool dropped = hasBeenDropped(pDelList, &pIter->index, key.ts, key.version, order, &pReader->info.verRange,
|
bool dropped = hasBeenDropped(pDelList, &pIter->index, key.ts, key.version, order, &pReader->info.verRange,
|
||||||
pReader->suppInfo.numOfPks > 0);
|
pReader->suppInfo.numOfPks > 0);
|
||||||
if (!dropped) {
|
if (!dropped) {
|
||||||
*pRes = pRow;
|
*pRes = pRow;
|
||||||
return TSDB_CODE_SUCCESS;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1002,7 +1002,7 @@ int32_t doDeleteTimeWindows(SStreamAggSupporter* pAggSup, SSDataBlock* pBlock, S
|
||||||
|
|
||||||
int32_t getNextQualifiedWindow(SInterval* pInterval, STimeWindow* pNext, SDataBlockInfo* pDataBlockInfo,
|
int32_t getNextQualifiedWindow(SInterval* pInterval, STimeWindow* pNext, SDataBlockInfo* pDataBlockInfo,
|
||||||
TSKEY* primaryKeys, int32_t prevPosition, int32_t order);
|
TSKEY* primaryKeys, int32_t prevPosition, int32_t order);
|
||||||
void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const SColumnInfoData* p, int32_t status);
|
int32_t extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const SColumnInfoData* p, int32_t status);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -295,7 +295,7 @@ qTaskInfo_t qCreateQueueExecTaskInfo(void* msg, SReadHandle* pReaderHandle, int3
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
createRawScanOperatorInfo(pReaderHandle, pTaskInfo, &pTaskInfo->pRoot);
|
code = createRawScanOperatorInfo(pReaderHandle, pTaskInfo, &pTaskInfo->pRoot);
|
||||||
if (NULL == pTaskInfo->pRoot || code != 0) {
|
if (NULL == pTaskInfo->pRoot || code != 0) {
|
||||||
taosMemoryFree(pTaskInfo);
|
taosMemoryFree(pTaskInfo);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1158,9 +1158,9 @@ SMqBatchMetaRsp* qStreamExtractMetaMsg(qTaskInfo_t tinfo) {
|
||||||
return &pTaskInfo->streamInfo.btMetaRsp;
|
return &pTaskInfo->streamInfo.btMetaRsp;
|
||||||
}
|
}
|
||||||
|
|
||||||
void qStreamExtractOffset(qTaskInfo_t tinfo, STqOffsetVal* pOffset) {
|
int32_t qStreamExtractOffset(qTaskInfo_t tinfo, STqOffsetVal* pOffset) {
|
||||||
SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo;
|
SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo;
|
||||||
tOffsetCopy(pOffset, &pTaskInfo->streamInfo.currentOffset);
|
return tOffsetCopy(pOffset, &pTaskInfo->streamInfo.currentOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t initQueryTableDataCondForTmq(SQueryTableDataCond* pCond, SSnapContext* sContext, SMetaTableInfo* pMtInfo) {
|
int32_t initQueryTableDataCondForTmq(SQueryTableDataCond* pCond, SSnapContext* sContext, SMetaTableInfo* pMtInfo) {
|
||||||
|
@ -1231,7 +1231,7 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT
|
||||||
}
|
}
|
||||||
|
|
||||||
if (subType == TOPIC_SUB_TYPE__COLUMN) {
|
if (subType == TOPIC_SUB_TYPE__COLUMN) {
|
||||||
extractOperatorInTree(pOperator, QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN, id, &pOperator);
|
code = extractOperatorInTree(pOperator, QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN, id, &pOperator);
|
||||||
if (pOperator == NULL || code != 0) {
|
if (pOperator == NULL || code != 0) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -1431,8 +1431,7 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT
|
||||||
}
|
}
|
||||||
|
|
||||||
end:
|
end:
|
||||||
tOffsetCopy(&pTaskInfo->streamInfo.currentOffset, pOffset);
|
(void) tOffsetCopy(&pTaskInfo->streamInfo.currentOffset, pOffset);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -567,7 +567,8 @@ int32_t doFilter(SSDataBlock* pBlock, SFilterInfo* pFilterInfo, SColMatchInfo* p
|
||||||
code = filterExecute(pFilterInfo, pBlock, &p, NULL, param1.numOfCols, &status);
|
code = filterExecute(pFilterInfo, pBlock, &p, NULL, param1.numOfCols, &status);
|
||||||
QUERY_CHECK_CODE(code, lino, _err);
|
QUERY_CHECK_CODE(code, lino, _err);
|
||||||
|
|
||||||
extractQualifiedTupleByFilterResult(pBlock, p, status);
|
code = extractQualifiedTupleByFilterResult(pBlock, p, status);
|
||||||
|
QUERY_CHECK_CODE(code, lino, _err);
|
||||||
|
|
||||||
if (pColMatchInfo != NULL) {
|
if (pColMatchInfo != NULL) {
|
||||||
size_t size = taosArrayGetSize(pColMatchInfo->pList);
|
size_t size = taosArrayGetSize(pColMatchInfo->pList);
|
||||||
|
@ -591,18 +592,21 @@ _err:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const SColumnInfoData* p, int32_t status) {
|
int32_t extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const SColumnInfoData* p, int32_t status) {
|
||||||
|
int32_t code = 0;
|
||||||
int8_t* pIndicator = (int8_t*)p->pData;
|
int8_t* pIndicator = (int8_t*)p->pData;
|
||||||
if (status == FILTER_RESULT_ALL_QUALIFIED) {
|
if (status == FILTER_RESULT_ALL_QUALIFIED) {
|
||||||
// here nothing needs to be done
|
// here nothing needs to be done
|
||||||
} else if (status == FILTER_RESULT_NONE_QUALIFIED) {
|
} else if (status == FILTER_RESULT_NONE_QUALIFIED) {
|
||||||
trimDataBlock(pBlock, pBlock->info.rows, NULL);
|
code = trimDataBlock(pBlock, pBlock->info.rows, NULL);
|
||||||
pBlock->info.rows = 0;
|
pBlock->info.rows = 0;
|
||||||
} else if (status == FILTER_RESULT_PARTIAL_QUALIFIED) {
|
} else if (status == FILTER_RESULT_PARTIAL_QUALIFIED) {
|
||||||
trimDataBlock(pBlock, pBlock->info.rows, (bool*)pIndicator);
|
code = trimDataBlock(pBlock, pBlock->info.rows, (bool*)pIndicator);
|
||||||
} else {
|
} else {
|
||||||
qError("unknown filter result type: %d", status);
|
qError("unknown filter result type: %d", status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
void doUpdateNumOfRows(SqlFunctionCtx* pCtx, SResultRow* pRow, int32_t numOfExprs, const int32_t* rowEntryOffset) {
|
void doUpdateNumOfRows(SqlFunctionCtx* pCtx, SResultRow* pRow, int32_t numOfExprs, const int32_t* rowEntryOffset) {
|
||||||
|
|
|
@ -308,12 +308,9 @@ int32_t mJoinFilterAndMarkHashRows(SSDataBlock* pBlock, SFilterInfo* pFilterInfo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extractQualifiedTupleByFilterResult(pBlock, p, status);
|
code = extractQualifiedTupleByFilterResult(pBlock, p, status);
|
||||||
|
|
||||||
code = TSDB_CODE_SUCCESS;
|
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
|
|
||||||
colDataDestroy(p);
|
colDataDestroy(p);
|
||||||
taosMemoryFree(p);
|
taosMemoryFree(p);
|
||||||
|
|
||||||
|
@ -375,12 +372,9 @@ int32_t mJoinFilterAndMarkRows(SSDataBlock* pBlock, SFilterInfo* pFilterInfo, SM
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extractQualifiedTupleByFilterResult(pBlock, p, status);
|
code = extractQualifiedTupleByFilterResult(pBlock, p, status);
|
||||||
|
|
||||||
code = TSDB_CODE_SUCCESS;
|
|
||||||
|
|
||||||
_return:
|
_return:
|
||||||
|
|
||||||
colDataDestroy(p);
|
colDataDestroy(p);
|
||||||
taosMemoryFree(p);
|
taosMemoryFree(p);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue