From 2fb0c1a00f1136f2981101bb20cabd7772646cd6 Mon Sep 17 00:00:00 2001 From: slzhou Date: Wed, 28 Feb 2024 14:31:31 +0800 Subject: [PATCH] feat: check temp space availability --- source/libs/executor/src/scanoperator.c | 12 ++++++++---- source/libs/executor/src/tsort.c | 5 +++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index 7f1f0700d0..1d64b066e9 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -4015,9 +4015,10 @@ int32_t startDurationForGroupTableMergeScan(SOperatorInfo* pOperator) { pInfo->pSortHandle = tsortCreateSortHandle(pInfo->pSortInfo, SORT_BLOCK_TS_MERGE, pInfo->bufPageSize, numOfBufPage, pInfo->pSortInputBlock, pTaskInfo->id.str, 0, 0, 0); int32_t memSize = 512 * 1024 * 1024; - // int32_t rowBytes = blockDataGetRowSize(pInfo->pResBlock) + taosArrayGetSize(pInfo->pResBlock->pDataBlock) + sizeof(int32_t); - // int32_t pageSize = TMAX(memSize/numOfTable, rowBytes); - tsortSetSortByRowId(pInfo->pSortHandle, pInfo->bufPageSize, memSize); + code = tsortSetSortByRowId(pInfo->pSortHandle, pInfo->bufPageSize, memSize); + if (code != TSDB_CODE_SUCCESS) { + return code; + } } else { pInfo->pSortHandle = tsortCreateSortHandle(pInfo->pSortInfo, SORT_BLOCK_TS_MERGE, pInfo->bufPageSize, numOfBufPage, pInfo->pSortInputBlock, pTaskInfo->id.str, 0, 0, 0); @@ -4210,7 +4211,10 @@ SSDataBlock* doTableMergeScan(SOperatorInfo* pOperator) { } else { if (pInfo->bNewFilesetEvent) { stopDurationForGroupTableMergeScan(pOperator); - startDurationForGroupTableMergeScan(pOperator); + code = startDurationForGroupTableMergeScan(pOperator); + if (code != TSDB_CODE_SUCCESS) { + T_LONG_JMP(pTaskInfo->env, terrno); + } } else { // Data of this group are all dumped, let's try the next group stopGroupTableMergeScan(pOperator); diff --git a/source/libs/executor/src/tsort.c b/source/libs/executor/src/tsort.c index 3b2915f81d..506c79ebaf 100644 --- a/source/libs/executor/src/tsort.c +++ b/source/libs/executor/src/tsort.c @@ -1266,6 +1266,11 @@ int32_t tsortSetSortByRowId(SSortHandle* pHandle, int32_t extRowsPageSize, int32 SBlockOrderInfo* pOrder = taosArrayGet(pHandle->pSortInfo, 0); pHandle->extRowsOrderInfo = *pOrder; initRowIdSort(pHandle); + if (!osTempSpaceAvailable()) { + terrno = TSDB_CODE_NO_DISKSPACE; + qError("create sort mem file failed since %s, tempDir:%s", terrstr(), tsTempDir); + return terrno; + } int32_t code = createSortMemFile(pHandle); pHandle->bSortByRowId = true; return code;