fix: return code issues

This commit is contained in:
dapan1121 2024-12-11 19:18:50 +08:00
parent d7032ac520
commit 2bd493f77b
51 changed files with 350 additions and 196 deletions

View File

@ -63,7 +63,7 @@ typedef struct SFuncExecFuncs {
processFuncByRow processFuncByRow;
} SFuncExecFuncs;
#define MAX_INTERVAL_TIME_WINDOW 1000000000 // maximum allowed time windows in final results
#define MAX_INTERVAL_TIME_WINDOW 10000000 // maximum allowed time windows in final results
#define TOP_BOTTOM_QUERY_LIMIT 100
#define FUNCTIONS_NAME_MAX_LENGTH 32

View File

@ -955,7 +955,7 @@ void taos_init_imp(void) {
taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_ENTRY_LOCK);
if (NULL == appInfo.pInstMap || NULL == appInfo.pInstMapByClusterId) {
(void)printf("failed to allocate memory when init appInfo\n");
tscInitRes = TSDB_CODE_OUT_OF_MEMORY;
tscInitRes = terrno;
return;
}
taosHashSetFreeFp(appInfo.pInstMap, destroyAppInst);

View File

@ -1339,7 +1339,6 @@ static void *hbThreadFunc(void *param) {
}
void *buf = taosMemoryMalloc(tlen);
if (buf == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
tFreeClientHbBatchReq(pReq);
// hbClearReqInfo(pAppHbMgr);
break;
@ -1353,7 +1352,6 @@ static void *hbThreadFunc(void *param) {
SMsgSendInfo *pInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo));
if (pInfo == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
tFreeClientHbBatchReq(pReq);
// hbClearReqInfo(pAppHbMgr);
taosMemoryFree(buf);
@ -1365,7 +1363,6 @@ static void *hbThreadFunc(void *param) {
pInfo->msgType = TDMT_MND_HEARTBEAT;
pInfo->param = taosMemoryMalloc(sizeof(int32_t));
if (pInfo->param == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
tFreeClientHbBatchReq(pReq);
// hbClearReqInfo(pAppHbMgr);
taosMemoryFree(buf);
@ -1459,7 +1456,7 @@ int32_t appHbMgrInit(SAppInstInfo *pAppInstInfo, char *key, SAppHbMgr **pAppHbMg
(*pAppHbMgr)->reportBytes = 0;
(*pAppHbMgr)->key = taosStrdup(key);
if ((*pAppHbMgr)->key == NULL) {
TSC_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
TSC_ERR_JRET(terrno);
}
// init app info

View File

@ -126,7 +126,7 @@ int32_t taos_connect_internal(const char* ip, const char* user, const char* pass
char* key = getClusterKey(user, secretEncrypt, ip, port);
if (NULL == key) {
TSC_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
TSC_ERR_RET(terrno);
}
tscInfo("connecting to server, numOfEps:%d inUse:%d user:%s db:%s key:%s", epSet.epSet.numOfEps, epSet.epSet.inUse,
user, db, key);
@ -1820,11 +1820,10 @@ int32_t doProcessMsgFromServerImpl(SRpcMsg* pMsg, SEpSet* pEpSet) {
.handleRefId = pMsg->info.refId,
.pEpSet = pEpSet};
if (pMsg->code != TSDB_CODE_OUT_OF_MEMORY && pMsg->contLen > 0) {
if (pMsg->contLen > 0) {
buf.pData = taosMemoryCalloc(1, pMsg->contLen);
if (buf.pData == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
pMsg->code = TSDB_CODE_OUT_OF_MEMORY;
pMsg->code = terrno;
} else {
(void)memcpy(buf.pData, pMsg->pCont, pMsg->contLen);
}
@ -2957,7 +2956,6 @@ TAOS_RES* taosQueryImpl(TAOS* taos, const char* sql, bool validateOnly, int8_t s
SSyncQueryParam* param = taosMemoryCalloc(1, sizeof(SSyncQueryParam));
if (NULL == param) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL;
}
int32_t code = tsem_init(&param->sem, 0, 0);
@ -2998,7 +2996,6 @@ TAOS_RES* taosQueryImplWithReqid(TAOS* taos, const char* sql, bool validateOnly,
SSyncQueryParam* param = taosMemoryCalloc(1, sizeof(SSyncQueryParam));
if (param == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL;
}
int32_t code = tsem_init(&param->sem, 0, 0);

View File

@ -292,7 +292,6 @@ TAOS *taos_connect(const char *ip, const char *user, const char *pass, const cha
int64_t *rid = taosMemoryCalloc(1, sizeof(int64_t));
if (NULL == rid) {
tscError("out of memory when taos connect to %s:%u, user:%s db:%s", ip, port, user, db);
terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL;
}
*rid = pObj->id;
@ -424,7 +423,7 @@ void taos_fetch_whitelist_a(TAOS *taos, __taos_async_whitelist_fn_t fp, void *pa
void *pReq = taosMemoryMalloc(msgLen);
if (pReq == NULL) {
fp(param, TSDB_CODE_OUT_OF_MEMORY, taos, 0, NULL);
fp(param, terrno, taos, 0, NULL);
releaseTscObj(connId);
return;
}
@ -438,7 +437,7 @@ void taos_fetch_whitelist_a(TAOS *taos, __taos_async_whitelist_fn_t fp, void *pa
SFetchWhiteListInfo *pParam = taosMemoryMalloc(sizeof(SFetchWhiteListInfo));
if (pParam == NULL) {
fp(param, TSDB_CODE_OUT_OF_MEMORY, taos, 0, NULL);
fp(param, terrno, taos, 0, NULL);
taosMemoryFree(pReq);
releaseTscObj(connId);
return;
@ -449,7 +448,7 @@ void taos_fetch_whitelist_a(TAOS *taos, __taos_async_whitelist_fn_t fp, void *pa
pParam->userParam = param;
SMsgSendInfo *pSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo));
if (pSendInfo == NULL) {
fp(param, TSDB_CODE_OUT_OF_MEMORY, taos, 0, NULL);
fp(param, terrno, taos, 0, NULL);
taosMemoryFree(pParam);
taosMemoryFree(pReq);
releaseTscObj(connId);

View File

@ -1563,7 +1563,7 @@ static int32_t taosAlterTable(TAOS* taos, void* meta, int32_t metaLen) {
req.source = TD_REQ_FROM_TAOX;
tEncodeSize(tEncodeSVAlterTbReq, &req, tlen, code);
if (code != 0) {
code = TSDB_CODE_OUT_OF_MEMORY;
code = terrno;
goto end;
}
tlen += sizeof(SMsgHead);
@ -1577,7 +1577,7 @@ static int32_t taosAlterTable(TAOS* taos, void* meta, int32_t metaLen) {
code = tEncodeSVAlterTbReq(&coder, &req);
if (code != 0) {
tEncoderClear(&coder);
code = TSDB_CODE_OUT_OF_MEMORY;
code = terrno;
goto end;
}
tEncoderClear(&coder);

View File

@ -134,7 +134,7 @@ int32_t smlParseValue(SSmlKv *pVal, SSmlMsgBuf *msg) {
void* data = NULL;
uint32_t size = 0;
if(taosHex2Ascii(pVal->value + NCHAR_ADD_LEN - 1, pVal->length - NCHAR_ADD_LEN, &data, &size) < 0){
return TSDB_CODE_OUT_OF_MEMORY;
return terrno;
}
if (size + VARSTR_HEADER_SIZE > TSDB_MAX_VARBINARY_LEN) {

View File

@ -300,7 +300,7 @@ int32_t stmtCacheBlock(STscStmt* pStmt) {
STableDataCxt** pSrc = taosHashGet(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName));
if (!pSrc) {
return TSDB_CODE_OUT_OF_MEMORY;
return terrno;
}
STableDataCxt* pDst = NULL;
@ -355,7 +355,7 @@ int32_t stmtParseSql(STscStmt* pStmt) {
STableDataCxt** pSrc =
(STableDataCxt**)taosHashGet(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName));
if (NULL == pSrc || NULL == *pSrc) {
return TSDB_CODE_OUT_OF_MEMORY;
return terrno;
}
STableDataCxt* pTableCtx = *pSrc;
@ -845,13 +845,11 @@ TAOS_STMT* stmtInit(STscObj* taos, int64_t reqid, TAOS_STMT_OPTIONS* pOptions) {
pStmt = taosMemoryCalloc(1, sizeof(STscStmt));
if (NULL == pStmt) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL;
}
pStmt->sql.pTableCache = taosHashInit(100, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
if (NULL == pStmt->sql.pTableCache) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
taosMemoryFree(pStmt);
return NULL;
}
@ -876,13 +874,11 @@ TAOS_STMT* stmtInit(STscObj* taos, int64_t reqid, TAOS_STMT_OPTIONS* pOptions) {
pStmt->sql.siInfo.mgmtEpSet = getEpSet_s(&pStmt->taos->pAppInfo->mgmtEp);
pStmt->sql.siInfo.pTableHash = tSimpleHashInit(100, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY));
if (NULL == pStmt->sql.siInfo.pTableHash) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
(void)stmtClose(pStmt);
return NULL;
}
pStmt->sql.siInfo.pTableCols = taosArrayInit(STMT_TABLE_COLS_NUM, POINTER_BYTES);
if (NULL == pStmt->sql.siInfo.pTableCols) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
(void)stmtClose(pStmt);
return NULL;
}
@ -948,7 +944,7 @@ int stmtPrepare(TAOS_STMT* stmt, const char* sql, unsigned long length) {
int32_t stmtInitStbInterlaceTableInfo(STscStmt* pStmt) {
STableDataCxt** pSrc = taosHashGet(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName));
if (!pSrc) {
return TSDB_CODE_OUT_OF_MEMORY;
return terrno;
}
STableDataCxt* pDst = NULL;

View File

@ -275,7 +275,7 @@ static int32_t stmtParseSql(STscStmt2* pStmt) {
STableDataCxt** pSrc =
(STableDataCxt**)taosHashGet(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName));
if (NULL == pSrc || NULL == *pSrc) {
return TSDB_CODE_OUT_OF_MEMORY;
return terrno;
}
STableDataCxt* pTableCtx = *pSrc;
@ -295,7 +295,7 @@ static int32_t stmtParseSql(STscStmt2* pStmt) {
if (NULL == pStmt->sql.pBindInfo) {
pStmt->sql.pBindInfo = taosMemoryMalloc(pTableCtx->boundColsInfo.numOfBound * sizeof(*pStmt->sql.pBindInfo));
if (NULL == pStmt->sql.pBindInfo) {
return TSDB_CODE_OUT_OF_MEMORY;
return terrno;
}
}
@ -540,7 +540,7 @@ static int32_t stmtGetFromCache(STscStmt2* pStmt) {
if (taosHashPut(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName), &pNewBlock,
POINTER_BYTES)) {
STMT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
STMT_ERR_RET(terrno);
}
pStmt->exec.pCurrBlock = pNewBlock;
@ -630,7 +630,7 @@ static int32_t stmtGetFromCache(STscStmt2* pStmt) {
if (taosHashPut(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName), &pNewBlock,
POINTER_BYTES)) {
STMT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
STMT_ERR_RET(terrno);
}
pStmt->exec.pCurrBlock = pNewBlock;
@ -766,13 +766,11 @@ TAOS_STMT2* stmtInit2(STscObj* taos, TAOS_STMT2_OPTION* pOptions) {
pStmt = taosMemoryCalloc(1, sizeof(STscStmt2));
if (NULL == pStmt) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL;
}
pStmt->sql.pTableCache = taosHashInit(100, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
if (NULL == pStmt->sql.pTableCache) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
taosMemoryFree(pStmt);
return NULL;
}
@ -798,7 +796,6 @@ TAOS_STMT2* stmtInit2(STscObj* taos, TAOS_STMT2_OPTION* pOptions) {
pStmt->sql.siInfo.mgmtEpSet = getEpSet_s(&pStmt->taos->pAppInfo->mgmtEp);
pStmt->sql.siInfo.pTableHash = tSimpleHashInit(100, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY));
if (NULL == pStmt->sql.siInfo.pTableHash) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
(void)stmtClose(pStmt);
return NULL;
}
@ -894,7 +891,7 @@ int stmtPrepare2(TAOS_STMT2* stmt, const char* sql, unsigned long length) {
static int32_t stmtInitStbInterlaceTableInfo(STscStmt2* pStmt) {
STableDataCxt** pSrc = taosHashGet(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName));
if (!pSrc) {
return TSDB_CODE_OUT_OF_MEMORY;
return terrno;
}
STableDataCxt* pDst = NULL;
@ -1199,7 +1196,7 @@ static int32_t stmtCacheBlock(STscStmt2* pStmt) {
STableDataCxt** pSrc = taosHashGet(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName));
if (!pSrc) {
return TSDB_CODE_OUT_OF_MEMORY;
return terrno;
}
STableDataCxt* pDst = NULL;
@ -1266,7 +1263,7 @@ static int32_t stmtBackupQueryFields(STscStmt2* pStmt) {
pRes->fields = taosMemoryMalloc(size);
pRes->userFields = taosMemoryMalloc(size);
if (NULL == pRes->fields || NULL == pRes->userFields) {
STMT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
STMT_ERR_RET(terrno);
}
(void)memcpy(pRes->fields, pStmt->exec.pRequest->body.resInfo.fields, size);
(void)memcpy(pRes->userFields, pStmt->exec.pRequest->body.resInfo.userFields, size);
@ -1284,7 +1281,7 @@ static int32_t stmtRestoreQueryFields(STscStmt2* pStmt) {
if (NULL == pStmt->exec.pRequest->body.resInfo.fields) {
pStmt->exec.pRequest->body.resInfo.fields = taosMemoryMalloc(size);
if (NULL == pStmt->exec.pRequest->body.resInfo.fields) {
STMT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
STMT_ERR_RET(terrno);
}
(void)memcpy(pStmt->exec.pRequest->body.resInfo.fields, pRes->fields, size);
}
@ -1292,7 +1289,7 @@ static int32_t stmtRestoreQueryFields(STscStmt2* pStmt) {
if (NULL == pStmt->exec.pRequest->body.resInfo.userFields) {
pStmt->exec.pRequest->body.resInfo.userFields = taosMemoryMalloc(size);
if (NULL == pStmt->exec.pRequest->body.resInfo.userFields) {
STMT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
STMT_ERR_RET(terrno);
}
(void)memcpy(pStmt->exec.pRequest->body.resInfo.userFields, pRes->userFields, size);
}

View File

@ -45,7 +45,7 @@
tDecoderInit(&decoder, POINTER_SHIFT(pMsg->pData, sizeof(SMqRspHead)), pMsg->len - sizeof(SMqRspHead)); \
if (FUNC(&decoder, DATA) < 0) { \
tDecoderClear(&decoder); \
code = TSDB_CODE_OUT_OF_MEMORY; \
code = terrno; \
goto END;\
}\
tDecoderClear(&decoder);\
@ -1552,7 +1552,7 @@ static void tmqMgmtInit(void) {
tmqMgmt.timer = taosTmrInit(1000, 100, 360000, "TMQ");
if (tmqMgmt.timer == NULL) {
tmqInitRes = TSDB_CODE_OUT_OF_MEMORY;
tmqInitRes = terrno;
}
tmqMgmt.rsetId = taosOpenRef(10000, tmqFreeImpl);
@ -2520,7 +2520,7 @@ int32_t tmq_unsubscribe(tmq_t* tmq) {
tmq_list_t* lst = tmq_list_new();
if (lst == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY;
code = terrno;
goto END;
}
code = tmq_subscribe(tmq, lst);
@ -2701,10 +2701,12 @@ int32_t tmq_commit_sync(tmq_t* tmq, const TAOS_RES* pRes) {
tqErrorC("failed to allocate memory for sync commit");
return terrno;
}
if (tsem2_init(&pInfo->sem, 0, 0) != 0) {
code = tsem2_init(&pInfo->sem, 0, 0);
if (code != 0) {
tqErrorC("failed to init sem for sync commit");
taosMemoryFree(pInfo);
return TSDB_CODE_OUT_OF_MEMORY;
return code;
}
pInfo->code = 0;
@ -2778,9 +2780,10 @@ int32_t tmq_commit_offset_sync(tmq_t* tmq, const char* pTopicName, int32_t vgId,
return terrno;
}
if (tsem2_init(&pInfo->sem, 0, 0) != 0) {
code = tsem2_init(&pInfo->sem, 0, 0);
if (code != 0) {
taosMemoryFree(pInfo);
return TSDB_CODE_OUT_OF_MEMORY;
return code;
}
pInfo->code = 0;
@ -2967,9 +2970,10 @@ static int32_t tmCommittedCb(void* param, SDataBuf* pMsg, int32_t code) {
if (pMsg) {
SDecoder decoder = {0};
tDecoderInit(&decoder, (uint8_t*)pMsg->pData, pMsg->len);
if (tDecodeMqVgOffset(&decoder, &pParam->vgOffset) < 0) {
int32_t err = tDecodeMqVgOffset(&decoder, &pParam->vgOffset);
if (err < 0) {
tOffsetDestroy(&pParam->vgOffset.offset);
code = TSDB_CODE_OUT_OF_MEMORY;
code = err;
goto end;
}
tDecoderClear(&decoder);
@ -3262,8 +3266,9 @@ int32_t tmq_get_topic_assignment(tmq_t* tmq, const char* pTopicName, tmq_topic_a
code = terrno;
goto end;
}
if (tsem2_init(&pCommon->rsp, 0, 0) != 0) {
code = TSDB_CODE_OUT_OF_MEMORY;
code = tsem2_init(&pCommon->rsp, 0, 0);
if (code != 0) {
goto end;
}
(void)taosThreadMutexInit(&pCommon->mutex, 0);
@ -3297,7 +3302,7 @@ int32_t tmq_get_topic_assignment(tmq_t* tmq, const char* pTopicName, tmq_topic_a
int32_t msgSize = tSerializeSMqPollReq(NULL, 0, &req);
if (msgSize < 0) {
taosMemoryFree(pParam);
code = TSDB_CODE_OUT_OF_MEMORY;
code = msgSize;
goto end;
}
@ -3308,10 +3313,11 @@ int32_t tmq_get_topic_assignment(tmq_t* tmq, const char* pTopicName, tmq_topic_a
goto end;
}
if (tSerializeSMqPollReq(msg, msgSize, &req) < 0) {
msgSize = tSerializeSMqPollReq(msg, msgSize, &req);
if (msgSize < 0) {
taosMemoryFree(msg);
taosMemoryFree(pParam);
code = TSDB_CODE_OUT_OF_MEMORY;
code = msgSize;
goto end;
}

View File

@ -106,6 +106,8 @@ static int32_t vnodeGetBufPoolToUse(SVnode *pVnode) {
if (code && code != TSDB_CODE_TIMEOUT_ERROR) {
TSDB_CHECK_CODE(code, lino, _exit);
}
code = 0;
}
}
}

View File

@ -519,7 +519,7 @@ int32_t ctgGetTbDistVgInfo(SCatalog* pCtg, SRequestConnInfo* pConn, SName* pTabl
vgList = taosArrayInit(1, sizeof(SVgroupInfo));
if (NULL == vgList) {
ctgError("taosArrayInit %d failed", (int32_t)sizeof(SVgroupInfo));
CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
CTG_ERR_JRET(terrno);
}
if (NULL == taosArrayPush(vgList, &vgroupInfo)) {
@ -877,13 +877,13 @@ int32_t catalogInit(SCatalogCfg* cfg) {
gCtgMgmt.timer = taosTmrInit(0, 0, 0, "catalog");
if (NULL == gCtgMgmt.timer) {
qError("init timer failed, error:%s", tstrerror(terrno));
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
CTG_ERR_RET(terrno);
}
gCtgMgmt.cacheTimer = taosTmrStart(ctgProcessTimerEvent, CTG_DEFAULT_CACHE_MON_MSEC, NULL, gCtgMgmt.timer);
if (NULL == gCtgMgmt.cacheTimer) {
qError("start cache timer failed");
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
CTG_ERR_RET(terrno);
}
CTG_ERR_RET(ctgStartUpdateThread());

View File

@ -1173,12 +1173,16 @@ int32_t ctgDumpTbIndexRes(SCtgTask* pTask) {
SCtgJob* pJob = pTask->pJob;
if (NULL == pJob->jobRes.pTableIndex) {
SArray* pRes = taosArrayInit(pJob->tbIndexNum, sizeof(SMetaRes));
if (NULL == pRes) {
CTG_ERR_RET(terrno);
}
if (atomic_val_compare_exchange_ptr(&pJob->jobRes.pTableIndex, NULL, pRes)) {
taosArrayDestroy(pRes);
}
if (NULL == pJob->jobRes.pTableIndex) {
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
CTG_ERR_RET(TSDB_CODE_CTG_INTERNAL_ERROR);
}
}
@ -1198,12 +1202,16 @@ int32_t ctgDumpTbCfgRes(SCtgTask* pTask) {
SCtgJob* pJob = pTask->pJob;
if (NULL == pJob->jobRes.pTableCfg) {
SArray* pRes = taosArrayInit(pJob->tbCfgNum, sizeof(SMetaRes));
if (NULL == pRes) {
CTG_ERR_RET(terrno);
}
if (atomic_val_compare_exchange_ptr(&pJob->jobRes.pTableCfg, NULL, pRes)) {
taosArrayDestroy(pRes);
}
if (NULL == pJob->jobRes.pTableCfg) {
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
CTG_ERR_RET(TSDB_CODE_CTG_INTERNAL_ERROR);
}
}
@ -1223,12 +1231,16 @@ int32_t ctgDumpTbTagRes(SCtgTask* pTask) {
SCtgJob* pJob = pTask->pJob;
if (NULL == pJob->jobRes.pTableTag) {
SArray* pRes = taosArrayInit(pJob->tbTagNum, sizeof(SMetaRes));
if (NULL == pRes) {
CTG_ERR_RET(terrno);
}
if (atomic_val_compare_exchange_ptr(&pJob->jobRes.pTableTag, NULL, pRes)) {
taosArrayDestroy(pRes);
}
if (NULL == pJob->jobRes.pTableTag) {
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
CTG_ERR_RET(TSDB_CODE_CTG_INTERNAL_ERROR);
}
}

View File

@ -3729,7 +3729,7 @@ int32_t ctgGetTbNamesFromCache(SCatalog *pCtg, SRequestConnInfo *pConn, SCtgTbNa
for (int32_t i = 0; i < tbNum; ++i) {
CTG_ERR_JRET(ctgAddFetch(&ctx->pFetchs, dbIdx, i, fetchIdx, baseResIdx + i, flag));
if (NULL == taosArrayPush(ctx->pResList, &(SMetaData){0})) {
CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
CTG_ERR_JRET(terrno);
}
}
@ -3863,7 +3863,7 @@ int32_t ctgGetViewsFromCache(SCatalog *pCtg, SRequestConnInfo *pConn, SCtgViewsC
taosMemoryFree(pViewMeta->querySql);
taosMemoryFree(pViewMeta->user);
taosMemoryFree(pViewMeta);
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
CTG_ERR_RET(terrno);
}
pViewMeta->pSchema = taosMemoryMalloc(pViewMeta->numOfCols * sizeof(SSchema));
if (pViewMeta->pSchema == NULL) {

View File

@ -34,9 +34,10 @@ int32_t ctgHandleBatchRsp(SCtgJob* pJob, SCtgTaskCallbackParam* cbParam, SDataBu
SBatchRspMsg* pRsp = NULL;
if (TSDB_CODE_SUCCESS == rspCode && pMsg->pData && (pMsg->len > 0)) {
if (tDeserializeSBatchRsp(pMsg->pData, pMsg->len, &batchRsp) < 0) {
code = tDeserializeSBatchRsp(pMsg->pData, pMsg->len, &batchRsp);
if (code < 0) {
ctgError("tDeserializeSBatchRsp failed, msgLen:%d", pMsg->len);
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
CTG_ERR_RET(code);
}
msgNum = taosArrayGetSize(batchRsp.pRsps);
@ -673,7 +674,7 @@ int32_t ctgAddBatch(SCatalog* pCtg, int32_t vgId, SRequestConnInfo* pConn, SCtgT
newBatch.batchId = atomic_add_fetch_32(&pJob->batchId, 1);
if (0 != taosHashPut(pBatchs, &vgId, sizeof(vgId), &newBatch, sizeof(newBatch))) {
CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
CTG_ERR_JRET(terrno);
}
ctgDebug("task %d %s req added to batch %d, target vgId %d", pTask->taskId, TMSG_INFO(msgType), newBatch.batchId,
@ -778,7 +779,7 @@ int32_t ctgBuildBatchReqMsg(SCtgBatch* pBatch, int32_t vgId, void** msg, int32_t
int32_t msgSize = tSerializeSBatchReq(NULL, 0, &batchReq);
if (msgSize < 0) {
qError("tSerializeSBatchReq failed");
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
CTG_ERR_RET(msgSize);
}
*msg = taosMemoryCalloc(1, msgSize);
@ -786,9 +787,10 @@ int32_t ctgBuildBatchReqMsg(SCtgBatch* pBatch, int32_t vgId, void** msg, int32_t
qError("calloc batchReq msg failed, size:%d", msgSize);
CTG_ERR_RET(terrno);
}
if (tSerializeSBatchReq(*msg, msgSize, &batchReq) < 0) {
msgSize = tSerializeSBatchReq(*msg, msgSize, &batchReq);
if (msgSize < 0) {
qError("tSerializeSBatchReq failed");
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
CTG_ERR_RET(msgSize);
}
*pSize = msgSize;

View File

@ -1620,7 +1620,7 @@ int32_t ctgCloneVgInfo(SDBVgInfo* src, SDBVgInfo** dst) {
taosHashCancelIterate(src->vgHash, pIter);
taosHashCleanup((*dst)->vgHash);
taosMemoryFreeClear(*dst);
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
CTG_ERR_RET(terrno);
}
pIter = taosHashIterate(src->vgHash, pIter);
@ -1787,7 +1787,7 @@ static int32_t ctgCloneDbVgroup(void* pSrc, void** ppDst) {
}
*ppDst = taosArrayDup((const SArray*)pSrc, NULL);
return (*ppDst) ? TSDB_CODE_SUCCESS : TSDB_CODE_OUT_OF_MEMORY;
return (*ppDst) ? TSDB_CODE_SUCCESS : terrno;
#else
return TSDB_CODE_CTG_INTERNAL_ERROR;
#endif
@ -1824,7 +1824,7 @@ static int32_t ctgCloneDbInfo(void* pSrc, void** ppDst) {
#if 0
SDbInfo* pDst = taosMemoryMalloc(sizeof(SDbInfo));
if (NULL == pDst) {
return TSDB_CODE_OUT_OF_MEMORY;
return terrno;
}
TAOS_MEMCPY(pDst, pSrc, sizeof(SDbInfo));
@ -2263,13 +2263,13 @@ static int32_t ctgCloneMetaDataArray(SArray* pSrc, __array_item_dup_fn_t copyFun
int32_t size = taosArrayGetSize(pSrc);
*pDst = taosArrayInit(size, sizeof(SMetaRes));
if (NULL == *pDst) {
return TSDB_CODE_OUT_OF_MEMORY;
return terrno;
}
for (int32_t i = 0; i < size; ++i) {
SMetaRes* pRes = taosArrayGet(pSrc, i);
SMetaRes res = {.code = pRes->code, .pRes = copyFunc(pRes->pRes)};
if (NULL == res.pRes) {
return TSDB_CODE_OUT_OF_MEMORY;
return terrno;
}
taosArrayPush(*pDst, &res);
}
@ -2630,11 +2630,11 @@ int32_t ctgBuildViewNullRes(SCtgTask* pTask, SCtgViewsCtx* pCtx) {
int32_t dupViewMetaFromRsp(SViewMetaRsp* pRsp, SViewMeta* pViewMeta) {
pViewMeta->querySql = tstrdup(pRsp->querySql);
if (NULL == pViewMeta->querySql) {
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
CTG_ERR_RET(terrno);
}
pViewMeta->user = tstrdup(pRsp->user);
if (NULL == pViewMeta->user) {
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
CTG_ERR_RET(terrno);
}
pViewMeta->version = pRsp->version;
pViewMeta->viewId = pRsp->viewId;

View File

@ -2056,7 +2056,7 @@ static int32_t qExplainPrepareCtx(SQueryPlan *pDag, SExplainCtx **pCtx) {
if (0 != taosHashPut(groupHash, &plan->id.groupId, sizeof(plan->id.groupId), &group, sizeof(group))) {
qError("taosHashPut to explainGroupHash failed, taskIdx:%d", n);
QRY_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
QRY_ERR_JRET(terrno);
}
}

View File

@ -131,11 +131,18 @@ int32_t createAnomalywindowOperatorInfo(SOperatorInfo* downstream, SPhysiNode* p
int32_t itemSize = sizeof(int32_t) + pInfo->aggSup.resultRowSize + pInfo->anomalyKey.bytes;
pInfo->anomalySup.pResultRow = taosMemoryCalloc(1, itemSize);
if (pInfo->anomalySup.pResultRow == NULL) {
code = terrno;
goto _error;
}
pInfo->anomalySup.blocks = taosArrayInit(16, sizeof(SSDataBlock*));
if (pInfo->anomalySup.blocks == NULL) {
code = terrno;
goto _error;
}
pInfo->anomalySup.windows = taosArrayInit(16, sizeof(STimeWindow));
if (pInfo->anomalySup.windows == NULL || pInfo->anomalySup.blocks == NULL || pInfo->anomalySup.pResultRow == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY;
if (pInfo->anomalySup.windows == NULL) {
code = terrno;
goto _error;
}
@ -269,8 +276,8 @@ static int32_t anomalyCacheBlock(SAnomalyWindowOperatorInfo* pInfo, SSDataBlock*
int32_t code = createOneDataBlock(pSrc, true, &pDst);
if (code != 0) return code;
if (pDst == NULL) return TSDB_CODE_OUT_OF_MEMORY;
if (taosArrayPush(pInfo->anomalySup.blocks, &pDst) == NULL) return TSDB_CODE_OUT_OF_MEMORY;
if (pDst == NULL) return code;
if (taosArrayPush(pInfo->anomalySup.blocks, &pDst) == NULL) return terrno;
return 0;
}

View File

@ -113,7 +113,7 @@ static int32_t allocBuf(SDataDeleterHandle* pDeleter, const SInputData* pInput,
if (taosQueueItemSize(pDeleter->pDataBlocks) > capacity) {
qError("SinkNode queue is full, no capacity, max:%d, current:%d, no capacity", capacity,
taosQueueItemSize(pDeleter->pDataBlocks));
return TSDB_CODE_OUT_OF_MEMORY;
return TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR;
}
pBuf->allocSize = sizeof(SDataCacheEntry) + sizeof(SDeleterRes);

View File

@ -354,15 +354,15 @@ static int32_t initExchangeOperator(SExchangePhysiNode* pExNode, SExchangeInfo*
pInfo->pSources = taosArrayInit(numOfSources, sizeof(SDownstreamSourceNode));
if (pInfo->pSources == NULL) {
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(TSDB_CODE_OUT_OF_MEMORY));
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(terrno));
return terrno;
}
if (pExNode->node.dynamicOp) {
pInfo->pHashSources = tSimpleHashInit(numOfSources * 2, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT));
if (NULL == pInfo->pHashSources) {
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(TSDB_CODE_OUT_OF_MEMORY));
return TSDB_CODE_OUT_OF_MEMORY;
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(terrno));
return terrno;
}
}
@ -370,7 +370,7 @@ static int32_t initExchangeOperator(SExchangePhysiNode* pExNode, SExchangeInfo*
SDownstreamSourceNode* pNode = (SDownstreamSourceNode*)nodesListGetNode((SNodeList*)pExNode->pSrcEndPoints, i);
if (!pNode) {
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(terrno));
return TSDB_CODE_OUT_OF_MEMORY;
return terrno;
}
void* tmp = taosArrayPush(pInfo->pSources, pNode);
if (!tmp) {
@ -668,7 +668,7 @@ int32_t doSendFetchDataRequest(SExchangeInfo* pExchangeInfo, SExecTaskInfo* pTas
int32_t msgSize = tSerializeSResFetchReq(NULL, 0, &req);
if (msgSize < 0) {
pTaskInfo->code = TSDB_CODE_OUT_OF_MEMORY;
pTaskInfo->code = msgSize;
taosMemoryFree(pWrapper);
freeOperatorParam(req.pOpParam, OP_GET_PARAM);
return pTaskInfo->code;
@ -676,14 +676,15 @@ int32_t doSendFetchDataRequest(SExchangeInfo* pExchangeInfo, SExecTaskInfo* pTas
void* msg = taosMemoryCalloc(1, msgSize);
if (NULL == msg) {
pTaskInfo->code = TSDB_CODE_OUT_OF_MEMORY;
pTaskInfo->code = terrno;
taosMemoryFree(pWrapper);
freeOperatorParam(req.pOpParam, OP_GET_PARAM);
return pTaskInfo->code;
}
if (tSerializeSResFetchReq(msg, msgSize, &req) < 0) {
pTaskInfo->code = TSDB_CODE_OUT_OF_MEMORY;
msgSize = tSerializeSResFetchReq(msg, msgSize, &req);
if (msgSize < 0) {
pTaskInfo->code = msgSize;
taosMemoryFree(pWrapper);
taosMemoryFree(msg);
freeOperatorParam(req.pOpParam, OP_GET_PARAM);
@ -703,7 +704,7 @@ int32_t doSendFetchDataRequest(SExchangeInfo* pExchangeInfo, SExecTaskInfo* pTas
taosMemoryFreeClear(msg);
taosMemoryFree(pWrapper);
qError("%s prepare message %d failed", GET_TASKID(pTaskInfo), (int32_t)sizeof(SMsgSendInfo));
pTaskInfo->code = TSDB_CODE_OUT_OF_MEMORY;
pTaskInfo->code = terrno;
return pTaskInfo->code;
}
@ -899,7 +900,7 @@ int32_t doExtractResultBlocks(SExchangeInfo* pExchangeInfo, SSourceDataInfo* pDa
blockDataCleanup(pb);
} else {
code = createOneDataBlock(pExchangeInfo->pDummyBlock, false, &pb);
QUERY_CHECK_NULL(pb, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
QUERY_CHECK_NULL(pb, code, lino, _end, code);
}
int32_t compLen = *(int32_t*)pStart;
@ -1056,7 +1057,7 @@ int32_t addSingleExchangeSource(SOperatorInfo* pOperator, SExchangeOperatorBasic
void* tmp = taosArrayPush(pExchangeInfo->pSourceDataInfo, &dataInfo);
if (!tmp) {
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(TSDB_CODE_OUT_OF_MEMORY));
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(terrno));
return terrno;
}
pIdx->inUseIdx = taosArrayGetSize(pExchangeInfo->pSourceDataInfo) - 1;

View File

@ -332,7 +332,6 @@ SArray* createSortInfo(SNodeList* pNodeList) {
SArray* pList = taosArrayInit(numOfCols, sizeof(SBlockOrderInfo));
if (pList == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return pList;
}
@ -342,7 +341,7 @@ SArray* createSortInfo(SNodeList* pNodeList) {
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(terrno));
taosArrayDestroy(pList);
pList = NULL;
terrno = TSDB_CODE_OUT_OF_MEMORY;
terrno = TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR;
break;
}
SBlockOrderInfo bi = {0};
@ -355,7 +354,6 @@ SArray* createSortInfo(SNodeList* pNodeList) {
if (!tmp) {
taosArrayDestroy(pList);
pList = NULL;
terrno = TSDB_CODE_OUT_OF_MEMORY;
break;
}
}
@ -1129,7 +1127,7 @@ static int32_t optimizeTbnameInCondImpl(void* pVnode, SArray* pExistedUidList, S
if (numOfExisted > 0) {
uHash = taosHashInit(numOfExisted / 0.7, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
if (!uHash) {
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(TSDB_CODE_OUT_OF_MEMORY));
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(terrno));
return terrno;
}
@ -1330,7 +1328,7 @@ static int32_t copyExistedUids(SArray* pUidTagList, const SArray* pUidList) {
STUidTagInfo info = {.uid = *uid};
void* tmp = taosArrayPush(pUidTagList, &info);
if (!tmp) {
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(TSDB_CODE_OUT_OF_MEMORY));
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(terrno));
return code;
}
}
@ -1356,15 +1354,13 @@ static int32_t doFilterByTagCond(STableListInfo* pListInfo, SArray* pUidList, SN
tagFilterAssist ctx = {0};
ctx.colHash = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_SMALLINT), false, HASH_NO_LOCK);
if (ctx.colHash == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
code = TSDB_CODE_OUT_OF_MEMORY;
code = terrno;
QUERY_CHECK_CODE(code, lino, end);
}
ctx.cInfoList = taosArrayInit(4, sizeof(SColumnInfo));
if (ctx.cInfoList == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
code = TSDB_CODE_OUT_OF_MEMORY;
code = terrno;
QUERY_CHECK_CODE(code, lino, end);
}
@ -1717,7 +1713,6 @@ SArray* makeColumnArrayFromList(SNodeList* pNodeList) {
size_t numOfCols = LIST_LENGTH(pNodeList);
SArray* pList = taosArrayInit(numOfCols, sizeof(SColumn));
if (pList == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL;
}
@ -1725,7 +1720,7 @@ SArray* makeColumnArrayFromList(SNodeList* pNodeList) {
SColumnNode* pColNode = (SColumnNode*)nodesListGetNode(pNodeList, i);
if (!pColNode) {
taosArrayDestroy(pList);
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(TSDB_CODE_OUT_OF_MEMORY));
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR));
return NULL;
}
@ -1741,7 +1736,7 @@ SArray* makeColumnArrayFromList(SNodeList* pNodeList) {
void* tmp = taosArrayPush(pList, &c);
if (!tmp) {
taosArrayDestroy(pList);
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(TSDB_CODE_OUT_OF_MEMORY));
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(terrno));
return NULL;
}
}
@ -1836,7 +1831,6 @@ static SResSchema createResSchema(int32_t type, int32_t bytes, int32_t slotId, i
static SColumn* createColumn(int32_t blockId, int32_t slotId, int32_t colId, SDataType* pType, EColumnType colType) {
SColumn* pCol = taosMemoryCalloc(1, sizeof(SColumn));
if (pCol == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL;
}
@ -2175,7 +2169,7 @@ SqlFunctionCtx* createSqlFunctionCtx(SExprInfo* pExprInfo, int32_t numOfOutput,
}
bool tmp = pCtx->fpSet.getEnv(pExpr->pExpr->_function.pFunctNode, &env);
if (!tmp) {
code = TSDB_CODE_OUT_OF_MEMORY;
code = terrno;
QUERY_CHECK_CODE(code, lino, _end);
}
} else {
@ -2188,7 +2182,7 @@ SqlFunctionCtx* createSqlFunctionCtx(SExprInfo* pExprInfo, int32_t numOfOutput,
if (pCtx->sfp.getEnv != NULL) {
bool tmp = pCtx->sfp.getEnv(pExpr->pExpr->_function.pFunctNode, &env);
if (!tmp) {
code = TSDB_CODE_OUT_OF_MEMORY;
code = terrno;
QUERY_CHECK_CODE(code, lino, _end);
}
}
@ -2237,6 +2231,8 @@ _end:
}
taosMemoryFreeClear(*rowEntryInfoOffset);
taosMemoryFreeClear(pFuncCtx);
terrno = code;
return NULL;
}
return pFuncCtx;
@ -3074,6 +3070,7 @@ SNodeList* makeColsNodeArrFromSortKeys(SNodeList* pSortKeys) {
int32_t code = nodesListMakeAppend(&ret, pSortKey->pExpr);
if (code != TSDB_CODE_SUCCESS) {
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(code));
terrno = code;
return NULL;
}
}

View File

@ -742,7 +742,7 @@ int32_t qExecTaskOpt(qTaskInfo_t tinfo, SArray* pResList, uint64_t* useconds, bo
QUERY_CHECK_CODE(code, lino, _end);
void* tmp = taosArrayPush(pTaskInfo->pResultBlockList, &p1);
QUERY_CHECK_NULL(tmp, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
QUERY_CHECK_NULL(tmp, code, lino, _end, terrno);
p = p1;
} else {
void* tmp = taosArrayGet(pTaskInfo->pResultBlockList, blockIndex);
@ -897,7 +897,7 @@ int32_t qAppendTaskStopInfo(SExecTaskInfo* pTaskInfo, SExchangeOpStopInfo* pInfo
taosWUnLockLatch(&pTaskInfo->stopInfo.lock);
if (!tmp) {
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(TSDB_CODE_OUT_OF_MEMORY));
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(terrno));
return terrno;
}
return TSDB_CODE_SUCCESS;
@ -1586,8 +1586,7 @@ void qProcessRspMsg(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet) {
if (pMsg->contLen > 0) {
buf.pData = taosMemoryCalloc(1, pMsg->contLen);
if (buf.pData == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
pMsg->code = TSDB_CODE_OUT_OF_MEMORY;
pMsg->code = terrno;
} else {
memcpy(buf.pData, pMsg->pCont, pMsg->contLen);
}
@ -1606,7 +1605,6 @@ SArray* qGetQueriedTableListInfo(qTaskInfo_t tinfo) {
code = getTableListInfo(pTaskInfo, &plist);
if (code || plist == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY;
return NULL;
}

View File

@ -438,9 +438,6 @@ static int32_t doCreateConstantValColumnSMAInfo(SInputColumnInfoData* pInput, SF
return terrno;
}
pInput->pColumnDataAgg[paramIndex] = da;
if (da == NULL) {
return TSDB_CODE_OUT_OF_MEMORY;
}
} else {
da = pInput->pColumnDataAgg[paramIndex];
}
@ -1056,7 +1053,7 @@ int32_t initExprSupp(SExprSupp* pSup, SExprInfo* pExprInfo, int32_t numOfExpr, S
if (pSup->pExprInfo != NULL) {
pSup->pCtx = createSqlFunctionCtx(pExprInfo, numOfExpr, &pSup->rowEntryInfoOffset, pStore);
if (pSup->pCtx == NULL) {
return TSDB_CODE_OUT_OF_MEMORY;
return terrno;
}
}
@ -1145,7 +1142,7 @@ int32_t createDataSinkParam(SDataSinkNode* pNode, void** pParam, SExecTaskInfo*
if (!pTable) {
taosArrayDestroy(pDeleterParam->pUidList);
taosMemoryFree(pDeleterParam);
return TSDB_CODE_OUT_OF_MEMORY;
return TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR;
}
void* tmp = taosArrayPush(pDeleterParam->pUidList, &pTable->uid);
if (!tmp) {

View File

@ -387,10 +387,10 @@ static int32_t initFillInfo(SFillOperatorInfo* pInfo, SExprInfo* pExpr, int32_t
return terrno;
}
if (pInfo->pFillInfo == NULL || pInfo->p == NULL) {
if (pInfo->pFillInfo == NULL) {
taosMemoryFree(pInfo->pFillInfo);
taosMemoryFree(pInfo->p);
return TSDB_CODE_OUT_OF_MEMORY;
return TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR;
} else {
return TSDB_CODE_SUCCESS;
}

View File

@ -384,7 +384,7 @@ void freeGcBlkBufInfo(void* ptr) {
static int32_t addBlkToDirtyBufList(SGroupCacheOperatorInfo* pGCache, SGcDownstreamCtx* pCtx, SGcBlkCacheInfo* pCache, SGcBlkBufInfo* pBufInfo) {
if (0 != taosHashPut(pCache->pDirtyBlk, &pBufInfo->basic.blkId, sizeof(pBufInfo->basic.blkId), pBufInfo, sizeof(*pBufInfo))) {
freeGcBlkBufInfo(pBufInfo);
return TSDB_CODE_OUT_OF_MEMORY;
return terrno;
}
pBufInfo = taosHashGet(pCache->pDirtyBlk, &pBufInfo->basic.blkId, sizeof(pBufInfo->basic.blkId));
if (NULL == pBufInfo) {
@ -906,7 +906,7 @@ static int32_t addNewGroupData(struct SOperatorInfo* pOperator, SOperatorParam*
*ppGrp = taosHashGet(pGrpHash, &uid, sizeof(uid));
if (NULL == *ppGrp) {
return TSDB_CODE_OUT_OF_MEMORY;
return terrno;
}
QRY_ERR_RET(initNewGroupData(pCtx, *ppGrp, pParam->downstreamIdx, vgId, pGCache->batchFetch, pGcParam->needCache));
@ -1147,12 +1147,12 @@ static int32_t groupCacheSessionWait(struct SOperatorInfo* pOperator, SGcDownstr
if (NULL == pGroup->waitQueue) {
pGroup->waitQueue = taosArrayInit(1, POINTER_BYTES);
if (NULL == pGroup->waitQueue) {
QRY_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
QRY_ERR_JRET(terrno);
}
}
if (NULL == taosArrayPush(pGroup->waitQueue, &pSession)) {
QRY_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
QRY_ERR_JRET(terrno);
}
if (!pSession->semInit) {
@ -1413,7 +1413,7 @@ static int32_t initGroupCacheDownstreamCtx(SOperatorInfo* pOperator) {
pCtx->lastBlkUid = 0;
pCtx->pVgTbHash = tSimpleHashInit(10, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT));
if (NULL == pCtx->pVgTbHash) {
return TSDB_CODE_OUT_OF_MEMORY;
return terrno;
}
tSimpleHashSetFreeFp(pCtx->pVgTbHash, freeSGcVgroupCtx);

View File

@ -614,7 +614,6 @@ SSDataBlock* createBlockDataNotLoaded(const SOperatorInfo* pOperator, SSDataBloc
if (pDataBlock->pBlockAgg) {
pDstBlock->pBlockAgg = taosMemoryCalloc(numOfCols, sizeof(SColumnDataAgg));
if (pDstBlock->pBlockAgg == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
blockDataDestroy(pDstBlock);
return NULL;
}

View File

@ -804,7 +804,7 @@ static int32_t hJoinAddRowToHashImpl(SHJoinOperatorInfo* pJoin, SGroupData* pGro
pRow->next = NULL;
if (tSimpleHashPut(pJoin->pKeyHash, pTable->keyData, keyLen, &group, sizeof(group))) {
taosMemoryFree(pRow);
return TSDB_CODE_OUT_OF_MEMORY;
return terrno;
}
} else {
pRow->next = pGroup->rows;
@ -1201,7 +1201,7 @@ int32_t createHashJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t numOfDow
size_t hashCap = pInfo->pBuild->inputStat.inputRowNum > 0 ? (pInfo->pBuild->inputStat.inputRowNum * 1.5) : 1024;
pInfo->pKeyHash = tSimpleHashInit(hashCap, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY));
if (pInfo->pKeyHash == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY;
code = terrno;
goto _return;
}

View File

@ -331,7 +331,7 @@ int32_t openNonSortMergeOperator(SOperatorInfo* pOperator) {
pNonSortMergeInfo->pSourceStatus =
taosMemoryCalloc(pOperator->numOfDownstream, sizeof(*pNonSortMergeInfo->pSourceStatus));
if (NULL == pNonSortMergeInfo->pSourceStatus) {
pTaskInfo->code = TSDB_CODE_OUT_OF_MEMORY;
pTaskInfo->code = terrno;
return pTaskInfo->code;
}

View File

@ -722,7 +722,7 @@ int32_t getOperatorExplainExecInfo(SOperatorInfo* operatorInfo, SArray* pExecInf
code = getOperatorExplainExecInfo(operatorInfo->pDownstream[i], pExecInfoList);
if (code != TSDB_CODE_SUCCESS) {
// taosMemoryFreeClear(*pRes);
return TSDB_CODE_OUT_OF_MEMORY;
return code;
}
}

View File

@ -1167,7 +1167,7 @@ static int32_t createTableListInfoFromParam(SOperatorInfo* pOperator) {
if (TSDB_CODE_DUP_KEY == terrno) {
continue;
}
return TSDB_CODE_OUT_OF_MEMORY;
return terrno;
}
info.uid = *pUid;
@ -4572,11 +4572,10 @@ int32_t createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhysiNode*
int32_t numOfTags;
SExprInfo* pTagExpr = createExpr(pTableScanNode->pTags, &numOfTags);
if (pTagExpr == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
goto _error;
}
if (initExprSupp(&pInfo->tagCalSup, pTagExpr, numOfTags, &pTaskInfo->storageAPI.functionStore) != 0) {
code = TSDB_CODE_OUT_OF_MEMORY;
code = initExprSupp(&pInfo->tagCalSup, pTagExpr, numOfTags, &pTaskInfo->storageAPI.functionStore);
if (code != 0) {
goto _error;
}
}
@ -5173,7 +5172,7 @@ static int32_t doTagScanFromMetaEntryNext(SOperatorInfo* pOperator, SSDataBlock*
while (pInfo->curPos < size && pRes->info.rows < pOperator->resultInfo.capacity) {
code = doTagScanOneTable(pOperator, pRes, &mr, &pTaskInfo->storageAPI);
if (code != TSDB_CODE_OUT_OF_MEMORY) {
if (code != TSDB_CODE_OUT_OF_MEMORY && code != TSDB_CODE_QRY_REACH_QMEM_THRESHOLD && code != TSDB_CODE_QRY_QUERY_MEM_EXHAUSTED) {
// ignore other error
code = TSDB_CODE_SUCCESS;
}

View File

@ -112,10 +112,10 @@ int32_t createSortOperatorInfo(SOperatorInfo* downstream, SSortPhysiNode* pSortN
goto _error;
}
SNodeList* pSortColsNodeArr = makeColsNodeArrFromSortKeys(pSortNode->pSortKeys);
if (!pSortColsNodeArr) code = TSDB_CODE_OUT_OF_MEMORY;
if (!pSortColsNodeArr) code = terrno;
if (TSDB_CODE_SUCCESS == code) {
pGroupIdCalc->pSortColsArr = makeColumnArrayFromList(pSortColsNodeArr);
if (!pGroupIdCalc->pSortColsArr) code = TSDB_CODE_OUT_OF_MEMORY;
if (!pGroupIdCalc->pSortColsArr) code = terrno;
nodesClearList(pSortColsNodeArr);
}
if (TSDB_CODE_SUCCESS == code) {

View File

@ -549,7 +549,7 @@ void doStreamEventSaveCheckpoint(SOperatorInfo* pOperator) {
int32_t len = doStreamEventEncodeOpState(NULL, 0, pOperator);
void* buf = taosMemoryCalloc(1, len);
if (!buf) {
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(TSDB_CODE_OUT_OF_MEMORY));
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(terrno));
return;
}
void* pBuf = buf;

View File

@ -1466,7 +1466,7 @@ void doStreamIntervalSaveCheckpoint(SOperatorInfo* pOperator) {
int32_t len = doStreamIntervalEncodeOpState(NULL, 0, pOperator);
void* buf = taosMemoryCalloc(1, len);
if (!buf) {
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(TSDB_CODE_OUT_OF_MEMORY));
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(terrno));
return;
}
void* pBuf = buf;

View File

@ -609,7 +609,6 @@ static SSDataBlock* sysTableScanUserCols(SOperatorInfo* pOperator) {
}
if (!pInfo->pCur || !pInfo->pSchema) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
qError("sysTableScanUserCols failed since %s", terrstr());
blockDataDestroy(pDataBlock);
pInfo->loadInfo.totalRows = 0;
@ -1014,7 +1013,7 @@ static int32_t sysTableGetGeomText(char* iGeom, int32_t nGeom, char** output, in
char* outputWKT = NULL;
if (nGeom == 0) {
if (!(*output = taosStrdup(""))) code = TSDB_CODE_OUT_OF_MEMORY;
if (!(*output = taosStrdup(""))) code = terrno;
*nOutput = 0;
return code;
}
@ -1112,8 +1111,9 @@ static int32_t sysTableUserTagsFillOneTableTags(const SSysTableScanInfo* pInfo,
code = sysTableGetGeomText(tagVal.pData, tagVal.nData, &tagData, &tagLen);
QUERY_CHECK_CODE(code, lino, _end);
} else if (tagType == TSDB_DATA_TYPE_VARBINARY) {
if (taosAscii2Hex(tagVal.pData, tagVal.nData, (void**)&tagData, &tagLen) < 0) {
qError("varbinary for systable failed since %s", tstrerror(TSDB_CODE_OUT_OF_MEMORY));
code = taosAscii2Hex(tagVal.pData, tagVal.nData, (void**)&tagData, &tagLen);
if (code < 0) {
qError("varbinary for systable failed since %s", tstrerror(code));
}
} else if (IS_VAR_DATA_TYPE(tagType)) {
tagData = (char*)tagVal.pData;
@ -2397,7 +2397,7 @@ static SSDataBlock* sysTableScanFromMNode(SOperatorInfo* pOperator, SSysTableSca
SMsgSendInfo* pMsgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo));
if (NULL == pMsgSendInfo) {
qError("%s prepare message %d failed", GET_TASKID(pTaskInfo), (int32_t)sizeof(SMsgSendInfo));
pTaskInfo->code = TSDB_CODE_OUT_OF_MEMORY;
pTaskInfo->code = terrno;
taosMemoryFree(buf1);
return NULL;
}

View File

@ -630,7 +630,7 @@ static void doInterpUnclosedTimeWindow(SOperatorInfo* pOperatorInfo, int32_t num
int32_t ret = setTimeWindowOutputBuf(pResultRowInfo, &w, (scanFlag == MAIN_SCAN), &pResult, groupId, pSup->pCtx,
numOfOutput, pSup->rowEntryInfoOffset, &pInfo->aggSup, pTaskInfo);
if (ret != TSDB_CODE_SUCCESS) {
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY);
T_LONG_JMP(pTaskInfo->env, ret);
}
if(isResultRowInterpolated(pResult, RESULT_ROW_END_INTERP)) {
@ -780,7 +780,7 @@ static bool hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul
int32_t ret = setTimeWindowOutputBuf(pResultRowInfo, &win, (scanFlag == MAIN_SCAN), &pResult, tableGroupId,
pSup->pCtx, numOfOutput, pSup->rowEntryInfoOffset, &pInfo->aggSup, pTaskInfo);
if (ret != TSDB_CODE_SUCCESS || pResult == NULL) {
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY);
T_LONG_JMP(pTaskInfo->env, ret);
}
TSKEY ekey = ascScan ? win.ekey : win.skey;
@ -827,7 +827,7 @@ static bool hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul
int32_t code = setTimeWindowOutputBuf(pResultRowInfo, &nextWin, (scanFlag == MAIN_SCAN), &pResult, tableGroupId,
pSup->pCtx, numOfOutput, pSup->rowEntryInfoOffset, &pInfo->aggSup, pTaskInfo);
if (code != TSDB_CODE_SUCCESS || pResult == NULL) {
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY);
T_LONG_JMP(pTaskInfo->env, code);
}
ekey = ascScan ? nextWin.ekey : nextWin.skey;
@ -2271,7 +2271,7 @@ static void doMergeIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultRowInfo*
setTimeWindowOutputBuf(pResultRowInfo, &win, (scanFlag == MAIN_SCAN), &pResult, tableGroupId, pExprSup->pCtx,
numOfOutput, pExprSup->rowEntryInfoOffset, &iaInfo->aggSup, pTaskInfo);
if (ret != TSDB_CODE_SUCCESS || pResult == NULL) {
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY);
T_LONG_JMP(pTaskInfo->env, ret);
}
TSKEY ekey = ascScan ? win.ekey : win.skey;
@ -2312,7 +2312,7 @@ static void doMergeIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultRowInfo*
int32_t code = outputPrevIntervalResult(pOperatorInfo, tableGroupId, pResultBlock, &win);
if (code != TSDB_CODE_SUCCESS) {
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(code));
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY);
T_LONG_JMP(pTaskInfo->env, code);
}
STimeWindow nextWin = win;
@ -2329,7 +2329,7 @@ static void doMergeIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultRowInfo*
setTimeWindowOutputBuf(pResultRowInfo, &nextWin, (scanFlag == MAIN_SCAN), &pResult, tableGroupId,
pExprSup->pCtx, numOfOutput, pExprSup->rowEntryInfoOffset, &iaInfo->aggSup, pTaskInfo);
if (code != TSDB_CODE_SUCCESS || pResult == NULL) {
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY);
T_LONG_JMP(pTaskInfo->env, code);
}
ekey = ascScan ? nextWin.ekey : nextWin.skey;
@ -2354,7 +2354,7 @@ static void doMergeIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultRowInfo*
code = outputPrevIntervalResult(pOperatorInfo, tableGroupId, pResultBlock, &nextWin);
if (code != TSDB_CODE_SUCCESS) {
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(code));
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY);
T_LONG_JMP(pTaskInfo->env, code);
}
}

View File

@ -44,7 +44,7 @@ static int32_t loadDataFromFilePage(tMemBucket *pMemBucket, int32_t slotIdx, SFi
pIdList = *(SArray **)p;
} else {
taosMemoryFree(*buffer);
return TSDB_CODE_OUT_OF_MEMORY;
return terrno;
}
int32_t offset = 0;

View File

@ -2012,7 +2012,7 @@ int32_t nodesMakeList(SNodeList** ppListOut) {
int32_t nodesListAppend(SNodeList* pList, SNode* pNode) {
if (NULL == pList || NULL == pNode) {
return TSDB_CODE_FAILED;
return TSDB_CODE_INVALID_PARA;
}
SListCell* p = NULL;
int32_t code = nodesCalloc(1, sizeof(SListCell), (void**)&p);

View File

@ -625,7 +625,7 @@ int32_t cloneDbVgInfo(SDBVgInfo* pSrc, SDBVgInfo** pDst) {
qError("taosHashPut failed, vgId:%d", vgInfo->vgId);
taosHashCancelIterate(pSrc->vgHash, pIter);
freeVgInfo(*pDst);
return TSDB_CODE_OUT_OF_MEMORY;
return terrno;
}
pIter = taosHashIterate(pSrc->vgHash, pIter);

View File

@ -64,7 +64,7 @@ int32_t queryBuildUseDbOutput(SUseDbOutput *pOut, SUseDbRsp *usedbRsp) {
qDebug("the %dth vgroup, id %d, epNum %d, current %s port %d", i, pVgInfo->vgId, pVgInfo->epSet.numOfEps,
pVgInfo->epSet.eps[pVgInfo->epSet.inUse].fqdn, pVgInfo->epSet.eps[pVgInfo->epSet.inUse].port);
if (0 != taosHashPut(pOut->dbVgroup->vgHash, &pVgInfo->vgId, sizeof(int32_t), pVgInfo, sizeof(SVgroupInfo))) {
return TSDB_CODE_OUT_OF_MEMORY;
return terrno;
}
}

View File

@ -96,6 +96,7 @@ void qwDestroySession(QW_FPARAMS_DEF, SQWJobInfo *pJobInfo, void* session) {
char id2[sizeof(qId) + sizeof(cId) + 1] = {0};
QW_SET_QCID(id2, qId, cId);
(void)taosHashRemove(gQueryMgmt.pJobInfo, id2, sizeof(id2));
QW_TASK_DLOG_E("the whole query job removed");
} else {
QW_TASK_DLOG("job not removed, remainSessions:%d, %d", taosHashGetSize(pJobInfo->pSessions), pJobInfo->memInfo->remainSession);
@ -136,6 +137,8 @@ int32_t qwRetrieveJobInfo(QW_FPARAMS_DEF, SQWJobInfo** ppJob) {
return code;
}
QW_TASK_DLOG_E("job added to hash");
pJob = (SQWJobInfo*)taosHashAcquire(gQueryMgmt.pJobInfo, id, sizeof(id));
if (NULL == pJob) {
QW_TASK_ELOG_E("job not in job hash, may be dropped");
@ -192,6 +195,8 @@ int32_t qwInitSession(QW_FPARAMS_DEF, SQWTaskCtx *ctx, void** ppSession) {
break;
} while (true);
QW_TASK_DLOG_E("session initialized");
_return:
if (NULL != pJob) {

View File

@ -73,7 +73,7 @@ int32_t qwBuildAndSendQueryRsp(int32_t rspType, SRpcHandleInfo *pConn, int32_t c
int32_t msgSize = tSerializeSQueryTableRsp(NULL, 0, &rsp);
if (msgSize < 0) {
qError("tSerializeSQueryTableRsp failed");
QW_RET(TSDB_CODE_OUT_OF_MEMORY);
QW_RET(msgSize);
}
void *pRsp = rpcMallocCont(msgSize);
@ -82,9 +82,10 @@ int32_t qwBuildAndSendQueryRsp(int32_t rspType, SRpcHandleInfo *pConn, int32_t c
QW_RET(terrno);
}
if (tSerializeSQueryTableRsp(pRsp, msgSize, &rsp) < 0) {
msgSize = tSerializeSQueryTableRsp(pRsp, msgSize, &rsp);
if (msgSize < 0) {
qError("tSerializeSQueryTableRsp %d failed", msgSize);
QW_RET(TSDB_CODE_OUT_OF_MEMORY);
QW_RET(msgSize);
}
SRpcMsg rpcRsp = {
@ -245,7 +246,7 @@ int32_t qwBuildAndSendDropMsg(QW_FPARAMS_DEF, SRpcHandleInfo *pConn) {
int32_t msgSize = tSerializeSTaskDropReq(NULL, 0, &qMsg);
if (msgSize < 0) {
QW_SCH_TASK_ELOG("tSerializeSTaskDropReq get size, msgSize:%d", msgSize);
QW_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
QW_ERR_RET(msgSize);
}
void *msg = rpcMallocCont(msgSize);
@ -254,10 +255,11 @@ int32_t qwBuildAndSendDropMsg(QW_FPARAMS_DEF, SRpcHandleInfo *pConn) {
QW_ERR_RET(terrno);
}
if (tSerializeSTaskDropReq(msg, msgSize, &qMsg) < 0) {
msgSize = tSerializeSTaskDropReq(msg, msgSize, &qMsg);
if (msgSize < 0) {
QW_SCH_TASK_ELOG("tSerializeSTaskDropReq failed, msgSize:%d", msgSize);
rpcFreeCont(msg);
QW_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
QW_ERR_RET(msgSize);
}
SRpcMsg pNewMsg = {
@ -283,7 +285,7 @@ int32_t qwBuildAndSendCQueryMsg(QW_FPARAMS_DEF, SRpcHandleInfo *pConn) {
SQueryContinueReq *req = (SQueryContinueReq *)rpcMallocCont(sizeof(SQueryContinueReq));
if (NULL == req) {
QW_SCH_TASK_ELOG("rpcMallocCont %d failed", (int32_t)sizeof(SQueryContinueReq));
QW_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
QW_ERR_RET(terrno);
}
req->header.vgId = mgmt->nodeId;
@ -326,7 +328,7 @@ int32_t qwRegisterQueryBrokenLinkArg(QW_FPARAMS_DEF, SRpcHandleInfo *pConn) {
int32_t msgSize = tSerializeSTaskDropReq(NULL, 0, &qMsg);
if (msgSize < 0) {
QW_SCH_TASK_ELOG("tSerializeSTaskDropReq get size, msgSize:%d", msgSize);
QW_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
QW_ERR_RET(msgSize);
}
void *msg = rpcMallocCont(msgSize);
@ -335,10 +337,11 @@ int32_t qwRegisterQueryBrokenLinkArg(QW_FPARAMS_DEF, SRpcHandleInfo *pConn) {
QW_ERR_RET(terrno);
}
if (tSerializeSTaskDropReq(msg, msgSize, &qMsg) < 0) {
msgSize = tSerializeSTaskDropReq(msg, msgSize, &qMsg);
if (msgSize < 0) {
QW_SCH_TASK_ELOG("tSerializeSTaskDropReq failed, msgSize:%d", msgSize);
rpcFreeCont(msg);
QW_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
QW_ERR_RET(msgSize);
}
SRpcMsg brokenMsg = {
@ -362,17 +365,19 @@ int32_t qwRegisterHbBrokenLinkArg(SQWorker *mgmt, uint64_t clientId, SRpcHandleI
int32_t msgSize = tSerializeSSchedulerHbReq(NULL, 0, &req);
if (msgSize < 0) {
QW_SCH_ELOG("tSerializeSSchedulerHbReq hbReq failed, size:%d", msgSize);
QW_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
QW_ERR_RET(msgSize);
}
void *msg = rpcMallocCont(msgSize);
if (NULL == msg) {
QW_SCH_ELOG("calloc %d failed", msgSize);
QW_ERR_RET(terrno);
}
if (tSerializeSSchedulerHbReq(msg, msgSize, &req) < 0) {
msgSize = tSerializeSSchedulerHbReq(msg, msgSize, &req);
if (msgSize < 0) {
QW_SCH_ELOG("tSerializeSSchedulerHbReq hbReq failed, size:%d", msgSize);
rpcFreeCont(msg);
QW_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
QW_ERR_RET(msgSize);
}
SRpcMsg brokenMsg = {

View File

@ -89,7 +89,7 @@ int32_t qwAddSchedulerImpl(SQWorker *mgmt, uint64_t clientId, int32_t rwType) {
QW_SCH_ELOG("taosHashPut new sch to scheduleHash failed, errno:%d", errno);
taosHashCleanup(newSch.tasksHash);
QW_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
QW_ERR_RET(code);
}
taosHashCleanup(newSch.tasksHash);
@ -174,7 +174,7 @@ int32_t qwAddTaskStatusImpl(QW_FPARAMS_DEF, SQWSchStatus *sch, int32_t rwType, i
}
} else {
QW_TASK_ELOG("taosHashPut to tasksHash failed, error:%x - %s", code, tstrerror(code));
QW_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
QW_ERR_RET(code);
}
}
QW_UNLOCK(QW_WRITE, &sch->tasksLock);
@ -254,7 +254,7 @@ int32_t qwAddTaskCtxImpl(QW_FPARAMS_DEF, bool acquire, SQWTaskCtx **ctx) {
}
} else {
QW_TASK_ELOG("taosHashPut to ctxHash failed, error:%x", code);
QW_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
QW_ERR_RET(code);
}
}
@ -665,7 +665,7 @@ int32_t qwOpenRef(void) {
if (gQwMgmt.qwRef < 0) {
taosWUnLockLatch(&gQwMgmt.lock);
qError("init qworker ref failed");
QW_RET(TSDB_CODE_OUT_OF_MEMORY);
QW_RET(gQwMgmt.qwRef);
}
}
taosWUnLockLatch(&gQwMgmt.lock);

View File

@ -1400,7 +1400,7 @@ int32_t qWorkerInit(int8_t nodeType, int32_t nodeId, void **qWorkerMgmt, const S
mgmt->timer = taosTmrInit(0, 0, 0, "qworker");
if (NULL == mgmt->timer) {
qError("init timer failed, error:%s", tstrerror(terrno));
QW_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
QW_ERR_JRET(terrno);
}
mgmt->nodeType = nodeType;
@ -1423,7 +1423,7 @@ int32_t qWorkerInit(int8_t nodeType, int32_t nodeId, void **qWorkerMgmt, const S
mgmt->hbTimer = taosTmrStart(qwProcessHbTimerEvent, QW_DEFAULT_HEARTBEAT_MSEC, (void *)param, mgmt->timer);
if (NULL == mgmt->hbTimer) {
qError("start hb timer failed");
QW_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
QW_ERR_JRET(terrno);
}
QW_ERR_JRET(qExecutorInit());

View File

@ -51,7 +51,6 @@ int32_t sclCreateColumnInfoData(SDataType *pType, int32_t numOfRows, SScalarPara
int32_t code = colInfoDataEnsureCapacity(pColumnData, numOfRows, true);
if (code != TSDB_CODE_SUCCESS) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
colDataDestroy(pColumnData);
taosMemoryFree(pColumnData);
return terrno;
@ -1235,7 +1234,7 @@ EDealRes sclRewriteFunction(SNode **pNode, SScalarCtx *ctx) {
sclError("calloc %d failed", len);
sclFreeParam(&output);
nodesDestroyNode((SNode *)res);
ctx->code = TSDB_CODE_OUT_OF_MEMORY;
ctx->code = terrno;
return DEAL_RES_ERROR;
}
(void)memcpy(res->datum.p, output.columnData->pData, len);
@ -1246,7 +1245,7 @@ EDealRes sclRewriteFunction(SNode **pNode, SScalarCtx *ctx) {
sclError("calloc %d failed", (int)(varDataTLen(output.columnData->pData) + 1));
sclFreeParam(&output);
nodesDestroyNode((SNode *)res);
ctx->code = TSDB_CODE_OUT_OF_MEMORY;
ctx->code = terrno;
return DEAL_RES_ERROR;
}
(void)memcpy(res->datum.p, output.columnData->pData, varDataTLen(output.columnData->pData));
@ -1440,7 +1439,7 @@ EDealRes sclRewriteCaseWhen(SNode **pNode, SScalarCtx *ctx) {
sclError("calloc %d failed", (int)(varDataTLen(output.columnData->pData) + 1));
sclFreeParam(&output);
nodesDestroyNode((SNode *)res);
ctx->code = TSDB_CODE_OUT_OF_MEMORY;
ctx->code = terrno;
return DEAL_RES_ERROR;
}
(void)memcpy(res->datum.p, output.columnData->pData, varDataTLen(output.columnData->pData));
@ -1494,7 +1493,7 @@ EDealRes sclWalkFunction(SNode *pNode, SScalarCtx *ctx) {
}
if (taosHashPut(ctx->pRes, &pNode, POINTER_BYTES, &output, sizeof(output))) {
ctx->code = TSDB_CODE_OUT_OF_MEMORY;
ctx->code = terrno;
sclFreeParam(&output);
return DEAL_RES_ERROR;
}
@ -1513,7 +1512,7 @@ EDealRes sclWalkLogic(SNode *pNode, SScalarCtx *ctx) {
}
if (taosHashPut(ctx->pRes, &pNode, POINTER_BYTES, &output, sizeof(output))) {
ctx->code = TSDB_CODE_OUT_OF_MEMORY;
ctx->code = terrno;
sclFreeParam(&output);
return DEAL_RES_ERROR;
}
@ -1532,7 +1531,7 @@ EDealRes sclWalkOperator(SNode *pNode, SScalarCtx *ctx) {
}
if (taosHashPut(ctx->pRes, &pNode, POINTER_BYTES, &output, sizeof(output))) {
ctx->code = TSDB_CODE_OUT_OF_MEMORY;
ctx->code = terrno;
sclFreeParam(&output);
return DEAL_RES_ERROR;
}
@ -1613,7 +1612,7 @@ EDealRes sclWalkCaseWhen(SNode *pNode, SScalarCtx *ctx) {
}
if (taosHashPut(ctx->pRes, &pNode, POINTER_BYTES, &output, sizeof(output))) {
ctx->code = TSDB_CODE_OUT_OF_MEMORY;
ctx->code = terrno;
return DEAL_RES_ERROR;
}

View File

@ -1078,7 +1078,7 @@ int32_t vectorConvertSingleCol(SScalarParam *input, SScalarParam *output, int32_
int32_t code = sclCreateColumnInfoData(&t, input->numOfRows, output);
if (code != TSDB_CODE_SUCCESS) {
return TSDB_CODE_OUT_OF_MEMORY;
return code;
}
code = vectorConvertSingleColImpl(input, output, NULL, startIndex, numOfRows);

View File

@ -74,7 +74,7 @@ int32_t flttMakeValueNode(SNode **pNode, int32_t dataType, void *value) {
if (IS_VAR_DATA_TYPE(dataType)) {
vnode->datum.p = (char *)taosMemoryMalloc(varDataTLen(value));
if (NULL == vnode->datum.p) {
FLT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
FLT_ERR_RET(terrno);
}
varDataCopy(vnode->datum.p, value);
vnode->node.resType.bytes = varDataLen(value);

View File

@ -94,7 +94,7 @@ int32_t scltAppendReservedSlot(SArray *pBlockList, int16_t *dataBlockId, int16_t
SSDataBlock *res = NULL;
int32_t code = createDataBlock(&res);
if (code != 0 || NULL == res->pDataBlock) {
SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
SCL_ERR_RET(code);
}
SColumnInfoData idata = {0};
@ -121,7 +121,7 @@ int32_t scltAppendReservedSlot(SArray *pBlockList, int16_t *dataBlockId, int16_t
}
if (NULL == taosArrayPush(pBlockList, &res)) {
SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
SCL_ERR_RET(terrno);
}
*dataBlockId = taosArrayGetSize(pBlockList) - 1;
res->info.id.blockId = *dataBlockId;
@ -161,7 +161,7 @@ int32_t scltMakeValueNode(SNode **pNode, int32_t dataType, void *value) {
if (IS_VAR_DATA_TYPE(dataType)) {
vnode->datum.p = (char *)taosMemoryMalloc(varDataTLen(value));
if (NULL == vnode->datum.p) {
SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
SCL_ERR_RET(terrno);
}
varDataCopy(vnode->datum.p, value);
vnode->node.resType.bytes = varDataTLen(value);
@ -1385,7 +1385,7 @@ int32_t makeCalculate(void *json, void *key, int32_t rightType, void *rightData,
SCL_ERR_RET(makeJsonArrow(&src, &opNode, json, (char *)key));
if (NULL == taosArrayPush(blockList, &src)) {
SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
SCL_ERR_RET(terrno);
}
SCL_ERR_RET(makeOperator(&opNode, blockList, opType, rightType, rightData, isReverse));
@ -2483,7 +2483,7 @@ TEST(columnTest, greater_and_lower) {
int32_t scltMakeDataBlock(SScalarParam **pInput, int32_t type, void *pVal, int32_t num, bool setVal) {
SScalarParam *input = (SScalarParam *)taosMemoryCalloc(1, sizeof(SScalarParam));
if (NULL == input) {
SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
SCL_ERR_RET(terrno);
}
int32_t bytes;
switch (type) {
@ -2515,7 +2515,7 @@ int32_t scltMakeDataBlock(SScalarParam **pInput, int32_t type, void *pVal, int32
input->columnData = (SColumnInfoData *)taosMemoryCalloc(1, sizeof(SColumnInfoData));
if (NULL == input->columnData) {
SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
SCL_ERR_RET(terrno);
}
input->numOfRows = num;

View File

@ -158,7 +158,6 @@ void* rpcMallocCont(int64_t contLen) {
char* start = taosMemoryCalloc(1, size);
if (start == NULL) {
tError("failed to malloc msg, size:%" PRId64, size);
terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL;
} else {
tTrace("malloc mem:%p size:%" PRId64, start, size);

View File

@ -487,12 +487,14 @@ enum {
#define MP_CHECK_QUOTA(_pool, _job, _size) do { \
if (*(_pool)->cfg.jobQuota > 0) { \
int64_t cAllocSize = atomic_add_fetch_64(&(_job)->job.allocMemSize, (_size)); \
if ((cAllocSize / 1048576L) > *(_pool)->cfg.jobQuota) { \
uWarn("job 0x%" PRIx64 " allocSize %" PRId64 " is over than quota %dMB", (_job)->job.jobId, cAllocSize, *(_pool)->cfg.jobQuota); \
if (cAllocSize > (*(_pool)->cfg.jobQuota * 1048576L)) { \
uWarn("job 0x%" PRIx64 " remainSession:%d allocSize %" PRId64 " is over than quota %dMB", (_job)->job.jobId, (_job)->job.remainSession, cAllocSize, *(_pool)->cfg.jobQuota); \
(_pool)->cfg.cb.reachFp(pJob->job.jobId, (_job)->job.clientId, TSDB_CODE_QRY_REACH_QMEM_THRESHOLD); \
mpSchedTrim(NULL); \
terrno = TSDB_CODE_QRY_REACH_QMEM_THRESHOLD; \
return NULL; \
} else { \
uDebug("job 0x%" PRIx64 " remainSession:%d allocSize %" PRId64 " is lower than quota %dMB", (_job)->job.jobId, (_job)->job.remainSession, cAllocSize, *(_pool)->cfg.jobQuota); \
} \
} \
if (atomic_load_64(&tsCurrentAvailMemorySize) <= ((_pool)->cfg.reserveSize + (_size))) { \

View File

@ -349,9 +349,11 @@ static SPageInfo* getPageInfoFromPayload(void* page) {
int32_t createDiskbasedBuf(SDiskbasedBuf** pBuf, int32_t pagesize, int64_t inMemBufSize, const char* id,
const char* dir) {
int32_t code = 0;
*pBuf = NULL;
SDiskbasedBuf* pPBuf = taosMemoryCalloc(1, sizeof(SDiskbasedBuf));
if (pPBuf == NULL) {
code = terrno;
goto _error;
}
@ -362,12 +364,14 @@ int32_t createDiskbasedBuf(SDiskbasedBuf** pBuf, int32_t pagesize, int64_t inMem
pPBuf->pFile = NULL;
pPBuf->id = taosStrdup(id);
if (id != NULL && pPBuf->id == NULL) {
code = terrno;
goto _error;
}
pPBuf->fileSize = 0;
pPBuf->pFree = taosArrayInit(4, sizeof(SFreeListItem));
pPBuf->freePgList = tdListNew(POINTER_BYTES);
if (pPBuf->pFree == NULL || pPBuf->freePgList == NULL) {
code = terrno;
goto _error;
}
@ -379,6 +383,7 @@ int32_t createDiskbasedBuf(SDiskbasedBuf** pBuf, int32_t pagesize, int64_t inMem
pPBuf->inMemPages = inMemBufSize / pagesize; // maximum allowed pages, it is a soft limit.
pPBuf->lruList = tdListNew(POINTER_BYTES);
if (pPBuf->lruList == NULL) {
code = terrno;
goto _error;
}
@ -386,17 +391,20 @@ int32_t createDiskbasedBuf(SDiskbasedBuf** pBuf, int32_t pagesize, int64_t inMem
_hash_fn_t fn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT);
pPBuf->pIdList = taosArrayInit(4, POINTER_BYTES);
if (pPBuf->pIdList == NULL) {
code = terrno;
goto _error;
}
pPBuf->all = tSimpleHashInit(64, fn);
if (pPBuf->all == NULL) {
code = terrno;
goto _error;
}
pPBuf->prefix = (char*)dir;
pPBuf->emptyDummyIdList = taosArrayInit(1, sizeof(int32_t));
if (pPBuf->emptyDummyIdList == NULL) {
code = terrno;
goto _error;
}
@ -409,7 +417,7 @@ int32_t createDiskbasedBuf(SDiskbasedBuf** pBuf, int32_t pagesize, int64_t inMem
_error:
destroyDiskbasedBuf(pPBuf);
*pBuf = NULL;
return TSDB_CODE_OUT_OF_MEMORY;
return code;
}
static char* doExtractPage(SDiskbasedBuf* pBuf) {

View File

@ -0,0 +1,130 @@
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import re
from util.log import *
from util.cases import *
from util.sql import *
from util.common import *
from util.sqlset import *
class TDTestCase:
updatecfgDict = {'queryUseMemoryPool':'true','minReservedMemorySize':1025, 'singleQueryMaxMemorySize': 0}
def init(self, conn, logSql, replicaVar=1):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor())
self.setsql = TDSetSql()
self.perf_param_list = ['apps','connections','consumers','queries','trans']
self.dbname = "db"
self.vgroups = 4
self.stbname = f'`{tdCom.getLongName(5)}`'
self.tbname = f'`{tdCom.getLongName(3)}`'
self.db_param = {
"database":f"{self.dbname}",
"buffer":100,
"vgroups":self.vgroups,
"stt_trigger":1,
"tsdb_pagesize":16
}
def update_cfg(self, use_mpool = 1, min_rsize = 0, single_msize = 0):
updatecfgDict = {'queryUseMemoryPool':'{use_mpool}','minReservedMemorySize': min_rsize, 'singleQueryMaxMemorySize': single_msize}
tdDnodes.stop(1)
tdDnodes.deploy(1)
tdDnodes.start(1)
def alter_cfg(self, use_mpool = 1, min_rsize = 0, single_msize = 0):
tdSql.error(f"alter dnode 1 'queryUseMemoryPool' '{use_mpool}'")
tdSql.error(f"alter dnode 1 'minReservedMemorySize' '{min_rsize}'")
tdSql.error(f"alter dnode 1 'singleQueryMaxMemorySize' '{single_msize}'")
def variables_check(self, err_case = 0, use_mpool = 1, min_rsize = 0, single_msize = 0):
if err_case == 1:
tdSql.error("show dnode 1 variables like 'queryUseMemoryPool'")
else:
tdSql.query("show dnode 1 variables like 'queryUseMemoryPool'")
tdSql.checkRows(1)
tdSql.checkData(0, 0, 1)
tdSql.checkData(0, 1, 'queryUseMemoryPool')
tdSql.checkData(0, 2, use_mpool)
if err_case == 1:
tdSql.error("show dnode 1 variables like 'minReservedMemorySize'")
else:
tdSql.query("show dnode 1 variables like 'minReservedMemorySize'")
tdSql.checkRows(1)
tdSql.checkData(0, 0, 1)
tdSql.checkData(0, 1, 'minReservedMemorySize')
tdSql.checkData(0, 2, min_rsize)
if err_case == 1:
tdSql.error("show dnode 1 variables like 'singleQueryMaxMemorySize'")
else:
tdSql.query("show dnode 1 variables like 'singleQueryMaxMemorySize'")
tdSql.checkRows(1)
tdSql.checkData(0, 0, 1)
tdSql.checkData(0, 1, 'singleQueryMaxMemorySize')
tdSql.checkData(0, 2, single_msize)
def cfg_check(self):
tdLog.info(f'[disable pool] start')
self.update_cfg(0, 1024, 0)
self.variables_check(0, 0, 1024, 0)
tdLog.info(f'[enable pool + up limit] start')
self.update_cfg(1, 1000000000, 1000000000)
self.variables_check(0, 1, 1000000000, 1000000000)
tdLog.info(f'[enable pool + out of reserve] start')
self.update_cfg(1, 1000000001)
self.variables_check(1)
tdLog.info(f'[enable pool + out of single] start')
self.update_cfg(1, 1000, 1000000001)
self.variables_check(1)
tdLog.info(f'[out of pool] start')
self.update_cfg(2)
self.variables_check(1)
def alter_check(self):
tdLog.info(f'[alter] start')
self.update_cfg(1, 1024, 0)
self.alter_cfg(1, 1024, 0);
def single_up_check(self):
tdLog.info(f'[low single] start')
self.update_cfg(1, 1024, 1)
tdSql.error("select *, repeat('aaaaaaaaaa',1000) from information_schema.ins_tables")
tdLog.info(f'[normal single] start')
self.update_cfg(1, 1024, 100)
tdSql.query("select *, repeat('aaaaaaaaaa',1000) from information_schema.ins_tables")
def too_big_reserve(self):
tdLog.info(f'[too big reserve] start')
self.update_cfg(1, 1024000)
def run(self):
self.cfg_check()
self.alter_check()
self.single_up_check()
self.too_big_reserve()
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())