Merge branch '3.0' into enh/3.0/TS-5007

This commit is contained in:
xiao-77 2024-12-13 15:04:36 +08:00
commit a6e1af6b42
162 changed files with 7472 additions and 839 deletions

View File

@ -131,7 +131,7 @@ IF(TD_WINDOWS)
SET(COMMON_FLAGS "/w /D_WIN32 /DWIN32 /Zi /MTd") SET(COMMON_FLAGS "/w /D_WIN32 /DWIN32 /Zi /MTd")
ENDIF() ENDIF()
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO") SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO /FORCE:MULTIPLE")
# IF (MSVC AND (MSVC_VERSION GREATER_EQUAL 1900)) # IF (MSVC AND (MSVC_VERSION GREATER_EQUAL 1900))
# SET(COMMON_FLAGS "${COMMON_FLAGS} /Wv:18") # SET(COMMON_FLAGS "${COMMON_FLAGS} /Wv:18")

View File

@ -2,7 +2,7 @@
# libuv # libuv
ExternalProject_Add(libuv ExternalProject_Add(libuv
GIT_REPOSITORY https://github.com/libuv/libuv.git GIT_REPOSITORY https://github.com/libuv/libuv.git
GIT_TAG v1.48.0 GIT_TAG v1.49.2
SOURCE_DIR "${TD_CONTRIB_DIR}/libuv" SOURCE_DIR "${TD_CONTRIB_DIR}/libuv"
BINARY_DIR "${TD_CONTRIB_DIR}/libuv" BINARY_DIR "${TD_CONTRIB_DIR}/libuv"
CONFIGURE_COMMAND "" CONFIGURE_COMMAND ""

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -73,6 +73,9 @@ After modifying configuration file parameters, you need to restart the *taosd* s
|tagFilterCache | |Not supported |Whether to cache tag filter results| |tagFilterCache | |Not supported |Whether to cache tag filter results|
|queryBufferSize | |Supported, effective after restart|Not effective yet| |queryBufferSize | |Supported, effective after restart|Not effective yet|
|queryRspPolicy | |Supported, effective immediately |Query response strategy| |queryRspPolicy | |Supported, effective immediately |Query response strategy|
|queryUseMemoryPool | |Not supported |Whether query will use memory pool to manage memory, default value: 1 (on); 0: off, 1: on|
|minReservedMemorySize | |Not supported |The minimum reserved system available memory size, all memory except reserved can be used for queries, unit: MB, default reserved size is 20% of system physical memory, value range 1024-1000000000|
|singleQueryMaxMemorySize| |Not supported |The memory limit that a single query can use on a single node (dnode), exceeding this limit will return an error, unit: MB, default value: 0 (no limit), value range 0-1000000000|
|filterScalarMode | |Not supported |Force scalar filter mode, 0: off; 1: on, default value 0| |filterScalarMode | |Not supported |Force scalar filter mode, 0: off; 1: on, default value 0|
|queryPlannerTrace | |Supported, effective immediately |Internal parameter, whether the query plan outputs detailed logs| |queryPlannerTrace | |Supported, effective immediately |Internal parameter, whether the query plan outputs detailed logs|
|queryNodeChunkSize | |Supported, effective immediately |Internal parameter, chunk size of the query plan| |queryNodeChunkSize | |Supported, effective immediately |Internal parameter, chunk size of the query plan|

View File

@ -286,6 +286,9 @@ This document details the server error codes that may be encountered when using
| 0x80000729 | Task message error | Query message error | Preserve the scene and logs, report issue on GitHub | | 0x80000729 | Task message error | Query message error | Preserve the scene and logs, report issue on GitHub |
| 0x8000072B | Task status error | Subquery status error | Preserve the scene and logs, report issue on GitHub | | 0x8000072B | Task status error | Subquery status error | Preserve the scene and logs, report issue on GitHub |
| 0x8000072F | Job not exist | Query JOB no longer exists | Preserve the scene and logs, report issue on GitHub | | 0x8000072F | Job not exist | Query JOB no longer exists | Preserve the scene and logs, report issue on GitHub |
| 0x80000739 | Query memory upper limit is reached | Single query memory upper limit is reached | Modify memory upper limit size or optimize SQL |
| 0x8000073A | Query memory exhausted | Query memory in dnode is exhausted | Limit concurrent queries or add more physical memory |
| 0x8000073B | Timeout for long time no fetch | Query without fetch for a long time | Correct application to fetch data asap |
## grant ## grant

View File

@ -69,6 +69,9 @@ taosd 命令行参数如下
|tagFilterCache | |不支持动态修改 |是否缓存标签过滤结果| |tagFilterCache | |不支持动态修改 |是否缓存标签过滤结果|
|queryBufferSize | |支持动态修改 重启生效 |暂不生效| |queryBufferSize | |支持动态修改 重启生效 |暂不生效|
|queryRspPolicy | |支持动态修改 立即生效 |查询响应策略| |queryRspPolicy | |支持动态修改 立即生效 |查询响应策略|
|queryUseMemoryPool | |不支持动态修改 |查询是否使用内存池管理内存默认值1打开; 0: 关闭1: 打开|
|minReservedMemorySize | |不支持动态修改 |最小预留的系统可用内存数量除预留外的内存都可以被用于查询单位MB默认预留大小为系统物理内存的 20%,取值范围 1024 - 1000000000|
|singleQueryMaxMemorySize| |不支持动态修改 |单个查询在单个节点(dnode)上可以使用的内存上限超过该上限将返回错误单位MB默认值0无上限取值范围 0 - 1000000000|
|filterScalarMode | |不支持动态修改 |强制使用标量过滤模式0关闭1开启默认值 0| |filterScalarMode | |不支持动态修改 |强制使用标量过滤模式0关闭1开启默认值 0|
|queryPlannerTrace | |支持动态修改 立即生效 |内部参数,查询计划是否输出详细日志| |queryPlannerTrace | |支持动态修改 立即生效 |内部参数,查询计划是否输出详细日志|
|queryNodeChunkSize | |支持动态修改 立即生效 |内部参数,查询计划的块大小| |queryNodeChunkSize | |支持动态修改 立即生效 |内部参数,查询计划的块大小|

View File

@ -296,6 +296,9 @@ description: TDengine 服务端的错误码列表和详细说明
| 0x80000729 | Task message error | 查询消息错误 | 保留现场和日志github上报issue | | 0x80000729 | Task message error | 查询消息错误 | 保留现场和日志github上报issue |
| 0x8000072B | Task status error | 子查询状态错误 | 保留现场和日志github上报issue | | 0x8000072B | Task status error | 子查询状态错误 | 保留现场和日志github上报issue |
| 0x8000072F | Job not exist | 查询JOB已经不存在 | 保留现场和日志github上报issue | | 0x8000072F | Job not exist | 查询JOB已经不存在 | 保留现场和日志github上报issue |
| 0x80000739 | Query memory upper limit is reached | 单个查询达到内存使用上限 | 设置合理的内存上限或调整 SQL 语句 |
| 0x8000073A | Query memory exhausted | dnode查询内存到达使用上限 | 设置合理的内存上限或调整并发查询量或增大系统内存 |
| 0x8000073B | Timeout for long time no fetch | 查询被长时间中断未恢复 | 调整应用实现尽快 fetch 数据 |
## grant ## grant

View File

@ -79,6 +79,18 @@ extern int32_t tsTagFilterResCacheSize;
extern int32_t tsBypassFlag; extern int32_t tsBypassFlag;
// queue & threads // queue & threads
extern int32_t tsQueryMinConcurrentTaskNum;
extern int32_t tsQueryMaxConcurrentTaskNum;
extern int32_t tsQueryConcurrentTaskNum;
extern int32_t tsSingleQueryMaxMemorySize;
extern int8_t tsQueryUseMemoryPool;
extern int8_t tsMemPoolFullFunc;
//extern int32_t tsQueryBufferPoolSize;
extern int32_t tsMinReservedMemorySize;
extern int64_t tsCurrentAvailMemorySize;
extern int8_t tsNeedTrim;
extern int32_t tsQueryNoFetchTimeoutSec;
extern int32_t tsNumOfQueryThreads;
extern int32_t tsNumOfRpcThreads; extern int32_t tsNumOfRpcThreads;
extern int32_t tsNumOfRpcSessions; extern int32_t tsNumOfRpcSessions;
extern int32_t tsShareConnLimit; extern int32_t tsShareConnLimit;

View File

@ -2782,7 +2782,7 @@ int32_t tDeserializeSResFetchReq(void* buf, int32_t bufLen, SResFetchReq* pReq);
typedef struct { typedef struct {
SMsgHead header; SMsgHead header;
uint64_t sId; uint64_t clientId;
} SSchTasksStatusReq; } SSchTasksStatusReq;
typedef struct { typedef struct {
@ -2812,7 +2812,7 @@ typedef struct SQueryNodeEpId {
typedef struct { typedef struct {
SMsgHead header; SMsgHead header;
uint64_t sId; uint64_t clientId;
SQueryNodeEpId epId; SQueryNodeEpId epId;
SArray* taskAction; // SArray<STaskAction> SArray* taskAction; // SArray<STaskAction>
} SSchedulerHbReq; } SSchedulerHbReq;

View File

@ -47,7 +47,7 @@ typedef int32_t (*GetQueueSizeFp)(void* pMgmt, int32_t vgId, EQueueType qtype);
typedef int32_t (*SendReqFp)(const SEpSet* pEpSet, SRpcMsg* pMsg); typedef int32_t (*SendReqFp)(const SEpSet* pEpSet, SRpcMsg* pMsg);
typedef void (*SendRspFp)(SRpcMsg* pMsg); typedef void (*SendRspFp)(SRpcMsg* pMsg);
typedef void (*RegisterBrokenLinkArgFp)(struct SRpcMsg* pMsg); typedef void (*RegisterBrokenLinkArgFp)(struct SRpcMsg* pMsg);
typedef void (*ReleaseHandleFp)(SRpcHandleInfo* pHandle, int8_t type); typedef void (*ReleaseHandleFp)(SRpcHandleInfo* pHandle, int8_t type, int32_t status);
typedef void (*ReportStartup)(const char* name, const char* desc); typedef void (*ReportStartup)(const char* name, const char* desc);
typedef struct { typedef struct {
@ -76,7 +76,7 @@ int32_t tmsgSendReq(const SEpSet* epSet, SRpcMsg* pMsg);
int32_t tmsgSendSyncReq(const SEpSet* epSet, SRpcMsg* pMsg); int32_t tmsgSendSyncReq(const SEpSet* epSet, SRpcMsg* pMsg);
void tmsgSendRsp(SRpcMsg* pMsg); void tmsgSendRsp(SRpcMsg* pMsg);
void tmsgRegisterBrokenLinkArg(SRpcMsg* pMsg); void tmsgRegisterBrokenLinkArg(SRpcMsg* pMsg);
void tmsgReleaseHandle(SRpcHandleInfo* pHandle, int8_t type); void tmsgReleaseHandle(SRpcHandleInfo* pHandle, int8_t type, int32_t code);
void tmsgReportStartup(const char* name, const char* desc); void tmsgReportStartup(const char* name, const char* desc);
bool tmsgUpdateDnodeInfo(int32_t* dnodeId, int64_t* clusterId, char* fqdn, uint16_t* port); bool tmsgUpdateDnodeInfo(int32_t* dnodeId, int64_t* clusterId, char* fqdn, uint16_t* port);
void tmsgUpdateDnodeEpSet(SEpSet* epset); void tmsgUpdateDnodeEpSet(SEpSet* epset);

View File

@ -29,6 +29,9 @@ extern "C" {
#define DS_BUF_FULL 2 #define DS_BUF_FULL 2
#define DS_BUF_EMPTY 3 #define DS_BUF_EMPTY 3
#define DS_FLAG_USE_MEMPOOL (1 << 0)
struct SSDataBlock; struct SSDataBlock;
typedef struct SDeleterRes { typedef struct SDeleterRes {
@ -84,7 +87,7 @@ typedef struct SOutputData {
* @param pHandle output * @param pHandle output
* @return error code * @return error code
*/ */
int32_t dsCreateDataSinker(void* pSinkManager, const SDataSinkNode* pDataSink, DataSinkHandle* pHandle, void* pParam, const char* id); int32_t dsCreateDataSinker(void* pSinkManager, SDataSinkNode** ppDataSink, DataSinkHandle* pHandle, void* pParam, const char* id);
int32_t dsDataSinkGetCacheSize(SDataSinkStat* pStat); int32_t dsDataSinkGetCacheSize(SDataSinkStat* pStat);
@ -131,6 +134,9 @@ void dsScheduleProcess(void* ahandle, void* pItem);
*/ */
void dsDestroyDataSinker(DataSinkHandle handle); void dsDestroyDataSinker(DataSinkHandle handle);
int32_t dsGetSinkFlags(DataSinkHandle handle, uint64_t* pFlags);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -58,6 +58,7 @@ typedef struct {
struct SStorageAPI api; struct SStorageAPI api;
void* pWorkerCb; void* pWorkerCb;
bool localExec;
} SReadHandle; } SReadHandle;
// in queue mode, data streams are seperated by msg // in queue mode, data streams are seperated by msg
@ -167,6 +168,7 @@ int32_t qExecTaskOpt(qTaskInfo_t tinfo, SArray* pResList, uint64_t* useconds, bo
int32_t qExecTask(qTaskInfo_t tinfo, SSDataBlock** pBlock, uint64_t* useconds); int32_t qExecTask(qTaskInfo_t tinfo, SSDataBlock** pBlock, uint64_t* useconds);
int32_t qExecutorInit(void);
void qResetTaskCode(qTaskInfo_t tinfo); void qResetTaskCode(qTaskInfo_t tinfo);
void qCleanExecTaskBlockBuf(qTaskInfo_t tinfo); void qCleanExecTaskBlockBuf(qTaskInfo_t tinfo);

View File

@ -631,7 +631,7 @@ typedef struct SDownstreamSourceNode {
SQueryNodeAddr addr; SQueryNodeAddr addr;
uint64_t clientId; uint64_t clientId;
uint64_t taskId; uint64_t taskId;
uint64_t schedId; uint64_t sId;
int32_t execId; int32_t execId;
int32_t fetchMsgType; int32_t fetchMsgType;
bool localExec; bool localExec;

View File

@ -113,6 +113,11 @@ int32_t qWorkerProcessLocalFetch(void *pMgmt, uint64_t sId, uint64_t qId, uint64
int32_t qWorkerDbgEnableDebug(char *option); int32_t qWorkerDbgEnableDebug(char *option);
void qWorkerRetireJob(uint64_t jobId, uint64_t clientId, int32_t errCode);
void qWorkerRetireJobs(int64_t retireSize, int32_t errCode);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -171,7 +171,7 @@ void *rpcReallocCont(void *ptr, int64_t contLen);
int32_t rpcSendRequest(void *thandle, const SEpSet *pEpSet, SRpcMsg *pMsg, int64_t *rid); int32_t rpcSendRequest(void *thandle, const SEpSet *pEpSet, SRpcMsg *pMsg, int64_t *rid);
int32_t rpcSendResponse(const SRpcMsg *pMsg); int32_t rpcSendResponse(const SRpcMsg *pMsg);
int32_t rpcRegisterBrokenLinkArg(SRpcMsg *msg); int32_t rpcRegisterBrokenLinkArg(SRpcMsg *msg);
int32_t rpcReleaseHandle(void *handle, int8_t type); // just release conn to rpc instance, no close sock int32_t rpcReleaseHandle(void *handle, int8_t type, int32_t code); // just release conn to rpc instance, no close sock
// These functions will not be called in the child process // These functions will not be called in the child process
int32_t rpcSendRequestWithCtx(void *thandle, const SEpSet *pEpSet, SRpcMsg *pMsg, int64_t *rid, SRpcCtx *ctx); int32_t rpcSendRequestWithCtx(void *thandle, const SEpSet *pEpSet, SRpcMsg *pMsg, int64_t *rid, SRpcCtx *ctx);

View File

@ -110,6 +110,7 @@ extern "C" {
#include "osLz4.h" #include "osLz4.h"
#include "osMath.h" #include "osMath.h"
#include "osMemory.h" #include "osMemory.h"
#include "osMemPool.h"
#include "osRand.h" #include "osRand.h"
#include "osSemaphore.h" #include "osSemaphore.h"
#include "osSignal.h" #include "osSignal.h"

206
include/os/osMemPool.h Normal file
View File

@ -0,0 +1,206 @@
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _TD_OS_MEMPOOL_H_
#define _TD_OS_MEMPOOL_H_
#include "os.h"
#ifdef __cplusplus
extern "C" {
#endif
#define MEMPOOL_MAX_CHUNK_SIZE (1 << 30)
#define MEMPOOL_MIN_CHUNK_SIZE (1 << 20)
typedef enum MemPoolEvictPolicy {
E_EVICT_ALL = 1,
E_EVICT_NONE,
E_EVICT_AUTO,
E_EVICT_MAX_VALUE, // no used
} MemPoolEvictPolicy;
typedef struct SMemPoolJob {
uint64_t jobId;
uint64_t clientId;
int32_t remainSession;
int64_t allocMemSize;
int64_t maxAllocMemSize;
} SMemPoolJob;
typedef struct SMPStatItem {
int64_t inErr;
int64_t exec;
int64_t succ;
int64_t fail;
} SMPStatItem;
typedef struct SMPStatItemExt {
int64_t inErr;
int64_t exec;
int64_t succ;
int64_t fail;
int64_t origExec;
int64_t origSucc;
int64_t origFail;
} SMPStatItemExt;
typedef struct SMPMemoryStat {
SMPStatItem memMalloc;
SMPStatItem memCalloc;
SMPStatItemExt memRealloc;
SMPStatItem memStrdup;
SMPStatItem memStrndup;
SMPStatItem memFree;
SMPStatItem memTrim;
SMPStatItem chunkMalloc;
SMPStatItem chunkRecycle;
SMPStatItem chunkReUse;
SMPStatItem chunkFree;
} SMPMemoryStat;
typedef struct SMPStatDetail {
SMPMemoryStat times;
SMPMemoryStat bytes;
} SMPStatDetail;
typedef void (*mpDecConcSessionNum)(void);
typedef void (*mpIncConcSessionNum)(void);
typedef void (*mpSetConcSessionNum)(int32_t);
typedef void (*mpReserveFailFp)(int64_t, int32_t);
typedef void (*mpReserveReachFp)(uint64_t, uint64_t, int32_t);
typedef void (*mpCfgUpdate)(void*, void*);
typedef struct SMemPoolCallBack {
//mpDecConcSessionNum decSessFp;
//mpIncConcSessionNum incSessFp;
//mpSetConcSessionNum setSessFp;
mpReserveFailFp failFp;
mpReserveReachFp reachFp;
//mpCfgUpdate cfgUpdateFp;
} SMemPoolCallBack;
typedef struct SMemPoolCfg {
//bool reserveMode;
int64_t reserveSize;
//int32_t *upperLimitSize; //MB
//int64_t retireUnitSize;
int32_t *jobQuota; //MB
int32_t chunkSize;
int32_t threadNum;
MemPoolEvictPolicy evicPolicy;
SMemPoolCallBack cb;
} SMemPoolCfg;
#define MEMPOOL_GET_ALLOC_SIZE(_dstat) ((_dstat)->bytes.memMalloc.succ + (_dstat)->bytes.memCalloc.succ + (_dstat)->bytes.memRealloc.succ + (_dstat)->bytes.memStrdup.succ + (_dstat)->bytes.memStrndup.succ)
#define MEMPOOL_GET_FREE_SIZE(_dstat) ((_dstat)->bytes.memRealloc.origSucc + (_dstat)->bytes.memFree.succ)
#define MEMPOOL_GET_USED_SIZE(_dstat) (MEMPOOL_GET_ALLOC_SIZE(_dstat) - MEMPOOL_GET_FREE_SIZE(_dstat))
int32_t taosMemPoolOpen(char* poolName, SMemPoolCfg* cfg, void** poolHandle);
void *taosMemPoolMalloc(void* poolHandle, void* session, int64_t size, char* fileName, int32_t lineNo);
void *taosMemPoolCalloc(void* poolHandle, void* session, int64_t num, int64_t size, char* fileName, int32_t lineNo);
void *taosMemPoolRealloc(void* poolHandle, void* session, void *ptr, int64_t size, char* fileName, int32_t lineNo);
char *taosMemPoolStrdup(void* poolHandle, void* session, const char *ptr, char* fileName, int32_t lineNo);
char *taosMemPoolStrndup(void* poolHandle, void* session, const char *ptr, int64_t size, char* fileName, int32_t lineNo);
void taosMemPoolFree(void* poolHandle, void* session, void *ptr, char* fileName, int32_t lineNo);
int64_t taosMemPoolGetMemorySize(void* poolHandle, void* session, void *ptr, char* fileName, int32_t lineNo);
int32_t taosMemPoolTrim(void* poolHandle, void* session, int32_t size, char* fileName, int32_t lineNo, bool* trimed);
void *taosMemPoolMallocAlign(void* poolHandle, void* session, uint32_t alignment, int64_t size, char* fileName, int32_t lineNo);
void taosMemPoolClose(void* poolHandle);
void taosMemPoolModDestroy(void);
void taosAutoMemoryFree(void *ptr);
int32_t taosMemPoolInitSession(void* poolHandle, void** ppSession, void* pJob, char *sessionId);
void taosMemPoolDestroySession(void* poolHandle, void* session);
int32_t taosMemPoolCallocJob(uint64_t jobId, uint64_t cId, void** ppJob);
void taosMemPoolCfgUpdate(void* poolHandle, SMemPoolCfg* pCfg);
void taosMemPoolPrintStat(void* poolHandle, void* session, char* procName);
int32_t taosMemPoolTryLockPool(void* poolHandle, bool readLock);
void taosMemPoolUnLockPool(void* poolHandle, bool readLock);
void taosMemPoolGetUsedSizeBegin(void* poolHandle, int64_t* usedSize, bool* needEnd);
void taosMemPoolGetUsedSizeEnd(void* poolHandle);
int32_t taosMemPoolGetSessionStat(void* session, SMPStatDetail** ppStat, int64_t* allocSize, int64_t* maxAllocSize);
void taosMemPoolSchedTrim(void);
int32_t taosMemoryPoolInit(mpReserveFailFp, mpReserveReachFp);
#define taosMemPoolFreeClear(ptr) \
do { \
if (ptr) { \
taosMemPoolFree((void *)ptr); \
(ptr) = NULL; \
} \
} while (0)
#ifndef BUILD_TEST
extern void* gMemPoolHandle;
extern threadlocal void* threadPoolSession;
extern threadlocal bool threadPoolEnabled;
extern int8_t tsMemPoolFullFunc;
#define taosEnableMemPoolUsage(_session) do { threadPoolSession = _session; tsEnableRandErr = true;} while (0)
#define taosDisableMemPoolUsage() do { threadPoolSession = NULL; tsEnableRandErr = false;} while (0)
#define taosSaveDisableMemPoolUsage(_enable, _randErr) do { (_enable) = threadPoolEnabled; (_randErr) = tsEnableRandErr; threadPoolEnabled = false; tsEnableRandErr = false;} while (0)
#define taosRestoreEnableMemPoolUsage(_enable, _randErr) do { threadPoolEnabled = (_enable); tsEnableRandErr = (_randErr);} while (0)
#define taosMemoryMalloc(_size) ((threadPoolEnabled && threadPoolSession) ? (taosMemPoolMalloc(gMemPoolHandle, threadPoolSession, _size, (char*)__FILE__, __LINE__)) : (taosMemMalloc(_size)))
#define taosMemoryCalloc(_num, _size) ((threadPoolEnabled && threadPoolSession) ? (taosMemPoolCalloc(gMemPoolHandle, threadPoolSession, _num, _size, (char*)__FILE__, __LINE__)) : (taosMemCalloc(_num, _size)))
#define taosMemoryRealloc(_ptr, _size) ((threadPoolEnabled && threadPoolSession) ? (taosMemPoolRealloc(gMemPoolHandle, threadPoolSession, _ptr, _size, (char*)__FILE__, __LINE__)) : (taosMemRealloc(_ptr, _size)))
#define taosStrdup(_ptr) ((threadPoolEnabled && threadPoolSession) ? (taosMemPoolStrdup(gMemPoolHandle, threadPoolSession, _ptr, (char*)__FILE__, __LINE__)) : (taosStrdupi(_ptr)))
#define taosStrndup(_ptr, _size) ((threadPoolEnabled && threadPoolSession) ? (taosMemPoolStrndup(gMemPoolHandle, threadPoolSession, _ptr, _size, (char*)__FILE__, __LINE__)) : (taosStrndupi(_ptr, _size)))
#define taosMemoryFree(_ptr) ((threadPoolEnabled && threadPoolSession) ? (taosMemPoolFree(gMemPoolHandle, threadPoolSession, _ptr, (char*)__FILE__, __LINE__)) : (taosMemFree(_ptr)))
#define taosMemorySize(_ptr) ((threadPoolEnabled && threadPoolSession) ? (taosMemPoolGetMemorySize(gMemPoolHandle, threadPoolSession, _ptr, (char*)__FILE__, __LINE__)) : (taosMemSize(_ptr)))
#define taosMemoryTrim(_size, _trimed) ((threadPoolEnabled && threadPoolSession) ? (taosMemPoolTrim(gMemPoolHandle, threadPoolSession, _size, (char*)__FILE__, __LINE__, _trimed)) : (taosMemTrim(_size, _trimed)))
#define taosMemoryMallocAlign(_alignment, _size) ((threadPoolEnabled && threadPoolSession) ? (taosMemPoolMallocAlign(gMemPoolHandle, threadPoolSession, _alignment, _size, (char*)__FILE__, __LINE__)) : (taosMemMallocAlign(_alignment, _size)))
#else
#define taosEnableMemoryPoolUsage(_pool, _session)
#define taosDisableMemoryPoolUsage()
#define taosSaveDisableMemoryPoolUsage()
#define taosRestoreEnableMemoryPoolUsage()
#define taosMemoryMalloc(_size) taosMemMalloc(_size)
#define taosMemoryCalloc(_num, _size) taosMemCalloc(_num, _size)
#define taosMemoryRealloc(_ptr, _size) taosMemRealloc(_ptr, _size)
#define taosStrdup(_ptr) taosStrdupi(_ptr)
#define taosStrndup(_ptr, _size) taosStrndupi(_ptr, _size)
#define taosMemoryFree(_ptr) taosMemFree(_ptr)
#define taosMemorySize(_ptr) taosMemSize(_ptr)
#define taosMemoryTrim(_size, _trimed) taosMemTrim(_size, _trimed)
#define taosMemoryMallocAlign(_alignment, _size) taosMemMallocAlign(_alignment, _size)
#endif
#define taosMemoryFreeClear(ptr) \
do { \
if (ptr) { \
taosMemoryFree((void *)ptr); \
(ptr) = NULL; \
} \
} while (0)
#ifdef __cplusplus
}
#endif
#endif /*_TD_OS_MEMPOOL_H_*/

View File

@ -36,35 +36,32 @@ extern "C" {
#endif // ifndef ALLOW_FORBID_FUNC #endif // ifndef ALLOW_FORBID_FUNC
#endif // if !defined(WINDOWS) #endif // if !defined(WINDOWS)
// #define taosMemoryMalloc malloc
// #define taosMemoryCalloc calloc
// #define taosMemoryRealloc realloc
// #define taosMemoryFree free
int32_t taosMemoryDbgInit(); int32_t taosMemoryDbgInit();
int32_t taosMemoryDbgInitRestore(); int32_t taosMemoryDbgInitRestore();
void *taosMemoryMalloc(int64_t size); void *taosMemMalloc(int64_t size);
void *taosMemoryCalloc(int64_t num, int64_t size); void *taosMemCalloc(int64_t num, int64_t size);
void *taosMemoryRealloc(void *ptr, int64_t size); void *taosMemRealloc(void *ptr, int64_t size);
char *taosStrdup(const char *ptr); char *taosStrdupi(const char *ptr);
void taosMemoryFree(void *ptr); char *taosStrndupi(const char *ptr, int64_t size);
int64_t taosMemorySize(void *ptr); void taosMemFree(void *ptr);
int64_t taosMemSize(void *ptr);
void taosPrintBackTrace(); void taosPrintBackTrace();
void taosMemoryTrim(int32_t size); int32_t taosMemTrim(int32_t size, bool* trimed);
void *taosMemoryMallocAlign(uint32_t alignment, int64_t size); void *taosMemMallocAlign(uint32_t alignment, int64_t size);
#define TAOS_MEMSET(_s, _c, _n) ((void)memset(_s, _c, _n)) #define TAOS_MEMSET(_s, _c, _n) ((void)memset(_s, _c, _n))
#define TAOS_MEMCPY(_d, _s, _n) ((void)memcpy(_d, _s, _n)) #define TAOS_MEMCPY(_d, _s, _n) ((void)memcpy(_d, _s, _n))
#define TAOS_MEMMOVE(_d, _s, _n) ((void)memmove(_d, _s, _n)) #define TAOS_MEMMOVE(_d, _s, _n) ((void)memmove(_d, _s, _n))
#define taosMemoryFreeClear(ptr) \ #define taosMemFreeClear(ptr) \
do { \ do { \
if (ptr) { \ if (ptr) { \
taosMemoryFree((void *)ptr); \ taosMemFree((void *)ptr); \
(ptr) = NULL; \ (ptr) = NULL; \
} \ } \
} while (0) } while (0)
#include "osMemPool.h"
#define TAOS_MEMORY_REALLOC(ptr, len) \ #define TAOS_MEMORY_REALLOC(ptr, len) \
do { \ do { \
void *tmp = taosMemoryRealloc(ptr, (len)); \ void *tmp = taosMemoryRealloc(ptr, (len)); \

View File

@ -84,6 +84,7 @@ int64_t tsnprintf(char *dst, int64_t size, const char *format, ...);
#define TAOS_STRNCAT(_dst, _src, len) ((void)strncat(_dst, _src, len)) #define TAOS_STRNCAT(_dst, _src, len) ((void)strncat(_dst, _src, len))
char *tstrdup(const char *src); char *tstrdup(const char *src);
char *tstrndup(const char *str, int64_t size);
int32_t taosUcs4len(TdUcs4 *ucs4); int32_t taosUcs4len(TdUcs4 *ucs4);
int32_t taosStr2int64(const char *str, int64_t *val); int32_t taosStr2int64(const char *str, int64_t *val);
int32_t taosStr2int32(const char *str, int32_t *val); int32_t taosStr2int32(const char *str, int32_t *val);
@ -126,7 +127,6 @@ double taosStr2Double(const char *str, char **pEnd);
float taosStr2Float(const char *str, char **pEnd); float taosStr2Float(const char *str, char **pEnd);
int32_t taosHex2Ascii(const char *z, uint32_t n, void **data, uint32_t *size); int32_t taosHex2Ascii(const char *z, uint32_t n, void **data, uint32_t *size);
int32_t taosAscii2Hex(const char *z, uint32_t n, void **data, uint32_t *size); int32_t taosAscii2Hex(const char *z, uint32_t n, void **data, uint32_t *size);
char *taosStrndup(const char *s, int n);
// int32_t taosBin2Ascii(const char *z, uint32_t n, void** data, uint32_t* size); // int32_t taosBin2Ascii(const char *z, uint32_t n, void** data, uint32_t* size);
bool isHex(const char *z, uint32_t n); bool isHex(const char *z, uint32_t n);
bool isValidateHex(const char *z, uint32_t n); bool isValidateHex(const char *z, uint32_t n);

View File

@ -45,6 +45,7 @@ int32_t taosGetCpuInstructions(char* sse42, char* avx, char* avx2, char* fma, ch
int32_t taosGetTotalMemory(int64_t *totalKB); int32_t taosGetTotalMemory(int64_t *totalKB);
int32_t taosGetProcMemory(int64_t *usedKB); int32_t taosGetProcMemory(int64_t *usedKB);
int32_t taosGetSysMemory(int64_t *usedKB); int32_t taosGetSysMemory(int64_t *usedKB);
int32_t taosGetSysAvailMemory(int64_t *availSize);
int32_t taosGetDiskSize(char *dataDir, SDiskSize *diskSize); int32_t taosGetDiskSize(char *dataDir, SDiskSize *diskSize);
int32_t taosGetProcIODelta(int64_t *rchars, int64_t *wchars, int64_t *read_bytes, int64_t *write_bytes); int32_t taosGetProcIODelta(int64_t *rchars, int64_t *wchars, int64_t *read_bytes, int64_t *write_bytes);
void taosSetDefaultProcIODelta(int64_t *rchars, int64_t *wchars, int64_t *read_bytes, int64_t *write_bytes); void taosSetDefaultProcIODelta(int64_t *rchars, int64_t *wchars, int64_t *read_bytes, int64_t *write_bytes);

View File

@ -645,6 +645,9 @@ int32_t taosGetErrSize();
#define TSDB_CODE_QRY_FILTER_RANGE_ERROR TAOS_DEF_ERROR_CODE(0, 0x0736) #define TSDB_CODE_QRY_FILTER_RANGE_ERROR TAOS_DEF_ERROR_CODE(0, 0x0736)
#define TSDB_CODE_QRY_FILTER_INVALID_TYPE TAOS_DEF_ERROR_CODE(0, 0x0737) #define TSDB_CODE_QRY_FILTER_INVALID_TYPE TAOS_DEF_ERROR_CODE(0, 0x0737)
#define TSDB_CODE_QRY_TASK_SUCC_TO_PARTSUSS TAOS_DEF_ERROR_CODE(0, 0x0738) #define TSDB_CODE_QRY_TASK_SUCC_TO_PARTSUSS TAOS_DEF_ERROR_CODE(0, 0x0738)
#define TSDB_CODE_QRY_REACH_QMEM_THRESHOLD TAOS_DEF_ERROR_CODE(0, 0x0739)
#define TSDB_CODE_QRY_QUERY_MEM_EXHAUSTED TAOS_DEF_ERROR_CODE(0, 0x073A)
#define TSDB_CODE_QRY_NO_FETCH_TIMEOUT TAOS_DEF_ERROR_CODE(0, 0x073B)
// grant // grant
#define TSDB_CODE_GRANT_EXPIRED TAOS_DEF_ERROR_CODE(0, 0x0800) #define TSDB_CODE_GRANT_EXPIRED TAOS_DEF_ERROR_CODE(0, 0x0800)

View File

@ -136,6 +136,7 @@ void cfgUnLock(SConfig *pCfg);
// clang-format off // clang-format off
int32_t cfgAddBool(SConfig *pCfg, const char *name, bool defaultVal, int8_t scope, int8_t dynScope,int8_t category); int32_t cfgAddBool(SConfig *pCfg, const char *name, bool defaultVal, int8_t scope, int8_t dynScope,int8_t category);
int32_t cfgAddInt32(SConfig *pCfg, const char *name, int32_t defaultVal, int64_t minval, int64_t maxval, int8_t scope, int8_t dynScope,int8_t category); int32_t cfgAddInt32(SConfig *pCfg, const char *name, int32_t defaultVal, int64_t minval, int64_t maxval, int8_t scope, int8_t dynScope,int8_t category);
int32_t cfgAddInt32Ex(SConfig *pCfg, const char *name, int32_t defaultVal, int64_t minval, int64_t maxval, int8_t scope, int8_t dynScope,int8_t category);
int32_t cfgAddInt64(SConfig *pCfg, const char *name, int64_t defaultVal, int64_t minval, int64_t maxval, int8_t scope, int8_t dynScope,int8_t category); int32_t cfgAddInt64(SConfig *pCfg, const char *name, int64_t defaultVal, int64_t minval, int64_t maxval, int8_t scope, int8_t dynScope,int8_t category);
int32_t cfgAddFloat(SConfig *pCfg, const char *name, float defaultVal, float minval, float maxval, int8_t scope, int8_t dynScope,int8_t category); int32_t cfgAddFloat(SConfig *pCfg, const char *name, float defaultVal, float minval, float maxval, int8_t scope, int8_t dynScope,int8_t category);
int32_t cfgAddString(SConfig *pCfg, const char *name, const char *defaultVal, int8_t scope, int8_t dynScope,int8_t category); int32_t cfgAddString(SConfig *pCfg, const char *name, const char *defaultVal, int8_t scope, int8_t dynScope,int8_t category);

View File

@ -655,6 +655,8 @@ typedef enum {
ANAL_ALGO_TYPE_END, ANAL_ALGO_TYPE_END,
} EAnalAlgoType; } EAnalAlgoType;
#define MIN_RESERVE_MEM_SIZE 1024 // MB
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -87,6 +87,8 @@ BoundedQueue* createBoundedQueue(uint32_t maxSize, pq_comp_fn fn, FDelete delete
void taosBQSetFn(BoundedQueue* q, pq_comp_fn fn); void taosBQSetFn(BoundedQueue* q, pq_comp_fn fn);
void taosBQClear(BoundedQueue* q);
void destroyBoundedQueue(BoundedQueue* q); void destroyBoundedQueue(BoundedQueue* q);
/* /*

View File

@ -72,6 +72,7 @@ void taosInitRWLatch(SRWLatch *pLatch);
void taosWLockLatch(SRWLatch *pLatch); void taosWLockLatch(SRWLatch *pLatch);
void taosWUnLockLatch(SRWLatch *pLatch); void taosWUnLockLatch(SRWLatch *pLatch);
void taosRLockLatch(SRWLatch *pLatch); void taosRLockLatch(SRWLatch *pLatch);
int32_t taosRTryLockLatch(SRWLatch *pLatch);
void taosRUnLockLatch(SRWLatch *pLatch); void taosRUnLockLatch(SRWLatch *pLatch);
int32_t taosWTryLockLatch(SRWLatch *pLatch); int32_t taosWTryLockLatch(SRWLatch *pLatch);

View File

@ -77,6 +77,7 @@ int32_t taosInitLog(const char *logName, int32_t maxFiles, bool tsc);
void taosCloseLog(); void taosCloseLog();
void taosResetLog(); void taosResetLog();
void taosDumpData(uint8_t *msg, int32_t len); void taosDumpData(uint8_t *msg, int32_t len);
void taosSetNoNewFile();
void taosPrintLog(const char *flags, int32_t level, int32_t dflag, const char *format, ...) void taosPrintLog(const char *flags, int32_t level, int32_t dflag, const char *format, ...)
#ifdef __GNUC__ #ifdef __GNUC__

View File

@ -1,35 +0,0 @@
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _TD_UTIL_MEMPOOL_H_
#define _TD_UTIL_MEMPOOL_H_
#include "os.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef void *mpool_h;
mpool_h taosMemPoolInit(int32_t maxNum, int32_t blockSize);
char *taosMemPoolMalloc(mpool_h handle);
void taosMemPoolFree(mpool_h handle, char *p);
void taosMemPoolCleanUp(mpool_h handle);
#ifdef __cplusplus
}
#endif
#endif /*_TD_UTIL_MEMPOOL_H_*/

View File

@ -50,7 +50,7 @@ typedef struct SDiskbasedBufStatis {
* @param handle * @param handle
* @return * @return
*/ */
int32_t createDiskbasedBuf(SDiskbasedBuf** pBuf, int32_t pagesize, int32_t inMemBufSize, const char* id, int32_t createDiskbasedBuf(SDiskbasedBuf** pBuf, int32_t pagesize, int64_t inMemBufSize, const char* id,
const char* dir); const char* dir);
/** /**

View File

@ -39,6 +39,8 @@ bool taosTmrStop(tmr_h tmrId);
bool taosTmrStopA(tmr_h *tmrId); bool taosTmrStopA(tmr_h *tmrId);
bool taosTmrIsStopped(tmr_h* timerId);
bool taosTmrReset(TAOS_TMR_CALLBACK fp, int32_t mseconds, void *param, void *handle, tmr_h *pTmrId); bool taosTmrReset(TAOS_TMR_CALLBACK fp, int32_t mseconds, void *param, void *handle, tmr_h *pTmrId);
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -689,7 +689,7 @@ void doDestroyRequest(void *p) {
SRequestObj *pRequest = (SRequestObj *)p; SRequestObj *pRequest = (SRequestObj *)p;
uint64_t reqId = pRequest->requestId; uint64_t reqId = pRequest->requestId;
tscTrace("begin to destroy request %" PRIx64 " p:%p", reqId, pRequest); tscDebug("begin to destroy request 0x%" PRIx64 " p:%p", reqId, pRequest);
int64_t nextReqRefId = pRequest->relation.nextRefId; int64_t nextReqRefId = pRequest->relation.nextRefId;
@ -731,7 +731,7 @@ void doDestroyRequest(void *p) {
taosMemoryFreeClear(pRequest->effectiveUser); taosMemoryFreeClear(pRequest->effectiveUser);
taosMemoryFreeClear(pRequest->sqlstr); taosMemoryFreeClear(pRequest->sqlstr);
taosMemoryFree(pRequest); taosMemoryFree(pRequest);
tscTrace("end to destroy request %" PRIx64 " p:%p", reqId, pRequest); tscDebug("end to destroy request %" PRIx64 " p:%p", reqId, pRequest);
destroyNextReq(nextReqRefId); destroyNextReq(nextReqRefId);
} }
@ -955,7 +955,7 @@ void taos_init_imp(void) {
taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_ENTRY_LOCK); taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_ENTRY_LOCK);
if (NULL == appInfo.pInstMap || NULL == appInfo.pInstMapByClusterId) { if (NULL == appInfo.pInstMap || NULL == appInfo.pInstMapByClusterId) {
(void)printf("failed to allocate memory when init appInfo\n"); (void)printf("failed to allocate memory when init appInfo\n");
tscInitRes = TSDB_CODE_OUT_OF_MEMORY; tscInitRes = terrno;
return; return;
} }
taosHashSetFreeFp(appInfo.pInstMap, destroyAppInst); taosHashSetFreeFp(appInfo.pInstMap, destroyAppInst);

View File

@ -595,6 +595,7 @@ static int32_t hbAsyncCallBack(void *param, SDataBuf *pMsg, int32_t code) {
} }
SAppInstInfo *pInst = pAppHbMgr->pAppInstInfo; SAppInstInfo *pInst = pAppHbMgr->pAppInstInfo;
if (code != 0) { if (code != 0) {
pInst->onlineDnodes = pInst->totalDnodes ? 0 : -1; pInst->onlineDnodes = pInst->totalDnodes ? 0 : -1;
tscDebug("hb rsp error %s, update server status %d/%d", tstrerror(code), pInst->onlineDnodes, pInst->totalDnodes); tscDebug("hb rsp error %s, update server status %d/%d", tstrerror(code), pInst->onlineDnodes, pInst->totalDnodes);
@ -1338,7 +1339,6 @@ static void *hbThreadFunc(void *param) {
} }
void *buf = taosMemoryMalloc(tlen); void *buf = taosMemoryMalloc(tlen);
if (buf == NULL) { if (buf == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
tFreeClientHbBatchReq(pReq); tFreeClientHbBatchReq(pReq);
// hbClearReqInfo(pAppHbMgr); // hbClearReqInfo(pAppHbMgr);
break; break;
@ -1352,7 +1352,6 @@ static void *hbThreadFunc(void *param) {
SMsgSendInfo *pInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo)); SMsgSendInfo *pInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo));
if (pInfo == NULL) { if (pInfo == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
tFreeClientHbBatchReq(pReq); tFreeClientHbBatchReq(pReq);
// hbClearReqInfo(pAppHbMgr); // hbClearReqInfo(pAppHbMgr);
taosMemoryFree(buf); taosMemoryFree(buf);
@ -1364,7 +1363,6 @@ static void *hbThreadFunc(void *param) {
pInfo->msgType = TDMT_MND_HEARTBEAT; pInfo->msgType = TDMT_MND_HEARTBEAT;
pInfo->param = taosMemoryMalloc(sizeof(int32_t)); pInfo->param = taosMemoryMalloc(sizeof(int32_t));
if (pInfo->param == NULL) { if (pInfo->param == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
tFreeClientHbBatchReq(pReq); tFreeClientHbBatchReq(pReq);
// hbClearReqInfo(pAppHbMgr); // hbClearReqInfo(pAppHbMgr);
taosMemoryFree(buf); taosMemoryFree(buf);
@ -1372,7 +1370,7 @@ static void *hbThreadFunc(void *param) {
break; break;
} }
*(int32_t *)pInfo->param = i; *(int32_t *)pInfo->param = i;
pInfo->paramFreeFp = taosMemoryFree; pInfo->paramFreeFp = taosAutoMemoryFree;
pInfo->requestId = generateRequestId(); pInfo->requestId = generateRequestId();
pInfo->requestObjRefId = 0; pInfo->requestObjRefId = 0;
@ -1458,7 +1456,7 @@ int32_t appHbMgrInit(SAppInstInfo *pAppInstInfo, char *key, SAppHbMgr **pAppHbMg
(*pAppHbMgr)->reportBytes = 0; (*pAppHbMgr)->reportBytes = 0;
(*pAppHbMgr)->key = taosStrdup(key); (*pAppHbMgr)->key = taosStrdup(key);
if ((*pAppHbMgr)->key == NULL) { if ((*pAppHbMgr)->key == NULL) {
TSC_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); TSC_ERR_JRET(terrno);
} }
// init app info // 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); char* key = getClusterKey(user, secretEncrypt, ip, port);
if (NULL == key) { 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, tscInfo("connecting to server, numOfEps:%d inUse:%d user:%s db:%s key:%s", epSet.epSet.numOfEps, epSet.epSet.inUse,
user, db, key); user, db, key);
@ -1820,11 +1820,10 @@ int32_t doProcessMsgFromServerImpl(SRpcMsg* pMsg, SEpSet* pEpSet) {
.handleRefId = pMsg->info.refId, .handleRefId = pMsg->info.refId,
.pEpSet = pEpSet}; .pEpSet = pEpSet};
if (pMsg->code != TSDB_CODE_OUT_OF_MEMORY && pMsg->contLen > 0) { if (pMsg->contLen > 0) {
buf.pData = taosMemoryCalloc(1, pMsg->contLen); buf.pData = taosMemoryCalloc(1, pMsg->contLen);
if (buf.pData == NULL) { if (buf.pData == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; pMsg->code = terrno;
pMsg->code = TSDB_CODE_OUT_OF_MEMORY;
} else { } else {
(void)memcpy(buf.pData, pMsg->pCont, pMsg->contLen); (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)); SSyncQueryParam* param = taosMemoryCalloc(1, sizeof(SSyncQueryParam));
if (NULL == param) { if (NULL == param) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL; return NULL;
} }
int32_t code = tsem_init(&param->sem, 0, 0); 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)); SSyncQueryParam* param = taosMemoryCalloc(1, sizeof(SSyncQueryParam));
if (param == NULL) { if (param == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL; return NULL;
} }
int32_t code = tsem_init(&param->sem, 0, 0); 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)); int64_t *rid = taosMemoryCalloc(1, sizeof(int64_t));
if (NULL == rid) { if (NULL == rid) {
tscError("out of memory when taos connect to %s:%u, user:%s db:%s", ip, port, user, db); 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; return NULL;
} }
*rid = pObj->id; *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); void *pReq = taosMemoryMalloc(msgLen);
if (pReq == NULL) { if (pReq == NULL) {
fp(param, TSDB_CODE_OUT_OF_MEMORY, taos, 0, NULL); fp(param, terrno, taos, 0, NULL);
releaseTscObj(connId); releaseTscObj(connId);
return; 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)); SFetchWhiteListInfo *pParam = taosMemoryMalloc(sizeof(SFetchWhiteListInfo));
if (pParam == NULL) { if (pParam == NULL) {
fp(param, TSDB_CODE_OUT_OF_MEMORY, taos, 0, NULL); fp(param, terrno, taos, 0, NULL);
taosMemoryFree(pReq); taosMemoryFree(pReq);
releaseTscObj(connId); releaseTscObj(connId);
return; return;
@ -449,7 +448,7 @@ void taos_fetch_whitelist_a(TAOS *taos, __taos_async_whitelist_fn_t fp, void *pa
pParam->userParam = param; pParam->userParam = param;
SMsgSendInfo *pSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo)); SMsgSendInfo *pSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo));
if (pSendInfo == NULL) { if (pSendInfo == NULL) {
fp(param, TSDB_CODE_OUT_OF_MEMORY, taos, 0, NULL); fp(param, terrno, taos, 0, NULL);
taosMemoryFree(pParam); taosMemoryFree(pParam);
taosMemoryFree(pReq); taosMemoryFree(pReq);
releaseTscObj(connId); releaseTscObj(connId);

View File

@ -1348,7 +1348,7 @@ end:
destroyRequest(pRequest); destroyRequest(pRequest);
tDecoderClear(&coder); tDecoderClear(&coder);
qDestroyQuery(pQuery); qDestroyQuery(pQuery);
taosArrayDestroyP(pTagList, taosMemoryFree); taosArrayDestroyP(pTagList, NULL);
return code; return code;
} }
@ -1563,7 +1563,7 @@ static int32_t taosAlterTable(TAOS* taos, void* meta, int32_t metaLen) {
req.source = TD_REQ_FROM_TAOX; req.source = TD_REQ_FROM_TAOX;
tEncodeSize(tEncodeSVAlterTbReq, &req, tlen, code); tEncodeSize(tEncodeSVAlterTbReq, &req, tlen, code);
if (code != 0) { if (code != 0) {
code = TSDB_CODE_OUT_OF_MEMORY; code = terrno;
goto end; goto end;
} }
tlen += sizeof(SMsgHead); tlen += sizeof(SMsgHead);
@ -1577,7 +1577,7 @@ static int32_t taosAlterTable(TAOS* taos, void* meta, int32_t metaLen) {
code = tEncodeSVAlterTbReq(&coder, &req); code = tEncodeSVAlterTbReq(&coder, &req);
if (code != 0) { if (code != 0) {
tEncoderClear(&coder); tEncoderClear(&coder);
code = TSDB_CODE_OUT_OF_MEMORY; code = terrno;
goto end; goto end;
} }
tEncoderClear(&coder); tEncoderClear(&coder);

View File

@ -444,7 +444,7 @@ int32_t smlParseEndLine(SSmlHandle *info, SSmlLineInfo *elements, SSmlKv *kvTs)
} }
clearColValArraySml(info->currTableDataCtx->pValues); clearColValArraySml(info->currTableDataCtx->pValues);
taosArrayClearP(info->escapedStringList, taosMemoryFree); taosArrayClearP(info->escapedStringList, NULL);
if (unlikely(ret != TSDB_CODE_SUCCESS)) { if (unlikely(ret != TSDB_CODE_SUCCESS)) {
uError("SML:0x%" PRIx64 " %s smlBuildCol error:%d", info->id, __FUNCTION__, ret); uError("SML:0x%" PRIx64 " %s smlBuildCol error:%d", info->id, __FUNCTION__, ret);
return ret; return ret;
@ -1270,7 +1270,7 @@ void smlDestroyInfo(SSmlHandle *info) {
taosArrayDestroy(info->valueJsonArray); taosArrayDestroy(info->valueJsonArray);
taosArrayDestroyEx(info->preLineTagKV, freeSSmlKv); taosArrayDestroyEx(info->preLineTagKV, freeSSmlKv);
taosArrayDestroyP(info->escapedStringList, taosMemoryFree); taosArrayDestroyP(info->escapedStringList, NULL);
if (!info->dataFormat) { if (!info->dataFormat) {
for (int i = 0; i < info->lineNum; i++) { for (int i = 0; i < info->lineNum; i++) {
@ -1536,7 +1536,7 @@ int32_t smlClearForRerun(SSmlHandle *info) {
SML_CHECK_NULL(info->lines); SML_CHECK_NULL(info->lines);
} }
taosArrayClearP(info->escapedStringList, taosMemoryFree); taosArrayClearP(info->escapedStringList, NULL);
if(info->protocol == TSDB_SML_JSON_PROTOCOL) { if(info->protocol == TSDB_SML_JSON_PROTOCOL) {
taosMemoryFreeClear(info->preLine.tags); taosMemoryFreeClear(info->preLine.tags);
} }

View File

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

View File

@ -275,7 +275,7 @@ static int32_t stmtParseSql(STscStmt2* pStmt) {
STableDataCxt** pSrc = STableDataCxt** pSrc =
(STableDataCxt**)taosHashGet(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName)); (STableDataCxt**)taosHashGet(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName));
if (NULL == pSrc || NULL == *pSrc) { if (NULL == pSrc || NULL == *pSrc) {
return TSDB_CODE_OUT_OF_MEMORY; return terrno;
} }
STableDataCxt* pTableCtx = *pSrc; STableDataCxt* pTableCtx = *pSrc;
@ -295,7 +295,7 @@ static int32_t stmtParseSql(STscStmt2* pStmt) {
if (NULL == pStmt->sql.pBindInfo) { if (NULL == pStmt->sql.pBindInfo) {
pStmt->sql.pBindInfo = taosMemoryMalloc(pTableCtx->boundColsInfo.numOfBound * sizeof(*pStmt->sql.pBindInfo)); pStmt->sql.pBindInfo = taosMemoryMalloc(pTableCtx->boundColsInfo.numOfBound * sizeof(*pStmt->sql.pBindInfo));
if (NULL == 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, if (taosHashPut(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName), &pNewBlock,
POINTER_BYTES)) { POINTER_BYTES)) {
STMT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); STMT_ERR_RET(terrno);
} }
pStmt->exec.pCurrBlock = pNewBlock; 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, if (taosHashPut(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName), &pNewBlock,
POINTER_BYTES)) { POINTER_BYTES)) {
STMT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); STMT_ERR_RET(terrno);
} }
pStmt->exec.pCurrBlock = pNewBlock; pStmt->exec.pCurrBlock = pNewBlock;
@ -766,13 +766,11 @@ TAOS_STMT2* stmtInit2(STscObj* taos, TAOS_STMT2_OPTION* pOptions) {
pStmt = taosMemoryCalloc(1, sizeof(STscStmt2)); pStmt = taosMemoryCalloc(1, sizeof(STscStmt2));
if (NULL == pStmt) { if (NULL == pStmt) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL; return NULL;
} }
pStmt->sql.pTableCache = taosHashInit(100, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK); pStmt->sql.pTableCache = taosHashInit(100, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
if (NULL == pStmt->sql.pTableCache) { if (NULL == pStmt->sql.pTableCache) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
taosMemoryFree(pStmt); taosMemoryFree(pStmt);
return NULL; 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.mgmtEpSet = getEpSet_s(&pStmt->taos->pAppInfo->mgmtEp);
pStmt->sql.siInfo.pTableHash = tSimpleHashInit(100, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY)); pStmt->sql.siInfo.pTableHash = tSimpleHashInit(100, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY));
if (NULL == pStmt->sql.siInfo.pTableHash) { if (NULL == pStmt->sql.siInfo.pTableHash) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
(void)stmtClose(pStmt); (void)stmtClose(pStmt);
return NULL; return NULL;
} }
@ -894,7 +891,7 @@ int stmtPrepare2(TAOS_STMT2* stmt, const char* sql, unsigned long length) {
static int32_t stmtInitStbInterlaceTableInfo(STscStmt2* pStmt) { static int32_t stmtInitStbInterlaceTableInfo(STscStmt2* pStmt) {
STableDataCxt** pSrc = taosHashGet(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName)); STableDataCxt** pSrc = taosHashGet(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName));
if (!pSrc) { if (!pSrc) {
return TSDB_CODE_OUT_OF_MEMORY; return terrno;
} }
STableDataCxt* pDst = NULL; 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)); STableDataCxt** pSrc = taosHashGet(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName));
if (!pSrc) { if (!pSrc) {
return TSDB_CODE_OUT_OF_MEMORY; return terrno;
} }
STableDataCxt* pDst = NULL; STableDataCxt* pDst = NULL;
@ -1266,7 +1263,7 @@ static int32_t stmtBackupQueryFields(STscStmt2* pStmt) {
pRes->fields = taosMemoryMalloc(size); pRes->fields = taosMemoryMalloc(size);
pRes->userFields = taosMemoryMalloc(size); pRes->userFields = taosMemoryMalloc(size);
if (NULL == pRes->fields || NULL == pRes->userFields) { 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->fields, pStmt->exec.pRequest->body.resInfo.fields, size);
(void)memcpy(pRes->userFields, pStmt->exec.pRequest->body.resInfo.userFields, 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) { if (NULL == pStmt->exec.pRequest->body.resInfo.fields) {
pStmt->exec.pRequest->body.resInfo.fields = taosMemoryMalloc(size); pStmt->exec.pRequest->body.resInfo.fields = taosMemoryMalloc(size);
if (NULL == pStmt->exec.pRequest->body.resInfo.fields) { 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); (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) { if (NULL == pStmt->exec.pRequest->body.resInfo.userFields) {
pStmt->exec.pRequest->body.resInfo.userFields = taosMemoryMalloc(size); pStmt->exec.pRequest->body.resInfo.userFields = taosMemoryMalloc(size);
if (NULL == pStmt->exec.pRequest->body.resInfo.userFields) { 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); (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)); \ tDecoderInit(&decoder, POINTER_SHIFT(pMsg->pData, sizeof(SMqRspHead)), pMsg->len - sizeof(SMqRspHead)); \
if (FUNC(&decoder, DATA) < 0) { \ if (FUNC(&decoder, DATA) < 0) { \
tDecoderClear(&decoder); \ tDecoderClear(&decoder); \
code = TSDB_CODE_OUT_OF_MEMORY; \ code = terrno; \
goto END;\ goto END;\
}\ }\
tDecoderClear(&decoder);\ tDecoderClear(&decoder);\
@ -534,7 +534,7 @@ int32_t tmq_list_append(tmq_list_t* list, const char* src) {
void tmq_list_destroy(tmq_list_t* list) { void tmq_list_destroy(tmq_list_t* list) {
if (list == NULL) return; if (list == NULL) return;
SArray* container = &list->container; SArray* container = &list->container;
taosArrayDestroyP(container, taosMemoryFree); taosArrayDestroyP(container, NULL);
} }
int32_t tmq_list_get_size(const tmq_list_t* list) { int32_t tmq_list_get_size(const tmq_list_t* list) {
@ -659,7 +659,7 @@ static int32_t doSendCommitMsg(tmq_t* tmq, int32_t vgId, SEpSet* epSet, STqOffse
pMsgSendInfo->requestId = generateRequestId(); pMsgSendInfo->requestId = generateRequestId();
pMsgSendInfo->requestObjRefId = 0; pMsgSendInfo->requestObjRefId = 0;
pMsgSendInfo->param = pParam; pMsgSendInfo->param = pParam;
pMsgSendInfo->paramFreeFp = taosMemoryFree; pMsgSendInfo->paramFreeFp = taosAutoMemoryFree;
pMsgSendInfo->fp = tmqCommitCb; pMsgSendInfo->fp = tmqCommitCb;
pMsgSendInfo->msgType = TDMT_VND_TMQ_COMMIT_OFFSET; pMsgSendInfo->msgType = TDMT_VND_TMQ_COMMIT_OFFSET;
@ -1385,7 +1385,7 @@ static int32_t askEp(tmq_t* pTmq, void* param, bool sync, bool updateEpSet) {
sendInfo->requestId = generateRequestId(); sendInfo->requestId = generateRequestId();
sendInfo->requestObjRefId = 0; sendInfo->requestObjRefId = 0;
sendInfo->param = pParam; sendInfo->param = pParam;
sendInfo->paramFreeFp = taosMemoryFree; sendInfo->paramFreeFp = taosAutoMemoryFree;
sendInfo->fp = askEpCb; sendInfo->fp = askEpCb;
sendInfo->msgType = TDMT_MND_TMQ_ASK_EP; sendInfo->msgType = TDMT_MND_TMQ_ASK_EP;
@ -1552,7 +1552,7 @@ static void tmqMgmtInit(void) {
tmqMgmt.timer = taosTmrInit(1000, 100, 360000, "TMQ"); tmqMgmt.timer = taosTmrInit(1000, 100, 360000, "TMQ");
if (tmqMgmt.timer == NULL) { if (tmqMgmt.timer == NULL) {
tmqInitRes = TSDB_CODE_OUT_OF_MEMORY; tmqInitRes = terrno;
} }
tmqMgmt.rsetId = taosOpenRef(10000, tmqFreeImpl); tmqMgmt.rsetId = taosOpenRef(10000, tmqFreeImpl);
@ -1886,7 +1886,7 @@ int32_t tmq_subscribe(tmq_t* tmq, const tmq_list_t* topic_list) {
} }
END: END:
taosArrayDestroyP(req.topicNames, taosMemoryFree); taosArrayDestroyP(req.topicNames, NULL);
return code; return code;
} }
@ -2177,7 +2177,7 @@ static int32_t doTmqPollImpl(tmq_t* pTmq, SMqClientTopic* pTopic, SMqClientVg* p
sendInfo->requestId = req.reqId; sendInfo->requestId = req.reqId;
sendInfo->requestObjRefId = 0; sendInfo->requestObjRefId = 0;
sendInfo->param = pParam; sendInfo->param = pParam;
sendInfo->paramFreeFp = taosMemoryFree; sendInfo->paramFreeFp = taosAutoMemoryFree;
sendInfo->fp = tmqPollCb; sendInfo->fp = tmqPollCb;
sendInfo->msgType = TDMT_VND_TMQ_CONSUME; sendInfo->msgType = TDMT_VND_TMQ_CONSUME;
@ -2520,7 +2520,7 @@ int32_t tmq_unsubscribe(tmq_t* tmq) {
tmq_list_t* lst = tmq_list_new(); tmq_list_t* lst = tmq_list_new();
if (lst == NULL) { if (lst == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY; code = terrno;
goto END; goto END;
} }
code = tmq_subscribe(tmq, lst); 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"); tqErrorC("failed to allocate memory for sync commit");
return terrno; 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"); tqErrorC("failed to init sem for sync commit");
taosMemoryFree(pInfo); taosMemoryFree(pInfo);
return TSDB_CODE_OUT_OF_MEMORY; return code;
} }
pInfo->code = 0; pInfo->code = 0;
@ -2778,9 +2780,10 @@ int32_t tmq_commit_offset_sync(tmq_t* tmq, const char* pTopicName, int32_t vgId,
return terrno; return terrno;
} }
if (tsem2_init(&pInfo->sem, 0, 0) != 0) { code = tsem2_init(&pInfo->sem, 0, 0);
if (code != 0) {
taosMemoryFree(pInfo); taosMemoryFree(pInfo);
return TSDB_CODE_OUT_OF_MEMORY; return code;
} }
pInfo->code = 0; pInfo->code = 0;
@ -2847,6 +2850,7 @@ end:
} }
} }
int32_t tmqGetNextResInfo(TAOS_RES* res, bool convertUcs4, SReqResultInfo** pResInfo) { int32_t tmqGetNextResInfo(TAOS_RES* res, bool convertUcs4, SReqResultInfo** pResInfo) {
SMqRspObj* pRspObj = (SMqRspObj*)res; SMqRspObj* pRspObj = (SMqRspObj*)res;
SMqDataRsp* data = &pRspObj->dataRsp; SMqDataRsp* data = &pRspObj->dataRsp;
@ -2966,9 +2970,10 @@ static int32_t tmCommittedCb(void* param, SDataBuf* pMsg, int32_t code) {
if (pMsg) { if (pMsg) {
SDecoder decoder = {0}; SDecoder decoder = {0};
tDecoderInit(&decoder, (uint8_t*)pMsg->pData, pMsg->len); 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); tOffsetDestroy(&pParam->vgOffset.offset);
code = TSDB_CODE_OUT_OF_MEMORY; code = err;
goto end; goto end;
} }
tDecoderClear(&decoder); tDecoderClear(&decoder);
@ -3261,8 +3266,9 @@ int32_t tmq_get_topic_assignment(tmq_t* tmq, const char* pTopicName, tmq_topic_a
code = terrno; code = terrno;
goto end; 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; goto end;
} }
(void)taosThreadMutexInit(&pCommon->mutex, 0); (void)taosThreadMutexInit(&pCommon->mutex, 0);
@ -3296,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); int32_t msgSize = tSerializeSMqPollReq(NULL, 0, &req);
if (msgSize < 0) { if (msgSize < 0) {
taosMemoryFree(pParam); taosMemoryFree(pParam);
code = TSDB_CODE_OUT_OF_MEMORY; code = msgSize;
goto end; goto end;
} }
@ -3307,10 +3313,11 @@ int32_t tmq_get_topic_assignment(tmq_t* tmq, const char* pTopicName, tmq_topic_a
goto end; goto end;
} }
if (tSerializeSMqPollReq(msg, msgSize, &req) < 0) { msgSize = tSerializeSMqPollReq(msg, msgSize, &req);
if (msgSize < 0) {
taosMemoryFree(msg); taosMemoryFree(msg);
taosMemoryFree(pParam); taosMemoryFree(pParam);
code = TSDB_CODE_OUT_OF_MEMORY; code = msgSize;
goto end; goto end;
} }
@ -3326,7 +3333,7 @@ int32_t tmq_get_topic_assignment(tmq_t* tmq, const char* pTopicName, tmq_topic_a
sendInfo->requestId = req.reqId; sendInfo->requestId = req.reqId;
sendInfo->requestObjRefId = 0; sendInfo->requestObjRefId = 0;
sendInfo->param = pParam; sendInfo->param = pParam;
sendInfo->paramFreeFp = taosMemoryFree; sendInfo->paramFreeFp = taosAutoMemoryFree;
sendInfo->fp = tmqGetWalInfoCb; sendInfo->fp = tmqGetWalInfoCb;
sendInfo->msgType = TDMT_VND_TMQ_VG_WALINFO; sendInfo->msgType = TDMT_VND_TMQ_VG_WALINFO;

View File

@ -403,7 +403,7 @@ _exit:
} }
void tCleanupStreamDispatchReq(SStreamDispatchReq* pReq) { void tCleanupStreamDispatchReq(SStreamDispatchReq* pReq) {
taosArrayDestroyP(pReq->data, taosMemoryFree); taosArrayDestroyP(pReq->data, NULL);
taosArrayDestroy(pReq->dataLen); taosArrayDestroy(pReq->dataLen);
} }

View File

@ -9393,7 +9393,7 @@ int32_t tSerializeSSchedulerHbReq(void *buf, int32_t bufLen, SSchedulerHbReq *pR
tEncoderInit(&encoder, buf, bufLen); tEncoderInit(&encoder, buf, bufLen);
TAOS_CHECK_EXIT(tStartEncode(&encoder)); TAOS_CHECK_EXIT(tStartEncode(&encoder));
TAOS_CHECK_EXIT(tEncodeU64(&encoder, pReq->sId)); TAOS_CHECK_EXIT(tEncodeU64(&encoder, pReq->clientId));
TAOS_CHECK_EXIT(tEncodeI32(&encoder, pReq->epId.nodeId)); TAOS_CHECK_EXIT(tEncodeI32(&encoder, pReq->epId.nodeId));
TAOS_CHECK_EXIT(tEncodeU16(&encoder, pReq->epId.ep.port)); TAOS_CHECK_EXIT(tEncodeU16(&encoder, pReq->epId.ep.port));
TAOS_CHECK_EXIT(tEncodeCStr(&encoder, pReq->epId.ep.fqdn)); TAOS_CHECK_EXIT(tEncodeCStr(&encoder, pReq->epId.ep.fqdn));
@ -9440,7 +9440,7 @@ int32_t tDeserializeSSchedulerHbReq(void *buf, int32_t bufLen, SSchedulerHbReq *
tDecoderInit(&decoder, (char *)buf + headLen, bufLen - headLen); tDecoderInit(&decoder, (char *)buf + headLen, bufLen - headLen);
TAOS_CHECK_EXIT(tStartDecode(&decoder)); TAOS_CHECK_EXIT(tStartDecode(&decoder));
TAOS_CHECK_EXIT(tDecodeU64(&decoder, &pReq->sId)); TAOS_CHECK_EXIT(tDecodeU64(&decoder, &pReq->clientId));
TAOS_CHECK_EXIT(tDecodeI32(&decoder, &pReq->epId.nodeId)); TAOS_CHECK_EXIT(tDecodeI32(&decoder, &pReq->epId.nodeId));
TAOS_CHECK_EXIT(tDecodeU16(&decoder, &pReq->epId.ep.port)); TAOS_CHECK_EXIT(tDecodeU16(&decoder, &pReq->epId.ep.port));
TAOS_CHECK_EXIT(tDecodeCStrTo(&decoder, pReq->epId.ep.fqdn)); TAOS_CHECK_EXIT(tDecodeCStrTo(&decoder, pReq->epId.ep.fqdn));
@ -11350,11 +11350,11 @@ int32_t tDecodeMqDataRsp(SDecoder *pDecoder, SMqDataRsp *pRsp) {
static void tDeleteMqDataRspCommon(SMqDataRsp *pRsp) { static void tDeleteMqDataRspCommon(SMqDataRsp *pRsp) {
taosArrayDestroy(pRsp->blockDataLen); taosArrayDestroy(pRsp->blockDataLen);
pRsp->blockDataLen = NULL; pRsp->blockDataLen = NULL;
taosArrayDestroyP(pRsp->blockData, (FDelete)taosMemoryFree); taosArrayDestroyP(pRsp->blockData, NULL);
pRsp->blockData = NULL; pRsp->blockData = NULL;
taosArrayDestroyP(pRsp->blockSchema, (FDelete)tDeleteSchemaWrapper); taosArrayDestroyP(pRsp->blockSchema, (FDelete)tDeleteSchemaWrapper);
pRsp->blockSchema = NULL; pRsp->blockSchema = NULL;
taosArrayDestroyP(pRsp->blockTbName, (FDelete)taosMemoryFree); taosArrayDestroyP(pRsp->blockTbName, NULL);
pRsp->blockTbName = NULL; pRsp->blockTbName = NULL;
tOffsetDestroy(&pRsp->reqOffset); tOffsetDestroy(&pRsp->reqOffset);
tOffsetDestroy(&pRsp->rspOffset); tOffsetDestroy(&pRsp->rspOffset);
@ -11416,7 +11416,7 @@ void tDeleteSTaosxRsp(SMqDataRsp *pRsp) {
taosArrayDestroy(pRsp->createTableLen); taosArrayDestroy(pRsp->createTableLen);
pRsp->createTableLen = NULL; pRsp->createTableLen = NULL;
taosArrayDestroyP(pRsp->createTableReq, (FDelete)taosMemoryFree); taosArrayDestroyP(pRsp->createTableReq, NULL);
pRsp->createTableReq = NULL; pRsp->createTableReq = NULL;
} }
@ -12975,7 +12975,7 @@ _exit:
void tDeleteMqBatchMetaRsp(SMqBatchMetaRsp *pRsp) { void tDeleteMqBatchMetaRsp(SMqBatchMetaRsp *pRsp) {
taosMemoryFreeClear(pRsp->pMetaBuff); taosMemoryFreeClear(pRsp->pMetaBuff);
taosArrayDestroyP(pRsp->batchMetaReq, taosMemoryFree); taosArrayDestroyP(pRsp->batchMetaReq, NULL);
taosArrayDestroy(pRsp->batchMetaLen); taosArrayDestroy(pRsp->batchMetaLen);
pRsp->batchMetaReq = NULL; pRsp->batchMetaReq = NULL;
pRsp->batchMetaLen = NULL; pRsp->batchMetaLen = NULL;

View File

@ -63,13 +63,28 @@ char tsEncryptKey[17] = {0};
int32_t tsMaxShellConns = 50000; int32_t tsMaxShellConns = 50000;
int32_t tsShellActivityTimer = 3; // second int32_t tsShellActivityTimer = 3; // second
// memory pool
int8_t tsMemPoolFullFunc = 0;
int8_t tsQueryUseMemoryPool = 1;
int32_t tsQueryBufferPoolSize = 0; // MB
int32_t tsSingleQueryMaxMemorySize = 0; // MB
int32_t tsMinReservedMemorySize = 0; // MB
int64_t tsCurrentAvailMemorySize = 0;
int8_t tsNeedTrim = 0;
// queue & threads // queue & threads
int32_t tsQueryMinConcurrentTaskNum = 1;
int32_t tsQueryMaxConcurrentTaskNum = 0;
int32_t tsQueryConcurrentTaskNum = 0;
int32_t tsQueryNoFetchTimeoutSec = 3600 * 5;
int32_t tsNumOfRpcThreads = 1; int32_t tsNumOfRpcThreads = 1;
int32_t tsNumOfRpcSessions = 30000; int32_t tsNumOfRpcSessions = 30000;
int32_t tsShareConnLimit = 10; int32_t tsShareConnLimit = 10;
int32_t tsReadTimeout = 900; int32_t tsReadTimeout = 900;
int32_t tsTimeToGetAvailableConn = 500000; int32_t tsTimeToGetAvailableConn = 500000;
int32_t tsNumOfQueryThreads = 0;
int32_t tsNumOfCommitThreads = 2; int32_t tsNumOfCommitThreads = 2;
int32_t tsNumOfTaskQueueThreads = 16; int32_t tsNumOfTaskQueueThreads = 16;
int32_t tsNumOfMnodeQueryThreads = 16; int32_t tsNumOfMnodeQueryThreads = 16;
@ -802,6 +817,12 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "queryRspPolicy", tsQueryRspPolicy, 0, 1, CFG_SCOPE_SERVER, CFG_DYN_SERVER,CFG_CATEGORY_GLOBAL)); TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "queryRspPolicy", tsQueryRspPolicy, 0, 1, CFG_SCOPE_SERVER, CFG_DYN_SERVER,CFG_CATEGORY_GLOBAL));
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "numOfCommitThreads", tsNumOfCommitThreads, 1, 1024, CFG_SCOPE_SERVER, CFG_DYN_SERVER_LAZY,CFG_CATEGORY_LOCAL)); TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "numOfCommitThreads", tsNumOfCommitThreads, 1, 1024, CFG_SCOPE_SERVER, CFG_DYN_SERVER_LAZY,CFG_CATEGORY_LOCAL));
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "retentionSpeedLimitMB", tsRetentionSpeedLimitMB, 0, 1024, CFG_SCOPE_SERVER, CFG_DYN_SERVER,CFG_CATEGORY_GLOBAL)); TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "retentionSpeedLimitMB", tsRetentionSpeedLimitMB, 0, 1024, CFG_SCOPE_SERVER, CFG_DYN_SERVER,CFG_CATEGORY_GLOBAL));
TAOS_CHECK_RETURN(cfgAddBool(pCfg, "queryUseMemoryPool", tsQueryUseMemoryPool, CFG_SCOPE_SERVER, CFG_DYN_NONE,CFG_CATEGORY_LOCAL) != 0);
TAOS_CHECK_RETURN(cfgAddBool(pCfg, "memPoolFullFunc", tsMemPoolFullFunc, CFG_SCOPE_SERVER, CFG_DYN_NONE,CFG_CATEGORY_LOCAL) != 0);
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "singleQueryMaxMemorySize", tsSingleQueryMaxMemorySize, 0, 1000000000, CFG_SCOPE_SERVER, CFG_DYN_NONE,CFG_CATEGORY_LOCAL) != 0);
//TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "queryBufferPoolSize", tsQueryBufferPoolSize, 0, 1000000000, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER) != 0);
TAOS_CHECK_RETURN(cfgAddInt32Ex(pCfg, "minReservedMemorySize", 0, 1024, 1000000000, CFG_SCOPE_SERVER, CFG_DYN_NONE,CFG_CATEGORY_LOCAL) != 0);
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "queryNoFetchTimeoutSec", tsQueryNoFetchTimeoutSec, 60, 1000000000, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER,CFG_CATEGORY_LOCAL) != 0);
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "numOfMnodeReadThreads", tsNumOfMnodeReadThreads, 1, 1024, CFG_SCOPE_SERVER, CFG_DYN_SERVER_LAZY,CFG_CATEGORY_LOCAL)); TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "numOfMnodeReadThreads", tsNumOfMnodeReadThreads, 1, 1024, CFG_SCOPE_SERVER, CFG_DYN_SERVER_LAZY,CFG_CATEGORY_LOCAL));
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "numOfVnodeQueryThreads", tsNumOfVnodeQueryThreads, 1, 1024, CFG_SCOPE_SERVER, CFG_DYN_SERVER_LAZY,CFG_CATEGORY_LOCAL)); TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "numOfVnodeQueryThreads", tsNumOfVnodeQueryThreads, 1, 1024, CFG_SCOPE_SERVER, CFG_DYN_SERVER_LAZY,CFG_CATEGORY_LOCAL));
@ -1764,6 +1785,21 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "experimental"); TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "experimental");
tsExperimental = pItem->bval; tsExperimental = pItem->bval;
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "queryUseMemoryPool");
tsQueryUseMemoryPool = pItem->bval;
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "memPoolFullFunc");
tsMemPoolFullFunc = pItem->bval;
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "singleQueryMaxMemorySize");
tsSingleQueryMaxMemorySize = pItem->i32;
// TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "queryBufferPoolSize");
// tsQueryBufferPoolSize = pItem->i32;
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "minReservedMemorySize");
tsMinReservedMemorySize = pItem->i32;
// GRANT_CFG_GET; // GRANT_CFG_GET;
TAOS_RETURN(TSDB_CODE_SUCCESS); TAOS_RETURN(TSDB_CODE_SUCCESS);
} }
@ -2404,7 +2440,8 @@ static int32_t taosCfgDynamicOptionsForServer(SConfig *pCfg, const char *name) {
{"bypassFlag", &tsBypassFlag}, {"bypassFlag", &tsBypassFlag},
{"arbHeartBeatIntervalSec", &tsArbHeartBeatIntervalSec}, {"arbHeartBeatIntervalSec", &tsArbHeartBeatIntervalSec},
{"arbCheckSyncIntervalSec", &tsArbCheckSyncIntervalSec}, {"arbCheckSyncIntervalSec", &tsArbCheckSyncIntervalSec},
{"arbSetAssignedTimeoutSec", &tsArbSetAssignedTimeoutSec}}; {"arbSetAssignedTimeoutSec", &tsArbSetAssignedTimeoutSec},
{"queryNoFetchTimeoutSec", &tsQueryNoFetchTimeoutSec}};
if ((code = taosCfgSetOption(debugOptions, tListLen(debugOptions), pItem, true)) != TSDB_CODE_SUCCESS) { if ((code = taosCfgSetOption(debugOptions, tListLen(debugOptions), pItem, true)) != TSDB_CODE_SUCCESS) {
code = taosCfgSetOption(options, tListLen(options), pItem, false); code = taosCfgSetOption(options, tListLen(options), pItem, false);

View File

@ -26,6 +26,7 @@
#endif #endif
#include "dmUtil.h" #include "dmUtil.h"
#include "tcs.h" #include "tcs.h"
#include "qworker.h"
#if defined(CUS_NAME) || defined(CUS_PROMPT) || defined(CUS_EMAIL) #if defined(CUS_NAME) || defined(CUS_PROMPT) || defined(CUS_EMAIL)
#include "cus_name.h" #include "cus_name.h"
@ -477,6 +478,13 @@ int mainWindows(int argc, char **argv) {
taosCleanupArgs(); taosCleanupArgs();
return code; return code;
} }
if ((code = taosMemoryPoolInit(qWorkerRetireJobs, qWorkerRetireJob)) != 0) {
dError("failed to init memPool, error:0x%x", code);
taosCloseLog();
taosCleanupArgs();
return code;
}
if ((tsCharsetCxt = taosConvInit(tsCharset)) == NULL) { if ((tsCharsetCxt = taosConvInit(tsCharset)) == NULL) {
dError("failed to init conv"); dError("failed to init conv");

View File

@ -221,9 +221,12 @@ static void *dmMonitorThreadFp(void *param) {
trimCount = (trimCount + 1) % TRIM_FREQ; trimCount = (trimCount + 1) % TRIM_FREQ;
if (trimCount == 0) { if (trimCount == 0) {
taosMemoryTrim(0); taosMemoryTrim(0, NULL);
} }
} }
if (atomic_val_compare_exchange_8(&tsNeedTrim, 1, 0)) {
taosMemoryTrim(0, NULL);
}
} }
return NULL; return NULL;

View File

@ -220,6 +220,8 @@ int32_t mmStartWorker(SMnodeMgmt *pMgmt) {
return code; return code;
} }
tsNumOfQueryThreads += tsNumOfMnodeQueryThreads;
SSingleWorkerCfg fCfg = { SSingleWorkerCfg fCfg = {
.min = tsNumOfMnodeFetchThreads, .min = tsNumOfMnodeFetchThreads,
.max = tsNumOfMnodeFetchThreads, .max = tsNumOfMnodeFetchThreads,

View File

@ -104,8 +104,8 @@ int32_t qmStartWorker(SQnodeMgmt *pMgmt) {
int32_t code = 0; int32_t code = 0;
SSingleWorkerCfg queryCfg = { SSingleWorkerCfg queryCfg = {
.min = tsNumOfVnodeQueryThreads, .min = tsNumOfQnodeQueryThreads,
.max = tsNumOfVnodeQueryThreads, .max = tsNumOfQnodeQueryThreads,
.name = "qnode-query", .name = "qnode-query",
.fp = (FItem)qmProcessQueue, .fp = (FItem)qmProcessQueue,
.param = pMgmt, .param = pMgmt,
@ -117,6 +117,8 @@ int32_t qmStartWorker(SQnodeMgmt *pMgmt) {
return code; return code;
} }
tsNumOfQueryThreads += tsNumOfQnodeQueryThreads;
SSingleWorkerCfg fetchCfg = { SSingleWorkerCfg fetchCfg = {
.min = tsNumOfQnodeFetchThreads, .min = tsNumOfQnodeFetchThreads,
.max = tsNumOfQnodeFetchThreads, .max = tsNumOfQnodeFetchThreads,

View File

@ -456,6 +456,8 @@ int32_t vmStartWorker(SVnodeMgmt *pMgmt) {
pQPool->max = tsNumOfVnodeQueryThreads; pQPool->max = tsNumOfVnodeQueryThreads;
if ((code = tQueryAutoQWorkerInit(pQPool)) != 0) return code; if ((code = tQueryAutoQWorkerInit(pQPool)) != 0) return code;
tsNumOfQueryThreads += tsNumOfVnodeQueryThreads;
SAutoQWorkerPool *pStreamPool = &pMgmt->streamPool; SAutoQWorkerPool *pStreamPool = &pMgmt->streamPool;
pStreamPool->name = "vnode-stream"; pStreamPool->name = "vnode-stream";
pStreamPool->ratio = tsRatioOfVnodeStreamThreads; pStreamPool->ratio = tsRatioOfVnodeStreamThreads;

View File

@ -220,6 +220,7 @@ void dmCleanup() {
dInfo("dnode env is cleaned up"); dInfo("dnode env is cleaned up");
taosMemPoolClose(gMemPoolHandle);
taosCleanupCfg(); taosCleanupCfg();
taosCloseLog(); taosCloseLog();
} }

View File

@ -368,7 +368,9 @@ static inline int32_t dmSendSyncReq(const SEpSet *pEpSet, SRpcMsg *pMsg) {
static inline void dmRegisterBrokenLinkArg(SRpcMsg *pMsg) { (void)rpcRegisterBrokenLinkArg(pMsg); } static inline void dmRegisterBrokenLinkArg(SRpcMsg *pMsg) { (void)rpcRegisterBrokenLinkArg(pMsg); }
static inline void dmReleaseHandle(SRpcHandleInfo *pHandle, int8_t type) { (void)rpcReleaseHandle(pHandle, type); } static inline void dmReleaseHandle(SRpcHandleInfo *pHandle, int8_t type, int32_t status) {
(void)rpcReleaseHandle(pHandle, type, status);
}
static bool rpcRfp(int32_t code, tmsg_t msgType) { static bool rpcRfp(int32_t code, tmsg_t msgType) {
if (code == TSDB_CODE_RPC_NETWORK_UNAVAIL || code == TSDB_CODE_RPC_BROKEN_LINK || code == TSDB_CODE_MNODE_NOT_FOUND || if (code == TSDB_CODE_RPC_NETWORK_UNAVAIL || code == TSDB_CODE_RPC_BROKEN_LINK || code == TSDB_CODE_MNODE_NOT_FOUND ||

View File

@ -614,7 +614,7 @@ int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) {
END: END:
mndTransDrop(pTrans); mndTransDrop(pTrans);
tDeleteSMqConsumerObj(pConsumerNew); tDeleteSMqConsumerObj(pConsumerNew);
taosArrayDestroyP(subscribe.topicNames, (FDelete)taosMemoryFree); taosArrayDestroyP(subscribe.topicNames, NULL);
return (code == TSDB_CODE_TMQ_NO_NEED_REBALANCE || code == TSDB_CODE_MND_CONSUMER_NOT_EXIST) ? 0 : code; return (code == TSDB_CODE_TMQ_NO_NEED_REBALANCE || code == TSDB_CODE_MND_CONSUMER_NOT_EXIST) ? 0 : code;
} }

View File

@ -351,10 +351,10 @@ END:
void tClearSMqConsumerObj(SMqConsumerObj *pConsumer) { void tClearSMqConsumerObj(SMqConsumerObj *pConsumer) {
if (pConsumer == NULL) return; if (pConsumer == NULL) return;
taosArrayDestroyP(pConsumer->currentTopics, (FDelete)taosMemoryFree); taosArrayDestroyP(pConsumer->currentTopics, NULL);
taosArrayDestroyP(pConsumer->rebNewTopics, (FDelete)taosMemoryFree); taosArrayDestroyP(pConsumer->rebNewTopics, NULL);
taosArrayDestroyP(pConsumer->rebRemovedTopics, (FDelete)taosMemoryFree); taosArrayDestroyP(pConsumer->rebRemovedTopics, NULL);
taosArrayDestroyP(pConsumer->assignedTopics, (FDelete)taosMemoryFree); taosArrayDestroyP(pConsumer->assignedTopics, NULL);
} }
void tDeleteSMqConsumerObj(SMqConsumerObj *pConsumer) { void tDeleteSMqConsumerObj(SMqConsumerObj *pConsumer) {

View File

@ -627,9 +627,12 @@ static void *mndBuildVDropStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pStb,
void *pBuf = POINTER_SHIFT(pHead, sizeof(SMsgHead)); void *pBuf = POINTER_SHIFT(pHead, sizeof(SMsgHead));
tEncoderInit(&encoder, pBuf, contLen - sizeof(SMsgHead)); tEncoderInit(&encoder, pBuf, contLen - sizeof(SMsgHead));
terrno = tEncodeSVDropStbReq(&encoder, &req); int32_t code = tEncodeSVDropStbReq(&encoder, &req);
tEncoderClear(&encoder); tEncoderClear(&encoder);
if (terrno != 0) return NULL; if (code != 0) {
terrno = code;
return NULL;
}
*pContLen = contLen; *pContLen = contLen;
return pHead; return pHead;

View File

@ -213,7 +213,7 @@ int32_t ipWhiteMgtUpdate(SMnode *pMnode, char *user, SIpWhiteList *pNew) {
_OVER: _OVER:
(void)taosThreadRwlockUnlock(&ipWhiteMgt.rw); (void)taosThreadRwlockUnlock(&ipWhiteMgt.rw);
taosArrayDestroyP(fqdns, (FDelete)taosMemoryFree); taosArrayDestroyP(fqdns, NULL);
if (code < 0) { if (code < 0) {
mError("failed to update ip white list for user: %s at line %d since %s", user, lino, tstrerror(code)); mError("failed to update ip white list for user: %s at line %d since %s", user, lino, tstrerror(code));
} }
@ -640,8 +640,8 @@ int32_t mndFetchAllIpWhite(SMnode *pMnode, SHashObj **ppIpWhiteTab) {
} }
_OVER: _OVER:
taosArrayDestroyP(fqdns, taosMemoryFree); taosArrayDestroyP(fqdns, NULL);
taosArrayDestroyP(pUserNames, taosMemoryFree); taosArrayDestroyP(pUserNames, NULL);
if (code < 0) { if (code < 0) {
mError("failed to fetch all ip white list at line %d since %s", lino, tstrerror(code)); mError("failed to fetch all ip white list at line %d since %s", lino, tstrerror(code));
@ -1899,13 +1899,13 @@ static int32_t mndProcessCreateUserReq(SRpcMsg *pReq) {
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS; if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
char detail[1000] = {0}; char detail[1000] = {0};
(void)sprintf(detail, "enable:%d, superUser:%d, sysInfo:%d, password:xxx", createReq.enable, createReq.superUser, TAOS_UNUSED(snprintf(detail, sizeof(detail), "enable:%d, superUser:%d, sysInfo:%d, password:xxx", createReq.enable,
createReq.sysInfo); createReq.superUser, createReq.sysInfo));
char operation[15] = {0}; char operation[15] = {0};
if (createReq.isImport == 1) { if (createReq.isImport == 1) {
(void)strcpy(operation, "importUser"); tstrncpy(operation, "importUser", sizeof(operation));
} else { } else {
(void)strcpy(operation, "createUser"); tstrncpy(operation, "createUser", sizeof(operation));
} }
auditRecord(pReq, pMnode->clusterId, operation, "", createReq.user, detail, strlen(detail)); auditRecord(pReq, pMnode->clusterId, operation, "", createReq.user, detail, strlen(detail));
@ -2502,9 +2502,10 @@ static int32_t mndProcessAlterUserReq(SRpcMsg *pReq) {
if (alterReq.alterType == TSDB_ALTER_USER_PASSWD) { if (alterReq.alterType == TSDB_ALTER_USER_PASSWD) {
char detail[1000] = {0}; char detail[1000] = {0};
(void)sprintf(detail, "alterType:%s, enable:%d, superUser:%d, sysInfo:%d, createdb:%d, tabName:%s, password:xxx", (void)snprintf(detail, sizeof(detail),
mndUserAuditTypeStr(alterReq.alterType), alterReq.enable, alterReq.superUser, alterReq.sysInfo, "alterType:%s, enable:%d, superUser:%d, sysInfo:%d, createdb:%d, tabName:%s, password:xxx",
alterReq.createdb ? 1 : 0, alterReq.tabName); mndUserAuditTypeStr(alterReq.alterType), alterReq.enable, alterReq.superUser, alterReq.sysInfo,
alterReq.createdb ? 1 : 0, alterReq.tabName);
auditRecord(pReq, pMnode->clusterId, "alterUser", "", alterReq.user, detail, strlen(detail)); auditRecord(pReq, pMnode->clusterId, "alterUser", "", alterReq.user, detail, strlen(detail));
} else if (alterReq.alterType == TSDB_ALTER_USER_SUPERUSER || alterReq.alterType == TSDB_ALTER_USER_ENABLE || } else if (alterReq.alterType == TSDB_ALTER_USER_SUPERUSER || alterReq.alterType == TSDB_ALTER_USER_ENABLE ||
alterReq.alterType == TSDB_ALTER_USER_SYSINFO || alterReq.alterType == TSDB_ALTER_USER_CREATEDB) { alterReq.alterType == TSDB_ALTER_USER_SYSINFO || alterReq.alterType == TSDB_ALTER_USER_CREATEDB) {
@ -2877,8 +2878,8 @@ static int32_t mndLoopHash(SHashObj *hash, char *priType, SSDataBlock *pBlock, i
SNode *pAst = NULL; SNode *pAst = NULL;
int32_t sqlLen = 0; int32_t sqlLen = 0;
size_t bufSz = strlen(value) + 1; size_t bufSz = strlen(value) + 1;
if (bufSz < 5) bufSz = 5; if (bufSz < 6) bufSz = 6;
TAOS_MEMORY_REALLOC(*sql, bufSz + 1); TAOS_MEMORY_REALLOC(*sql, bufSz);
if (*sql == NULL) { if (*sql == NULL) {
code = terrno; code = terrno;
goto _exit; goto _exit;
@ -2892,12 +2893,12 @@ static int32_t mndLoopHash(SHashObj *hash, char *priType, SSDataBlock *pBlock, i
if (nodesStringToNode(value, &pAst) == 0) { if (nodesStringToNode(value, &pAst) == 0) {
if (nodesNodeToSQL(pAst, *sql, bufSz, &sqlLen) != 0) { if (nodesNodeToSQL(pAst, *sql, bufSz, &sqlLen) != 0) {
sqlLen = 5; sqlLen = 5;
(void)sprintf(*sql, "error"); (void)snprintf(*sql, bufSz, "error");
} }
nodesDestroyNode(pAst); nodesDestroyNode(pAst);
} else { } else {
sqlLen = 5; sqlLen = 5;
(void)sprintf(*sql, "error"); (void)snprintf(*sql, bufSz, "error");
} }
STR_WITH_MAXSIZE_TO_VARSTR((*condition), (*sql), pShow->pMeta->pSchemas[cols].bytes); STR_WITH_MAXSIZE_TO_VARSTR((*condition), (*sql), pShow->pMeta->pSchemas[cols].bytes);

View File

@ -308,7 +308,7 @@ static int32_t tdSetRSmaInfoItemParams(SSma *pSma, SRSmaParam *param, SRSmaStat
if (!pStreamTask->exec.qmsg) { if (!pStreamTask->exec.qmsg) {
TAOS_RETURN(terrno); TAOS_RETURN(terrno);
} }
(void)sprintf(pStreamTask->exec.qmsg, "%s", RSMA_EXEC_TASK_FLAG); TAOS_UNUSED(snprintf(pStreamTask->exec.qmsg, strlen(RSMA_EXEC_TASK_FLAG) + 1, "%s", RSMA_EXEC_TASK_FLAG));
pStreamTask->chkInfo.checkpointId = streamMetaGetLatestCheckpointId(pStreamTask->pMeta); pStreamTask->chkInfo.checkpointId = streamMetaGetLatestCheckpointId(pStreamTask->pMeta);
tdRSmaTaskInit(pStreamTask->pMeta, pItem, &pStreamTask->id); tdRSmaTaskInit(pStreamTask->pMeta, pItem, &pStreamTask->id);

View File

@ -946,7 +946,7 @@ int32_t tsdbFSEditCommit(STFileSystem *fs) {
arg->tsdb = fs->tsdb; arg->tsdb = fs->tsdb;
arg->fid = fset->fid; arg->fid = fset->fid;
code = vnodeAsync(&fset->channel, EVA_PRIORITY_HIGH, tsdbMerge, taosMemoryFree, arg, NULL); code = vnodeAsync(&fset->channel, EVA_PRIORITY_HIGH, tsdbMerge, taosAutoMemoryFree, arg, NULL);
TSDB_CHECK_CODE(code, lino, _exit); TSDB_CHECK_CODE(code, lino, _exit);
fset->mergeScheduled = true; fset->mergeScheduled = true;
} }

View File

@ -150,7 +150,7 @@ _end:
void clearBlockScanInfoBuf(SBlockInfoBuf* pBuf) { void clearBlockScanInfoBuf(SBlockInfoBuf* pBuf) {
if (pBuf == NULL) return; if (pBuf == NULL) return;
if (pBuf->pData != NULL) { if (pBuf->pData != NULL) {
taosArrayDestroyP(pBuf->pData, (FDelete)taosMemoryFree); taosArrayDestroyP(pBuf->pData, NULL);
pBuf->pData = NULL; pBuf->pData = NULL;
} }
} }

View File

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

View File

@ -1321,7 +1321,7 @@ _exit:
taosArrayDestroy(tbUids); taosArrayDestroy(tbUids);
tDecoderClear(&decoder); tDecoderClear(&decoder);
tEncoderClear(&encoder); tEncoderClear(&encoder);
taosArrayDestroyP(tbNames, taosMemoryFree); taosArrayDestroyP(tbNames, NULL);
return rcode; return rcode;
} }

View File

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

View File

@ -1173,12 +1173,16 @@ int32_t ctgDumpTbIndexRes(SCtgTask* pTask) {
SCtgJob* pJob = pTask->pJob; SCtgJob* pJob = pTask->pJob;
if (NULL == pJob->jobRes.pTableIndex) { if (NULL == pJob->jobRes.pTableIndex) {
SArray* pRes = taosArrayInit(pJob->tbIndexNum, sizeof(SMetaRes)); 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)) { if (atomic_val_compare_exchange_ptr(&pJob->jobRes.pTableIndex, NULL, pRes)) {
taosArrayDestroy(pRes); taosArrayDestroy(pRes);
} }
if (NULL == pJob->jobRes.pTableIndex) { 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; SCtgJob* pJob = pTask->pJob;
if (NULL == pJob->jobRes.pTableCfg) { if (NULL == pJob->jobRes.pTableCfg) {
SArray* pRes = taosArrayInit(pJob->tbCfgNum, sizeof(SMetaRes)); 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)) { if (atomic_val_compare_exchange_ptr(&pJob->jobRes.pTableCfg, NULL, pRes)) {
taosArrayDestroy(pRes); taosArrayDestroy(pRes);
} }
if (NULL == pJob->jobRes.pTableCfg) { 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; SCtgJob* pJob = pTask->pJob;
if (NULL == pJob->jobRes.pTableTag) { if (NULL == pJob->jobRes.pTableTag) {
SArray* pRes = taosArrayInit(pJob->tbTagNum, sizeof(SMetaRes)); 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)) { if (atomic_val_compare_exchange_ptr(&pJob->jobRes.pTableTag, NULL, pRes)) {
taosArrayDestroy(pRes); taosArrayDestroy(pRes);
} }
if (NULL == pJob->jobRes.pTableTag) { 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) { for (int32_t i = 0; i < tbNum; ++i) {
CTG_ERR_JRET(ctgAddFetch(&ctx->pFetchs, dbIdx, i, fetchIdx, baseResIdx + i, flag)); CTG_ERR_JRET(ctgAddFetch(&ctx->pFetchs, dbIdx, i, fetchIdx, baseResIdx + i, flag));
if (NULL == taosArrayPush(ctx->pResList, &(SMetaData){0})) { 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->querySql);
taosMemoryFree(pViewMeta->user); taosMemoryFree(pViewMeta->user);
taosMemoryFree(pViewMeta); taosMemoryFree(pViewMeta);
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); CTG_ERR_RET(terrno);
} }
pViewMeta->pSchema = taosMemoryMalloc(pViewMeta->numOfCols * sizeof(SSchema)); pViewMeta->pSchema = taosMemoryMalloc(pViewMeta->numOfCols * sizeof(SSchema));
if (pViewMeta->pSchema == NULL) { if (pViewMeta->pSchema == NULL) {

View File

@ -34,9 +34,10 @@ int32_t ctgHandleBatchRsp(SCtgJob* pJob, SCtgTaskCallbackParam* cbParam, SDataBu
SBatchRspMsg* pRsp = NULL; SBatchRspMsg* pRsp = NULL;
if (TSDB_CODE_SUCCESS == rspCode && pMsg->pData && (pMsg->len > 0)) { 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); ctgError("tDeserializeSBatchRsp failed, msgLen:%d", pMsg->len);
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); CTG_ERR_RET(code);
} }
msgNum = taosArrayGetSize(batchRsp.pRsps); 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); newBatch.batchId = atomic_add_fetch_32(&pJob->batchId, 1);
if (0 != taosHashPut(pBatchs, &vgId, sizeof(vgId), &newBatch, sizeof(newBatch))) { 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, 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); int32_t msgSize = tSerializeSBatchReq(NULL, 0, &batchReq);
if (msgSize < 0) { if (msgSize < 0) {
qError("tSerializeSBatchReq failed"); qError("tSerializeSBatchReq failed");
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); CTG_ERR_RET(msgSize);
} }
*msg = taosMemoryCalloc(1, 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); qError("calloc batchReq msg failed, size:%d", msgSize);
CTG_ERR_RET(terrno); CTG_ERR_RET(terrno);
} }
if (tSerializeSBatchReq(*msg, msgSize, &batchReq) < 0) { msgSize = tSerializeSBatchReq(*msg, msgSize, &batchReq);
if (msgSize < 0) {
qError("tSerializeSBatchReq failed"); qError("tSerializeSBatchReq failed");
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); CTG_ERR_RET(msgSize);
} }
*pSize = msgSize; *pSize = msgSize;
@ -835,7 +837,7 @@ int32_t ctgGetQnodeListFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, SArray
char* msg = NULL; char* msg = NULL;
int32_t msgLen = 0; int32_t msgLen = 0;
int32_t reqType = TDMT_MND_QNODE_LIST; int32_t reqType = TDMT_MND_QNODE_LIST;
void* (*mallocFp)(int64_t) = pTask ? (MallocType)taosMemoryMalloc : (MallocType)rpcMallocCont; void* (*mallocFp)(int64_t) = pTask ? (MallocType)taosMemMalloc : (MallocType)rpcMallocCont;
ctgDebug("try to get qnode list from mnode, mgmtEpInUse:%d", pConn->mgmtEps.inUse); ctgDebug("try to get qnode list from mnode, mgmtEpInUse:%d", pConn->mgmtEps.inUse);
@ -892,7 +894,7 @@ int32_t ctgGetDnodeListFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, SArray
char* msg = NULL; char* msg = NULL;
int32_t msgLen = 0; int32_t msgLen = 0;
int32_t reqType = TDMT_MND_DNODE_LIST; int32_t reqType = TDMT_MND_DNODE_LIST;
void* (*mallocFp)(int64_t) = pTask ? (MallocType)taosMemoryMalloc : (MallocType)rpcMallocCont; void* (*mallocFp)(int64_t) = pTask ? (MallocType)taosMemMalloc : (MallocType)rpcMallocCont;
ctgDebug("try to get dnode list from mnode, mgmtEpInUse:%d", pConn->mgmtEps.inUse); ctgDebug("try to get dnode list from mnode, mgmtEpInUse:%d", pConn->mgmtEps.inUse);
@ -946,7 +948,7 @@ int32_t ctgGetDBVgInfoFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, SBuildU
int32_t msgLen = 0; int32_t msgLen = 0;
int32_t reqType = TDMT_MND_USE_DB; int32_t reqType = TDMT_MND_USE_DB;
SCtgTask* pTask = tReq ? tReq->pTask : NULL; SCtgTask* pTask = tReq ? tReq->pTask : NULL;
void* (*mallocFp)(int64_t) = pTask ? (MallocType)taosMemoryMalloc : (MallocType)rpcMallocCont; void* (*mallocFp)(int64_t) = pTask ? (MallocType)taosMemMalloc : (MallocType)rpcMallocCont;
ctgDebug("try to get db vgInfo from mnode, dbFName:%s", input->db); ctgDebug("try to get db vgInfo from mnode, dbFName:%s", input->db);
@ -1001,7 +1003,7 @@ int32_t ctgGetDBCfgFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const char
char* msg = NULL; char* msg = NULL;
int32_t msgLen = 0; int32_t msgLen = 0;
int32_t reqType = TDMT_MND_GET_DB_CFG; int32_t reqType = TDMT_MND_GET_DB_CFG;
void* (*mallocFp)(int64_t) = pTask ? (MallocType)taosMemoryMalloc : (MallocType)rpcMallocCont; void* (*mallocFp)(int64_t) = pTask ? (MallocType)taosMemMalloc : (MallocType)rpcMallocCont;
ctgDebug("try to get db cfg from mnode, dbFName:%s", dbFName); ctgDebug("try to get db cfg from mnode, dbFName:%s", dbFName);
@ -1059,7 +1061,7 @@ int32_t ctgGetIndexInfoFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const
char* msg = NULL; char* msg = NULL;
int32_t msgLen = 0; int32_t msgLen = 0;
int32_t reqType = TDMT_MND_GET_INDEX; int32_t reqType = TDMT_MND_GET_INDEX;
void* (*mallocFp)(int64_t) = pTask ? (MallocType)taosMemoryMalloc : (MallocType)rpcMallocCont; void* (*mallocFp)(int64_t) = pTask ? (MallocType)taosMemMalloc : (MallocType)rpcMallocCont;
ctgDebug("try to get index from mnode, indexName:%s", indexName); ctgDebug("try to get index from mnode, indexName:%s", indexName);
@ -1117,7 +1119,7 @@ int32_t ctgGetTbIndexFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, SName* n
char* msg = NULL; char* msg = NULL;
int32_t msgLen = 0; int32_t msgLen = 0;
int32_t reqType = TDMT_MND_GET_TABLE_INDEX; int32_t reqType = TDMT_MND_GET_TABLE_INDEX;
void* (*mallocFp)(int64_t) = pTask ? (MallocType)taosMemoryMalloc : (MallocType)rpcMallocCont; void* (*mallocFp)(int64_t) = pTask ? (MallocType)taosMemMalloc : (MallocType)rpcMallocCont;
char tbFName[TSDB_TABLE_FNAME_LEN]; char tbFName[TSDB_TABLE_FNAME_LEN];
ctgDebug("try to get tb index from mnode, tbFName:%s", tbFName); ctgDebug("try to get tb index from mnode, tbFName:%s", tbFName);
@ -1183,7 +1185,7 @@ int32_t ctgGetUdfInfoFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const ch
char* msg = NULL; char* msg = NULL;
int32_t msgLen = 0; int32_t msgLen = 0;
int32_t reqType = TDMT_MND_RETRIEVE_FUNC; int32_t reqType = TDMT_MND_RETRIEVE_FUNC;
void* (*mallocFp)(int64_t) = pTask ? (MallocType)taosMemoryMalloc : (MallocType)rpcMallocCont; void* (*mallocFp)(int64_t) = pTask ? (MallocType)taosMemMalloc : (MallocType)rpcMallocCont;
ctgDebug("try to get udf info from mnode, funcName:%s", funcName); ctgDebug("try to get udf info from mnode, funcName:%s", funcName);
@ -1241,7 +1243,7 @@ int32_t ctgGetUserDbAuthFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const
char* msg = NULL; char* msg = NULL;
int32_t msgLen = 0; int32_t msgLen = 0;
int32_t reqType = TDMT_MND_GET_USER_AUTH; int32_t reqType = TDMT_MND_GET_USER_AUTH;
void* (*mallocFp)(int64_t) = pTask ? (MallocType)taosMemoryMalloc : (MallocType)rpcMallocCont; void* (*mallocFp)(int64_t) = pTask ? (MallocType)taosMemMalloc : (MallocType)rpcMallocCont;
ctgDebug("try to get user auth from mnode, user:%s", user); ctgDebug("try to get user auth from mnode, user:%s", user);
@ -1304,7 +1306,7 @@ int32_t ctgGetTbMetaFromMnodeImpl(SCatalog* pCtg, SRequestConnInfo* pConn, const
int32_t reqType = TDMT_MND_TABLE_META; int32_t reqType = TDMT_MND_TABLE_META;
char tbFName[TSDB_TABLE_FNAME_LEN]; char tbFName[TSDB_TABLE_FNAME_LEN];
(void)snprintf(tbFName, sizeof(tbFName), "%s.%s", dbFName, tbName); (void)snprintf(tbFName, sizeof(tbFName), "%s.%s", dbFName, tbName);
void* (*mallocFp)(int64_t) = pTask ? (MallocType)taosMemoryMalloc : (MallocType)rpcMallocCont; void* (*mallocFp)(int64_t) = pTask ? (MallocType)taosMemMalloc : (MallocType)rpcMallocCont;
ctgDebug("try to get table meta from mnode, tbFName:%s", tbFName); ctgDebug("try to get table meta from mnode, tbFName:%s", tbFName);
@ -1370,7 +1372,7 @@ int32_t ctgGetTbMetaFromVnode(SCatalog* pCtg, SRequestConnInfo* pConn, const SNa
int32_t reqType = (pTask && pTask->type == CTG_TASK_GET_TB_NAME ? TDMT_VND_TABLE_NAME : TDMT_VND_TABLE_META); int32_t reqType = (pTask && pTask->type == CTG_TASK_GET_TB_NAME ? TDMT_VND_TABLE_NAME : TDMT_VND_TABLE_META);
char tbFName[TSDB_TABLE_FNAME_LEN]; char tbFName[TSDB_TABLE_FNAME_LEN];
(void)snprintf(tbFName, sizeof(tbFName), "%s.%s", dbFName, pTableName->tname); (void)snprintf(tbFName, sizeof(tbFName), "%s.%s", dbFName, pTableName->tname);
void* (*mallocFp)(int64_t) = pTask ? (MallocType)taosMemoryMalloc : (MallocType)rpcMallocCont; void* (*mallocFp)(int64_t) = pTask ? (MallocType)taosMemMalloc : (MallocType)rpcMallocCont;
SEp* pEp = &vgroupInfo->epSet.eps[vgroupInfo->epSet.inUse]; SEp* pEp = &vgroupInfo->epSet.eps[vgroupInfo->epSet.inUse];
ctgDebug("try to get table meta from vnode, vgId:%d, ep num:%d, ep %s:%d, tbFName:%s", vgroupInfo->vgId, ctgDebug("try to get table meta from vnode, vgId:%d, ep num:%d, ep %s:%d, tbFName:%s", vgroupInfo->vgId,
@ -1443,8 +1445,7 @@ int32_t ctgGetTableCfgFromVnode(SCatalog* pCtg, SRequestConnInfo* pConn, const S
int32_t msgLen = 0; int32_t msgLen = 0;
int32_t reqType = TDMT_VND_TABLE_CFG; int32_t reqType = TDMT_VND_TABLE_CFG;
char tbFName[TSDB_TABLE_FNAME_LEN]; char tbFName[TSDB_TABLE_FNAME_LEN];
void* (*mallocFp)(int64_t) = pTask ? (MallocType)taosMemMalloc : (MallocType)rpcMallocCont;
void* (*mallocFp)(int64_t) = pTask ? (MallocType)taosMemoryMalloc : (MallocType)rpcMallocCont;
char dbFName[TSDB_DB_FNAME_LEN]; char dbFName[TSDB_DB_FNAME_LEN];
(void)tNameGetFullDbName(pTableName, dbFName); (void)tNameGetFullDbName(pTableName, dbFName);
SBuildTableInput bInput = {.vgId = vgroupInfo->vgId, .dbFName = dbFName, .tbName = (char*)pTableName->tname}; SBuildTableInput bInput = {.vgId = vgroupInfo->vgId, .dbFName = dbFName, .tbName = (char*)pTableName->tname};
@ -1518,7 +1519,7 @@ int32_t ctgGetTableCfgFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const S
int32_t msgLen = 0; int32_t msgLen = 0;
int32_t reqType = TDMT_MND_TABLE_CFG; int32_t reqType = TDMT_MND_TABLE_CFG;
char tbFName[TSDB_TABLE_FNAME_LEN]; char tbFName[TSDB_TABLE_FNAME_LEN];
void* (*mallocFp)(int64_t) = pTask ? (MallocType)taosMemoryMalloc : (MallocType)rpcMallocCont; void* (*mallocFp)(int64_t) = pTask ? (MallocType)taosMemMalloc : (MallocType)rpcMallocCont;
char dbFName[TSDB_DB_FNAME_LEN]; char dbFName[TSDB_DB_FNAME_LEN];
(void)tNameGetFullDbName(pTableName, dbFName); (void)tNameGetFullDbName(pTableName, dbFName);
SBuildTableInput bInput = {.vgId = 0, .dbFName = dbFName, .tbName = (char*)pTableName->tname}; SBuildTableInput bInput = {.vgId = 0, .dbFName = dbFName, .tbName = (char*)pTableName->tname};
@ -1580,7 +1581,7 @@ int32_t ctgGetSvrVerFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, char** ou
char* msg = NULL; char* msg = NULL;
int32_t msgLen = 0; int32_t msgLen = 0;
int32_t reqType = TDMT_MND_SERVER_VERSION; int32_t reqType = TDMT_MND_SERVER_VERSION;
void* (*mallocFp)(int64_t) = pTask ? (MallocType)taosMemoryMalloc : (MallocType)rpcMallocCont; void* (*mallocFp)(int64_t) = pTask ? (MallocType)taosMemMalloc : (MallocType)rpcMallocCont;
qDebug("try to get svr ver from mnode"); qDebug("try to get svr ver from mnode");
@ -1634,7 +1635,7 @@ int32_t ctgGetViewInfoFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, SName*
int32_t msgLen = 0; int32_t msgLen = 0;
int32_t reqType = TDMT_MND_VIEW_META; int32_t reqType = TDMT_MND_VIEW_META;
SCtgTask* pTask = tReq ? tReq->pTask : NULL; SCtgTask* pTask = tReq ? tReq->pTask : NULL;
void* (*mallocFp)(int64_t) = pTask ? (MallocType)taosMemoryMalloc : (MallocType)rpcMallocCont; void* (*mallocFp)(int64_t) = pTask ? (MallocType)taosMemMalloc : (MallocType)rpcMallocCont;
char fullName[TSDB_TABLE_FNAME_LEN]; char fullName[TSDB_TABLE_FNAME_LEN];
int32_t code = tNameExtractFullName(pName, fullName); int32_t code = tNameExtractFullName(pName, fullName);
if (code) { if (code) {
@ -1696,7 +1697,7 @@ int32_t ctgGetTbTSMAFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const SNa
char* msg = NULL; char* msg = NULL;
int32_t msgLen = 0; int32_t msgLen = 0;
SCtgTask* pTask = tReq ? tReq->pTask : NULL; SCtgTask* pTask = tReq ? tReq->pTask : NULL;
void* (*mallocFp)(int64_t) = pTask ? (MallocType)taosMemoryMalloc : (MallocType)rpcMallocCont; void* (*mallocFp)(int64_t) = pTask ? (MallocType)taosMemMalloc : (MallocType)rpcMallocCont;
char tbFName[TSDB_TABLE_FNAME_LEN]; char tbFName[TSDB_TABLE_FNAME_LEN];
int32_t code = tNameExtractFullName(name, tbFName); int32_t code = tNameExtractFullName(name, tbFName);
if (code) { if (code) {
@ -1768,7 +1769,7 @@ int32_t ctgGetStreamProgressFromVnode(SCatalog* pCtg, SRequestConnInfo* pConn, c
} }
SCtgTask* pTask = tReq ? tReq->pTask : NULL; SCtgTask* pTask = tReq ? tReq->pTask : NULL;
void* (*mallocFp)(int64_t) = pTask ? (MallocType)taosMemoryMalloc : (MallocType)rpcMallocCont; void* (*mallocFp)(int64_t) = pTask ? (MallocType)taosMemMalloc : (MallocType)rpcMallocCont;
SEp* pEp = &vgroupInfo->epSet.eps[vgroupInfo->epSet.inUse]; SEp* pEp = &vgroupInfo->epSet.eps[vgroupInfo->epSet.inUse];
ctgDebug("try to get stream progress from vnode, vgId:%d, ep num:%d, ep %s:%d, target:%s", vgroupInfo->vgId, ctgDebug("try to get stream progress from vnode, vgId:%d, ep num:%d, ep %s:%d, target:%s", vgroupInfo->vgId,

View File

@ -1620,7 +1620,7 @@ int32_t ctgCloneVgInfo(SDBVgInfo* src, SDBVgInfo** dst) {
taosHashCancelIterate(src->vgHash, pIter); taosHashCancelIterate(src->vgHash, pIter);
taosHashCleanup((*dst)->vgHash); taosHashCleanup((*dst)->vgHash);
taosMemoryFreeClear(*dst); taosMemoryFreeClear(*dst);
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); CTG_ERR_RET(terrno);
} }
pIter = taosHashIterate(src->vgHash, pIter); pIter = taosHashIterate(src->vgHash, pIter);
@ -1787,7 +1787,7 @@ static int32_t ctgCloneDbVgroup(void* pSrc, void** ppDst) {
} }
*ppDst = taosArrayDup((const SArray*)pSrc, NULL); *ppDst = taosArrayDup((const SArray*)pSrc, NULL);
return (*ppDst) ? TSDB_CODE_SUCCESS : TSDB_CODE_OUT_OF_MEMORY; return (*ppDst) ? TSDB_CODE_SUCCESS : terrno;
#else #else
return TSDB_CODE_CTG_INTERNAL_ERROR; return TSDB_CODE_CTG_INTERNAL_ERROR;
#endif #endif
@ -1824,7 +1824,7 @@ static int32_t ctgCloneDbInfo(void* pSrc, void** ppDst) {
#if 0 #if 0
SDbInfo* pDst = taosMemoryMalloc(sizeof(SDbInfo)); SDbInfo* pDst = taosMemoryMalloc(sizeof(SDbInfo));
if (NULL == pDst) { if (NULL == pDst) {
return TSDB_CODE_OUT_OF_MEMORY; return terrno;
} }
TAOS_MEMCPY(pDst, pSrc, sizeof(SDbInfo)); 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); int32_t size = taosArrayGetSize(pSrc);
*pDst = taosArrayInit(size, sizeof(SMetaRes)); *pDst = taosArrayInit(size, sizeof(SMetaRes));
if (NULL == *pDst) { if (NULL == *pDst) {
return TSDB_CODE_OUT_OF_MEMORY; return terrno;
} }
for (int32_t i = 0; i < size; ++i) { for (int32_t i = 0; i < size; ++i) {
SMetaRes* pRes = taosArrayGet(pSrc, i); SMetaRes* pRes = taosArrayGet(pSrc, i);
SMetaRes res = {.code = pRes->code, .pRes = copyFunc(pRes->pRes)}; SMetaRes res = {.code = pRes->code, .pRes = copyFunc(pRes->pRes)};
if (NULL == res.pRes) { if (NULL == res.pRes) {
return TSDB_CODE_OUT_OF_MEMORY; return terrno;
} }
taosArrayPush(*pDst, &res); taosArrayPush(*pDst, &res);
} }
@ -2630,11 +2630,11 @@ int32_t ctgBuildViewNullRes(SCtgTask* pTask, SCtgViewsCtx* pCtx) {
int32_t dupViewMetaFromRsp(SViewMetaRsp* pRsp, SViewMeta* pViewMeta) { int32_t dupViewMetaFromRsp(SViewMetaRsp* pRsp, SViewMeta* pViewMeta) {
pViewMeta->querySql = tstrdup(pRsp->querySql); pViewMeta->querySql = tstrdup(pRsp->querySql);
if (NULL == pViewMeta->querySql) { if (NULL == pViewMeta->querySql) {
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); CTG_ERR_RET(terrno);
} }
pViewMeta->user = tstrdup(pRsp->user); pViewMeta->user = tstrdup(pRsp->user);
if (NULL == pViewMeta->user) { if (NULL == pViewMeta->user) {
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); CTG_ERR_RET(terrno);
} }
pViewMeta->version = pRsp->version; pViewMeta->version = pRsp->version;
pViewMeta->viewId = pRsp->viewId; 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))) { if (0 != taosHashPut(groupHash, &plan->id.groupId, sizeof(plan->id.groupId), &group, sizeof(group))) {
qError("taosHashPut to explainGroupHash failed, taskIdx:%d", n); qError("taosHashPut to explainGroupHash failed, taskIdx:%d", n);
QRY_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); QRY_ERR_JRET(terrno);
} }
} }

View File

@ -39,6 +39,7 @@ typedef void (*FGetDataLength)(struct SDataSinkHandle* pHandle, int64_t* pLen, i
typedef int32_t (*FGetDataBlock)(struct SDataSinkHandle* pHandle, SOutputData* pOutput); typedef int32_t (*FGetDataBlock)(struct SDataSinkHandle* pHandle, SOutputData* pOutput);
typedef int32_t (*FDestroyDataSinker)(struct SDataSinkHandle* pHandle); typedef int32_t (*FDestroyDataSinker)(struct SDataSinkHandle* pHandle);
typedef int32_t (*FGetCacheSize)(struct SDataSinkHandle* pHandle, uint64_t* size); typedef int32_t (*FGetCacheSize)(struct SDataSinkHandle* pHandle, uint64_t* size);
typedef int32_t (*FGetSinkFlags)(struct SDataSinkHandle* pHandle, uint64_t* flags);
typedef struct SDataSinkHandle { typedef struct SDataSinkHandle {
FPutDataBlock fPut; FPutDataBlock fPut;
@ -48,12 +49,13 @@ typedef struct SDataSinkHandle {
FGetDataBlock fGetData; FGetDataBlock fGetData;
FDestroyDataSinker fDestroy; FDestroyDataSinker fDestroy;
FGetCacheSize fGetCacheSize; FGetCacheSize fGetCacheSize;
FGetSinkFlags fGetFlags;
} SDataSinkHandle; } SDataSinkHandle;
int32_t createDataDispatcher(SDataSinkManager* pManager, const SDataSinkNode* pDataSink, DataSinkHandle* pHandle); int32_t createDataDispatcher(SDataSinkManager* pManager, SDataSinkNode** ppDataSink, DataSinkHandle* pHandle);
int32_t createDataDeleter(SDataSinkManager* pManager, const SDataSinkNode* pDataSink, DataSinkHandle* pHandle, int32_t createDataDeleter(SDataSinkManager* pManager, SDataSinkNode** ppDataSink, DataSinkHandle* pHandle,
void* pParam); void* pParam);
int32_t createDataInserter(SDataSinkManager* pManager, const SDataSinkNode* pDataSink, DataSinkHandle* pHandle, int32_t createDataInserter(SDataSinkManager* pManager, SDataSinkNode** ppDataSink, DataSinkHandle* pHandle,
void* pParam); void* pParam);
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -942,7 +942,7 @@ void updateLoadRemoteInfo(SLoadRemoteDataInfo* pInfo, int64_t numOfRows, int3
struct SOperatorInfo* pOperator); struct SOperatorInfo* pOperator);
STimeWindow getFirstQualifiedTimeWindow(int64_t ts, STimeWindow* pWindow, SInterval* pInterval, int32_t order); STimeWindow getFirstQualifiedTimeWindow(int64_t ts, STimeWindow* pWindow, SInterval* pInterval, int32_t order);
int32_t getBufferPgSize(int32_t rowSize, uint32_t* defaultPgsz, uint32_t* defaultBufsz); int32_t getBufferPgSize(int32_t rowSize, uint32_t* defaultPgsz, int64_t* defaultBufsz);
extern void doDestroyExchangeOperatorInfo(void* param); extern void doDestroyExchangeOperatorInfo(void* param);

View File

@ -581,7 +581,7 @@ int32_t doInitAggInfoSup(SAggSupporter* pAggSup, SqlFunctionCtx* pCtx, int32_t n
} }
uint32_t defaultPgsz = 0; uint32_t defaultPgsz = 0;
uint32_t defaultBufsz = 0; int64_t defaultBufsz = 0;
code = getBufferPgSize(pAggSup->resultRowSize, &defaultPgsz, &defaultBufsz); code = getBufferPgSize(pAggSup->resultRowSize, &defaultPgsz, &defaultBufsz);
if (code) { if (code) {
qError("failed to get buff page size, rowSize:%d", pAggSup->resultRowSize); qError("failed to get buff page size, rowSize:%d", pAggSup->resultRowSize);

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; int32_t itemSize = sizeof(int32_t) + pInfo->aggSup.resultRowSize + pInfo->anomalyKey.bytes;
pInfo->anomalySup.pResultRow = taosMemoryCalloc(1, itemSize); pInfo->anomalySup.pResultRow = taosMemoryCalloc(1, itemSize);
if (pInfo->anomalySup.pResultRow == NULL) {
code = terrno;
goto _error;
}
pInfo->anomalySup.blocks = taosArrayInit(16, sizeof(SSDataBlock*)); pInfo->anomalySup.blocks = taosArrayInit(16, sizeof(SSDataBlock*));
if (pInfo->anomalySup.blocks == NULL) {
code = terrno;
goto _error;
}
pInfo->anomalySup.windows = taosArrayInit(16, sizeof(STimeWindow)); pInfo->anomalySup.windows = taosArrayInit(16, sizeof(STimeWindow));
if (pInfo->anomalySup.windows == NULL) {
if (pInfo->anomalySup.windows == NULL || pInfo->anomalySup.blocks == NULL || pInfo->anomalySup.pResultRow == NULL) { code = terrno;
code = TSDB_CODE_OUT_OF_MEMORY;
goto _error; goto _error;
} }
@ -269,8 +276,8 @@ static int32_t anomalyCacheBlock(SAnomalyWindowOperatorInfo* pInfo, SSDataBlock*
int32_t code = createOneDataBlock(pSrc, true, &pDst); int32_t code = createOneDataBlock(pSrc, true, &pDst);
if (code != 0) return code; if (code != 0) return code;
if (pDst == NULL) return TSDB_CODE_OUT_OF_MEMORY; if (pDst == NULL) return code;
if (taosArrayPush(pInfo->anomalySup.blocks, &pDst) == NULL) return TSDB_CODE_OUT_OF_MEMORY; if (taosArrayPush(pInfo->anomalySup.blocks, &pDst) == NULL) return terrno;
return 0; return 0;
} }
@ -664,4 +671,4 @@ int32_t createAnomalywindowOperatorInfo(SOperatorInfo* downstream, SPhysiNode* p
} }
void destroyForecastInfo(void* param) {} void destroyForecastInfo(void* param) {}
#endif #endif

View File

@ -41,6 +41,7 @@ typedef struct SDataCacheEntry {
typedef struct SDataDeleterHandle { typedef struct SDataDeleterHandle {
SDataSinkHandle sink; SDataSinkHandle sink;
SDataSinkManager* pManager; SDataSinkManager* pManager;
SDataSinkNode* pSinkNode;
SDataBlockDescNode* pSchema; SDataBlockDescNode* pSchema;
SDataDeleterNode* pDeleter; SDataDeleterNode* pDeleter;
SDeleterParam* pParam; SDeleterParam* pParam;
@ -50,6 +51,7 @@ typedef struct SDataDeleterHandle {
bool queryEnd; bool queryEnd;
uint64_t useconds; uint64_t useconds;
uint64_t cachedSize; uint64_t cachedSize;
uint64_t flags;
TdThreadMutex mutex; TdThreadMutex mutex;
} SDataDeleterHandle; } SDataDeleterHandle;
@ -111,7 +113,7 @@ static int32_t allocBuf(SDataDeleterHandle* pDeleter, const SInputData* pInput,
if (taosQueueItemSize(pDeleter->pDataBlocks) > capacity) { if (taosQueueItemSize(pDeleter->pDataBlocks) > capacity) {
qError("SinkNode queue is full, no capacity, max:%d, current:%d, no capacity", capacity, qError("SinkNode queue is full, no capacity, max:%d, current:%d, no capacity", capacity,
taosQueueItemSize(pDeleter->pDataBlocks)); taosQueueItemSize(pDeleter->pDataBlocks));
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR;
} }
pBuf->allocSize = sizeof(SDataCacheEntry) + sizeof(SDeleterRes); pBuf->allocSize = sizeof(SDataCacheEntry) + sizeof(SDeleterRes);
@ -257,6 +259,8 @@ static int32_t destroyDataSinker(SDataSinkHandle* pHandle) {
} }
taosCloseQueue(pDeleter->pDataBlocks); taosCloseQueue(pDeleter->pDataBlocks);
(void)taosThreadMutexDestroy(&pDeleter->mutex); (void)taosThreadMutexDestroy(&pDeleter->mutex);
nodesDestroyNode((SNode*)pDeleter->pSinkNode);
pDeleter->pSinkNode = NULL;
taosMemoryFree(pDeleter->pManager); taosMemoryFree(pDeleter->pManager);
@ -270,8 +274,18 @@ static int32_t getCacheSize(struct SDataSinkHandle* pHandle, uint64_t* size) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
int32_t createDataDeleter(SDataSinkManager* pManager, const SDataSinkNode* pDataSink, DataSinkHandle* pHandle,
static int32_t getSinkFlags(struct SDataSinkHandle* pHandle, uint64_t* pFlags) {
SDataDeleterHandle* pDispatcher = (SDataDeleterHandle*)pHandle;
*pFlags = atomic_load_64(&pDispatcher->flags);
return TSDB_CODE_SUCCESS;
}
int32_t createDataDeleter(SDataSinkManager* pManager, SDataSinkNode** ppDataSink, DataSinkHandle* pHandle,
void* pParam) { void* pParam) {
SDataSinkNode* pDataSink = *ppDataSink;
int32_t code = TSDB_CODE_SUCCESS; int32_t code = TSDB_CODE_SUCCESS;
if (pParam == NULL) { if (pParam == NULL) {
code = TSDB_CODE_QRY_INVALID_INPUT; code = TSDB_CODE_QRY_INVALID_INPUT;
@ -296,9 +310,12 @@ int32_t createDataDeleter(SDataSinkManager* pManager, const SDataSinkNode* pData
deleter->sink.fGetData = getDataBlock; deleter->sink.fGetData = getDataBlock;
deleter->sink.fDestroy = destroyDataSinker; deleter->sink.fDestroy = destroyDataSinker;
deleter->sink.fGetCacheSize = getCacheSize; deleter->sink.fGetCacheSize = getCacheSize;
deleter->sink.fGetFlags = getSinkFlags;
deleter->pManager = pManager; deleter->pManager = pManager;
deleter->pDeleter = pDeleterNode; deleter->pDeleter = pDeleterNode;
deleter->pSchema = pDataSink->pInputDataBlockDesc; deleter->pSchema = pDataSink->pInputDataBlockDesc;
deleter->pSinkNode = pDataSink;
*ppDataSink = NULL;
deleter->pParam = pParam; deleter->pParam = pParam;
deleter->status = DS_BUF_EMPTY; deleter->status = DS_BUF_EMPTY;
@ -307,6 +324,7 @@ int32_t createDataDeleter(SDataSinkManager* pManager, const SDataSinkNode* pData
if (code) { if (code) {
goto _end; goto _end;
} }
deleter->flags = DS_FLAG_USE_MEMPOOL;
code = taosThreadMutexInit(&deleter->mutex, NULL); code = taosThreadMutexInit(&deleter->mutex, NULL);
if (code) { if (code) {
goto _end; goto _end;
@ -323,6 +341,9 @@ _end:
} else { } else {
taosMemoryFree(pManager); taosMemoryFree(pManager);
} }
nodesDestroyNode((SNode *)*ppDataSink);
*ppDataSink = NULL;
return code; return code;
} }

View File

@ -43,6 +43,7 @@ typedef struct SDataDispatchHandle {
SDataSinkHandle sink; SDataSinkHandle sink;
SDataSinkManager* pManager; SDataSinkManager* pManager;
SDataBlockDescNode* pSchema; SDataBlockDescNode* pSchema;
SDataSinkNode* pSinkNode;
STaosQueue* pDataBlocks; STaosQueue* pDataBlocks;
SDataDispatchBuf nextOutput; SDataDispatchBuf nextOutput;
int32_t outPutColCounts; int32_t outPutColCounts;
@ -50,6 +51,7 @@ typedef struct SDataDispatchHandle {
bool queryEnd; bool queryEnd;
uint64_t useconds; uint64_t useconds;
uint64_t cachedSize; uint64_t cachedSize;
uint64_t flags;
void* pCompressBuf; void* pCompressBuf;
int32_t bufSize; int32_t bufSize;
TdThreadMutex mutex; TdThreadMutex mutex;
@ -355,6 +357,7 @@ static int32_t destroyDataSinker(SDataSinkHandle* pHandle) {
SDataDispatchHandle* pDispatcher = (SDataDispatchHandle*)pHandle; SDataDispatchHandle* pDispatcher = (SDataDispatchHandle*)pHandle;
(void)atomic_sub_fetch_64(&gDataSinkStat.cachedSize, pDispatcher->cachedSize); (void)atomic_sub_fetch_64(&gDataSinkStat.cachedSize, pDispatcher->cachedSize);
taosMemoryFreeClear(pDispatcher->nextOutput.pData); taosMemoryFreeClear(pDispatcher->nextOutput.pData);
nodesDestroyNode((SNode*)pDispatcher->pSinkNode);
while (!taosQueueEmpty(pDispatcher->pDataBlocks)) { while (!taosQueueEmpty(pDispatcher->pDataBlocks)) {
SDataDispatchBuf* pBuf = NULL; SDataDispatchBuf* pBuf = NULL;
@ -381,6 +384,13 @@ static int32_t getCacheSize(struct SDataSinkHandle* pHandle, uint64_t* size) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
static int32_t getSinkFlags(struct SDataSinkHandle* pHandle, uint64_t* pFlags) {
SDataDispatchHandle* pDispatcher = (SDataDispatchHandle*)pHandle;
*pFlags = atomic_load_64(&pDispatcher->flags);
return TSDB_CODE_SUCCESS;
}
static int32_t blockDescNodeCheck(SDataBlockDescNode* pInputDataBlockDesc) { static int32_t blockDescNodeCheck(SDataBlockDescNode* pInputDataBlockDesc) {
if(tsSafetyCheckLevel == TSDB_SAFETY_CHECK_LEVELL_NEVER) { if(tsSafetyCheckLevel == TSDB_SAFETY_CHECK_LEVELL_NEVER) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
@ -428,12 +438,13 @@ int32_t getOutputColCounts(SDataBlockDescNode* pInputDataBlockDesc) {
return numOfCols; return numOfCols;
} }
int32_t createDataDispatcher(SDataSinkManager* pManager, const SDataSinkNode* pDataSink, DataSinkHandle* pHandle) { int32_t createDataDispatcher(SDataSinkManager* pManager, SDataSinkNode** ppDataSink, DataSinkHandle* pHandle) {
int32_t code; int32_t code;
SDataSinkNode* pDataSink = *ppDataSink;
code = blockDescNodeCheck(pDataSink->pInputDataBlockDesc); code = blockDescNodeCheck(pDataSink->pInputDataBlockDesc);
if (code) { if (code) {
qError("failed to check input data block desc, code:%d", code); qError("failed to check input data block desc, code:%d", code);
return code; goto _return;
} }
SDataDispatchHandle* dispatcher = taosMemoryCalloc(1, sizeof(SDataDispatchHandle)); SDataDispatchHandle* dispatcher = taosMemoryCalloc(1, sizeof(SDataDispatchHandle));
@ -448,10 +459,12 @@ int32_t createDataDispatcher(SDataSinkManager* pManager, const SDataSinkNode* pD
dispatcher->sink.fGetData = getDataBlock; dispatcher->sink.fGetData = getDataBlock;
dispatcher->sink.fDestroy = destroyDataSinker; dispatcher->sink.fDestroy = destroyDataSinker;
dispatcher->sink.fGetCacheSize = getCacheSize; dispatcher->sink.fGetCacheSize = getCacheSize;
dispatcher->sink.fGetFlags = getSinkFlags;
dispatcher->pManager = pManager; dispatcher->pManager = pManager;
pManager = NULL; pManager = NULL;
dispatcher->pSchema = pDataSink->pInputDataBlockDesc; dispatcher->pSchema = pDataSink->pInputDataBlockDesc;
dispatcher->pSinkNode = pDataSink;
*ppDataSink = NULL;
dispatcher->outPutColCounts = getOutputColCounts(dispatcher->pSchema); dispatcher->outPutColCounts = getOutputColCounts(dispatcher->pSchema);
dispatcher->status = DS_BUF_EMPTY; dispatcher->status = DS_BUF_EMPTY;
dispatcher->queryEnd = false; dispatcher->queryEnd = false;
@ -466,6 +479,8 @@ int32_t createDataDispatcher(SDataSinkManager* pManager, const SDataSinkNode* pD
goto _return; goto _return;
} }
dispatcher->flags = DS_FLAG_USE_MEMPOOL;
*pHandle = dispatcher; *pHandle = dispatcher;
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
@ -476,5 +491,9 @@ _return:
if (dispatcher) { if (dispatcher) {
dsDestroyDataSinker(dispatcher); dsDestroyDataSinker(dispatcher);
} }
nodesDestroyNode((SNode *)*ppDataSink);
*ppDataSink = NULL;
return terrno; return terrno;
} }

View File

@ -45,6 +45,7 @@ typedef struct SDataInserterHandle {
bool fullOrderColList; bool fullOrderColList;
uint64_t useconds; uint64_t useconds;
uint64_t cachedSize; uint64_t cachedSize;
uint64_t flags;
TdThreadMutex mutex; TdThreadMutex mutex;
tsem_t ready; tsem_t ready;
bool explain; bool explain;
@ -138,7 +139,7 @@ static int32_t sendSubmitRequest(SDataInserterHandle* pInserter, void* pMsg, int
pParam->pInserter = pInserter; pParam->pInserter = pInserter;
pMsgSendInfo->param = pParam; pMsgSendInfo->param = pParam;
pMsgSendInfo->paramFreeFp = taosMemoryFree; pMsgSendInfo->paramFreeFp = taosAutoMemoryFree;
pMsgSendInfo->msgInfo.pData = pMsg; pMsgSendInfo->msgInfo.pData = pMsg;
pMsgSendInfo->msgInfo.len = msgLen; pMsgSendInfo->msgInfo.len = msgLen;
pMsgSendInfo->msgType = TDMT_VND_SUBMIT; pMsgSendInfo->msgType = TDMT_VND_SUBMIT;
@ -434,6 +435,9 @@ static int32_t destroyDataSinker(SDataSinkHandle* pHandle) {
taosMemoryFree(pInserter->pSchema); taosMemoryFree(pInserter->pSchema);
taosMemoryFree(pInserter->pParam); taosMemoryFree(pInserter->pParam);
taosHashCleanup(pInserter->pCols); taosHashCleanup(pInserter->pCols);
nodesDestroyNode((SNode *)pInserter->pNode);
pInserter->pNode = NULL;
(void)taosThreadMutexDestroy(&pInserter->mutex); (void)taosThreadMutexDestroy(&pInserter->mutex);
taosMemoryFree(pInserter->pManager); taosMemoryFree(pInserter->pManager);
@ -447,8 +451,16 @@ static int32_t getCacheSize(struct SDataSinkHandle* pHandle, uint64_t* size) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
int32_t createDataInserter(SDataSinkManager* pManager, const SDataSinkNode* pDataSink, DataSinkHandle* pHandle, static int32_t getSinkFlags(struct SDataSinkHandle* pHandle, uint64_t* pFlags) {
SDataInserterHandle* pDispatcher = (SDataInserterHandle*)pHandle;
*pFlags = atomic_load_64(&pDispatcher->flags);
return TSDB_CODE_SUCCESS;
}
int32_t createDataInserter(SDataSinkManager* pManager, SDataSinkNode** ppDataSink, DataSinkHandle* pHandle,
void* pParam) { void* pParam) {
SDataSinkNode* pDataSink = *ppDataSink;
SDataInserterHandle* inserter = taosMemoryCalloc(1, sizeof(SDataInserterHandle)); SDataInserterHandle* inserter = taosMemoryCalloc(1, sizeof(SDataInserterHandle));
if (NULL == inserter) { if (NULL == inserter) {
taosMemoryFree(pParam); taosMemoryFree(pParam);
@ -462,12 +474,14 @@ int32_t createDataInserter(SDataSinkManager* pManager, const SDataSinkNode* pDat
inserter->sink.fGetData = NULL; inserter->sink.fGetData = NULL;
inserter->sink.fDestroy = destroyDataSinker; inserter->sink.fDestroy = destroyDataSinker;
inserter->sink.fGetCacheSize = getCacheSize; inserter->sink.fGetCacheSize = getCacheSize;
inserter->sink.fGetFlags = getSinkFlags;
inserter->pManager = pManager; inserter->pManager = pManager;
inserter->pNode = pInserterNode; inserter->pNode = pInserterNode;
inserter->pParam = pParam; inserter->pParam = pParam;
inserter->status = DS_BUF_EMPTY; inserter->status = DS_BUF_EMPTY;
inserter->queryEnd = false; inserter->queryEnd = false;
inserter->explain = pInserterNode->explain; inserter->explain = pInserterNode->explain;
*ppDataSink = NULL;
int64_t suid = 0; int64_t suid = 0;
int32_t code = pManager->pAPI->metaFn.getTableSchema(inserter->pParam->readHandle->vnode, pInserterNode->tableId, int32_t code = pManager->pAPI->metaFn.getTableSchema(inserter->pParam->readHandle->vnode, pInserterNode->tableId,
@ -521,5 +535,8 @@ _return:
taosMemoryFree(pManager); taosMemoryFree(pManager);
} }
nodesDestroyNode((SNode *)*ppDataSink);
*ppDataSink = NULL;
return terrno; return terrno;
} }

View File

@ -39,23 +39,23 @@ int32_t dsDataSinkGetCacheSize(SDataSinkStat* pStat) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
int32_t dsCreateDataSinker(void* pSinkManager, const SDataSinkNode* pDataSink, DataSinkHandle* pHandle, void* pParam, const char* id) { int32_t dsCreateDataSinker(void* pSinkManager, SDataSinkNode** ppDataSink, DataSinkHandle* pHandle, void* pParam, const char* id) {
SDataSinkManager* pManager = pSinkManager; SDataSinkManager* pManager = pSinkManager;
switch ((int)nodeType(pDataSink)) { switch ((int)nodeType(*ppDataSink)) {
case QUERY_NODE_PHYSICAL_PLAN_DISPATCH: case QUERY_NODE_PHYSICAL_PLAN_DISPATCH:
return createDataDispatcher(pManager, pDataSink, pHandle); return createDataDispatcher(pManager, ppDataSink, pHandle);
case QUERY_NODE_PHYSICAL_PLAN_DELETE: { case QUERY_NODE_PHYSICAL_PLAN_DELETE: {
return createDataDeleter(pManager, pDataSink, pHandle, pParam); return createDataDeleter(pManager, ppDataSink, pHandle, pParam);
} }
case QUERY_NODE_PHYSICAL_PLAN_QUERY_INSERT: { case QUERY_NODE_PHYSICAL_PLAN_QUERY_INSERT: {
return createDataInserter(pManager, pDataSink, pHandle, pParam); return createDataInserter(pManager, ppDataSink, pHandle, pParam);
} }
default: default:
break; break;
} }
taosMemoryFree(pSinkManager); taosMemoryFree(pSinkManager);
qError("invalid input node type:%d, %s", nodeType(pDataSink), id); qError("invalid input node type:%d, %s", nodeType(*ppDataSink), id);
return TSDB_CODE_QRY_INVALID_INPUT; return TSDB_CODE_QRY_INVALID_INPUT;
} }
@ -101,3 +101,9 @@ void dsDestroyDataSinker(DataSinkHandle handle) {
(void)pHandleImpl->fDestroy(pHandleImpl); (void)pHandleImpl->fDestroy(pHandleImpl);
taosMemoryFree(pHandleImpl); taosMemoryFree(pHandleImpl);
} }
int32_t dsGetSinkFlags(DataSinkHandle handle, uint64_t* pFlags) {
SDataSinkHandle* pHandleImpl = (SDataSinkHandle*)handle;
return pHandleImpl->fGetFlags(pHandleImpl, pFlags);
}

View File

@ -354,15 +354,15 @@ static int32_t initExchangeOperator(SExchangePhysiNode* pExNode, SExchangeInfo*
pInfo->pSources = taosArrayInit(numOfSources, sizeof(SDownstreamSourceNode)); pInfo->pSources = taosArrayInit(numOfSources, sizeof(SDownstreamSourceNode));
if (pInfo->pSources == NULL) { 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; return terrno;
} }
if (pExNode->node.dynamicOp) { if (pExNode->node.dynamicOp) {
pInfo->pHashSources = tSimpleHashInit(numOfSources * 2, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT)); pInfo->pHashSources = tSimpleHashInit(numOfSources * 2, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT));
if (NULL == pInfo->pHashSources) { if (NULL == pInfo->pHashSources) {
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 TSDB_CODE_OUT_OF_MEMORY; return terrno;
} }
} }
@ -370,7 +370,7 @@ static int32_t initExchangeOperator(SExchangePhysiNode* pExNode, SExchangeInfo*
SDownstreamSourceNode* pNode = (SDownstreamSourceNode*)nodesListGetNode((SNodeList*)pExNode->pSrcEndPoints, i); SDownstreamSourceNode* pNode = (SDownstreamSourceNode*)nodesListGetNode((SNodeList*)pExNode->pSrcEndPoints, i);
if (!pNode) { if (!pNode) {
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(terrno)); 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); void* tmp = taosArrayPush(pInfo->pSources, pNode);
if (!tmp) { if (!tmp) {
@ -640,16 +640,16 @@ int32_t doSendFetchDataRequest(SExchangeInfo* pExchangeInfo, SExecTaskInfo* pTas
if (pSource->localExec) { if (pSource->localExec) {
SDataBuf pBuf = {0}; SDataBuf pBuf = {0};
int32_t code = (*pTaskInfo->localFetch.fp)(pTaskInfo->localFetch.handle, pSource->schedId, pTaskInfo->id.queryId, int32_t code = (*pTaskInfo->localFetch.fp)(pTaskInfo->localFetch.handle, pSource->sId, pTaskInfo->id.queryId,
pSource->clientId, pSource->taskId, 0, pSource->execId, &pBuf.pData, pSource->clientId, pSource->taskId, 0, pSource->execId, &pBuf.pData,
pTaskInfo->localFetch.explainRes); pTaskInfo->localFetch.explainRes);
code = loadRemoteDataCallback(pWrapper, &pBuf, code); code = loadRemoteDataCallback(pWrapper, &pBuf, code);
QUERY_CHECK_CODE(code, lino, _end);
taosMemoryFree(pWrapper); taosMemoryFree(pWrapper);
QUERY_CHECK_CODE(code, lino, _end);
} else { } else {
SResFetchReq req = {0}; SResFetchReq req = {0};
req.header.vgId = pSource->addr.nodeId; req.header.vgId = pSource->addr.nodeId;
req.sId = pSource->schedId; req.sId = pSource->sId;
req.clientId = pSource->clientId; req.clientId = pSource->clientId;
req.taskId = pSource->taskId; req.taskId = pSource->taskId;
req.queryId = pTaskInfo->id.queryId; req.queryId = pTaskInfo->id.queryId;
@ -668,7 +668,7 @@ int32_t doSendFetchDataRequest(SExchangeInfo* pExchangeInfo, SExecTaskInfo* pTas
int32_t msgSize = tSerializeSResFetchReq(NULL, 0, &req); int32_t msgSize = tSerializeSResFetchReq(NULL, 0, &req);
if (msgSize < 0) { if (msgSize < 0) {
pTaskInfo->code = TSDB_CODE_OUT_OF_MEMORY; pTaskInfo->code = msgSize;
taosMemoryFree(pWrapper); taosMemoryFree(pWrapper);
freeOperatorParam(req.pOpParam, OP_GET_PARAM); freeOperatorParam(req.pOpParam, OP_GET_PARAM);
return pTaskInfo->code; return pTaskInfo->code;
@ -676,14 +676,15 @@ int32_t doSendFetchDataRequest(SExchangeInfo* pExchangeInfo, SExecTaskInfo* pTas
void* msg = taosMemoryCalloc(1, msgSize); void* msg = taosMemoryCalloc(1, msgSize);
if (NULL == msg) { if (NULL == msg) {
pTaskInfo->code = TSDB_CODE_OUT_OF_MEMORY; pTaskInfo->code = terrno;
taosMemoryFree(pWrapper); taosMemoryFree(pWrapper);
freeOperatorParam(req.pOpParam, OP_GET_PARAM); freeOperatorParam(req.pOpParam, OP_GET_PARAM);
return pTaskInfo->code; return pTaskInfo->code;
} }
if (tSerializeSResFetchReq(msg, msgSize, &req) < 0) { msgSize = tSerializeSResFetchReq(msg, msgSize, &req);
pTaskInfo->code = TSDB_CODE_OUT_OF_MEMORY; if (msgSize < 0) {
pTaskInfo->code = msgSize;
taosMemoryFree(pWrapper); taosMemoryFree(pWrapper);
taosMemoryFree(msg); taosMemoryFree(msg);
freeOperatorParam(req.pOpParam, OP_GET_PARAM); freeOperatorParam(req.pOpParam, OP_GET_PARAM);
@ -703,18 +704,19 @@ int32_t doSendFetchDataRequest(SExchangeInfo* pExchangeInfo, SExecTaskInfo* pTas
taosMemoryFreeClear(msg); taosMemoryFreeClear(msg);
taosMemoryFree(pWrapper); taosMemoryFree(pWrapper);
qError("%s prepare message %d failed", GET_TASKID(pTaskInfo), (int32_t)sizeof(SMsgSendInfo)); 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; return pTaskInfo->code;
} }
pMsgSendInfo->param = pWrapper; pMsgSendInfo->param = pWrapper;
pMsgSendInfo->paramFreeFp = taosMemoryFree; pMsgSendInfo->paramFreeFp = taosAutoMemoryFree;
pMsgSendInfo->msgInfo.pData = msg; pMsgSendInfo->msgInfo.pData = msg;
pMsgSendInfo->msgInfo.len = msgSize; pMsgSendInfo->msgInfo.len = msgSize;
pMsgSendInfo->msgType = pSource->fetchMsgType; pMsgSendInfo->msgType = pSource->fetchMsgType;
pMsgSendInfo->fp = loadRemoteDataCallback; pMsgSendInfo->fp = loadRemoteDataCallback;
int64_t transporterId = 0; int64_t transporterId = 0;
void* poolHandle = NULL;
code = asyncSendMsgToServer(pExchangeInfo->pTransporter, &pSource->addr.epSet, &transporterId, pMsgSendInfo); code = asyncSendMsgToServer(pExchangeInfo->pTransporter, &pSource->addr.epSet, &transporterId, pMsgSendInfo);
QUERY_CHECK_CODE(code, lino, _end); QUERY_CHECK_CODE(code, lino, _end);
int64_t* pRpcHandle = taosArrayGet(pExchangeInfo->pFetchRpcHandles, sourceIndex); int64_t* pRpcHandle = taosArrayGet(pExchangeInfo->pFetchRpcHandles, sourceIndex);
@ -898,7 +900,7 @@ int32_t doExtractResultBlocks(SExchangeInfo* pExchangeInfo, SSourceDataInfo* pDa
blockDataCleanup(pb); blockDataCleanup(pb);
} else { } else {
code = createOneDataBlock(pExchangeInfo->pDummyBlock, false, &pb); 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; int32_t compLen = *(int32_t*)pStart;
@ -1055,7 +1057,7 @@ int32_t addSingleExchangeSource(SOperatorInfo* pOperator, SExchangeOperatorBasic
void* tmp = taosArrayPush(pExchangeInfo->pSourceDataInfo, &dataInfo); void* tmp = taosArrayPush(pExchangeInfo->pSourceDataInfo, &dataInfo);
if (!tmp) { 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 terrno;
} }
pIdx->inUseIdx = taosArrayGetSize(pExchangeInfo->pSourceDataInfo) - 1; pIdx->inUseIdx = taosArrayGetSize(pExchangeInfo->pSourceDataInfo) - 1;

View File

@ -332,7 +332,6 @@ SArray* createSortInfo(SNodeList* pNodeList) {
SArray* pList = taosArrayInit(numOfCols, sizeof(SBlockOrderInfo)); SArray* pList = taosArrayInit(numOfCols, sizeof(SBlockOrderInfo));
if (pList == NULL) { if (pList == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return pList; return pList;
} }
@ -342,7 +341,7 @@ SArray* createSortInfo(SNodeList* pNodeList) {
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(terrno)); qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(terrno));
taosArrayDestroy(pList); taosArrayDestroy(pList);
pList = NULL; pList = NULL;
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR;
break; break;
} }
SBlockOrderInfo bi = {0}; SBlockOrderInfo bi = {0};
@ -355,7 +354,6 @@ SArray* createSortInfo(SNodeList* pNodeList) {
if (!tmp) { if (!tmp) {
taosArrayDestroy(pList); taosArrayDestroy(pList);
pList = NULL; pList = NULL;
terrno = TSDB_CODE_OUT_OF_MEMORY;
break; break;
} }
} }
@ -1129,7 +1127,7 @@ static int32_t optimizeTbnameInCondImpl(void* pVnode, SArray* pExistedUidList, S
if (numOfExisted > 0) { if (numOfExisted > 0) {
uHash = taosHashInit(numOfExisted / 0.7, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK); uHash = taosHashInit(numOfExisted / 0.7, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
if (!uHash) { 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; return terrno;
} }
@ -1330,7 +1328,7 @@ static int32_t copyExistedUids(SArray* pUidTagList, const SArray* pUidList) {
STUidTagInfo info = {.uid = *uid}; STUidTagInfo info = {.uid = *uid};
void* tmp = taosArrayPush(pUidTagList, &info); void* tmp = taosArrayPush(pUidTagList, &info);
if (!tmp) { 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; return code;
} }
} }
@ -1356,15 +1354,13 @@ static int32_t doFilterByTagCond(STableListInfo* pListInfo, SArray* pUidList, SN
tagFilterAssist ctx = {0}; tagFilterAssist ctx = {0};
ctx.colHash = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_SMALLINT), false, HASH_NO_LOCK); ctx.colHash = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_SMALLINT), false, HASH_NO_LOCK);
if (ctx.colHash == NULL) { if (ctx.colHash == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; code = terrno;
code = TSDB_CODE_OUT_OF_MEMORY;
QUERY_CHECK_CODE(code, lino, end); QUERY_CHECK_CODE(code, lino, end);
} }
ctx.cInfoList = taosArrayInit(4, sizeof(SColumnInfo)); ctx.cInfoList = taosArrayInit(4, sizeof(SColumnInfo));
if (ctx.cInfoList == NULL) { if (ctx.cInfoList == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; code = terrno;
code = TSDB_CODE_OUT_OF_MEMORY;
QUERY_CHECK_CODE(code, lino, end); QUERY_CHECK_CODE(code, lino, end);
} }
@ -1705,6 +1701,7 @@ int32_t getGroupIdFromTagsVal(void* pVnode, uint64_t uid, SNodeList* pGroupNode,
nodesDestroyList(groupNew); nodesDestroyList(groupNew);
pAPI->metaReaderFn.clearReader(&mr); pAPI->metaReaderFn.clearReader(&mr);
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
@ -1716,7 +1713,6 @@ SArray* makeColumnArrayFromList(SNodeList* pNodeList) {
size_t numOfCols = LIST_LENGTH(pNodeList); size_t numOfCols = LIST_LENGTH(pNodeList);
SArray* pList = taosArrayInit(numOfCols, sizeof(SColumn)); SArray* pList = taosArrayInit(numOfCols, sizeof(SColumn));
if (pList == NULL) { if (pList == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL; return NULL;
} }
@ -1724,7 +1720,7 @@ SArray* makeColumnArrayFromList(SNodeList* pNodeList) {
SColumnNode* pColNode = (SColumnNode*)nodesListGetNode(pNodeList, i); SColumnNode* pColNode = (SColumnNode*)nodesListGetNode(pNodeList, i);
if (!pColNode) { if (!pColNode) {
taosArrayDestroy(pList); 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; return NULL;
} }
@ -1740,7 +1736,7 @@ SArray* makeColumnArrayFromList(SNodeList* pNodeList) {
void* tmp = taosArrayPush(pList, &c); void* tmp = taosArrayPush(pList, &c);
if (!tmp) { if (!tmp) {
taosArrayDestroy(pList); 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; return NULL;
} }
} }
@ -1835,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) { static SColumn* createColumn(int32_t blockId, int32_t slotId, int32_t colId, SDataType* pType, EColumnType colType) {
SColumn* pCol = taosMemoryCalloc(1, sizeof(SColumn)); SColumn* pCol = taosMemoryCalloc(1, sizeof(SColumn));
if (pCol == NULL) { if (pCol == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL; return NULL;
} }
@ -2174,7 +2169,7 @@ SqlFunctionCtx* createSqlFunctionCtx(SExprInfo* pExprInfo, int32_t numOfOutput,
} }
bool tmp = pCtx->fpSet.getEnv(pExpr->pExpr->_function.pFunctNode, &env); bool tmp = pCtx->fpSet.getEnv(pExpr->pExpr->_function.pFunctNode, &env);
if (!tmp) { if (!tmp) {
code = TSDB_CODE_OUT_OF_MEMORY; code = terrno;
QUERY_CHECK_CODE(code, lino, _end); QUERY_CHECK_CODE(code, lino, _end);
} }
} else { } else {
@ -2187,7 +2182,7 @@ SqlFunctionCtx* createSqlFunctionCtx(SExprInfo* pExprInfo, int32_t numOfOutput,
if (pCtx->sfp.getEnv != NULL) { if (pCtx->sfp.getEnv != NULL) {
bool tmp = pCtx->sfp.getEnv(pExpr->pExpr->_function.pFunctNode, &env); bool tmp = pCtx->sfp.getEnv(pExpr->pExpr->_function.pFunctNode, &env);
if (!tmp) { if (!tmp) {
code = TSDB_CODE_OUT_OF_MEMORY; code = terrno;
QUERY_CHECK_CODE(code, lino, _end); QUERY_CHECK_CODE(code, lino, _end);
} }
} }
@ -2236,6 +2231,8 @@ _end:
} }
taosMemoryFreeClear(*rowEntryInfoOffset); taosMemoryFreeClear(*rowEntryInfoOffset);
taosMemoryFreeClear(pFuncCtx); taosMemoryFreeClear(pFuncCtx);
terrno = code;
return NULL; return NULL;
} }
return pFuncCtx; return pFuncCtx;
@ -3073,6 +3070,7 @@ SNodeList* makeColsNodeArrFromSortKeys(SNodeList* pSortKeys) {
int32_t code = nodesListMakeAppend(&ret, pSortKey->pExpr); int32_t code = nodesListMakeAppend(&ret, pSortKey->pExpr);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(code)); qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(code));
terrno = code;
return NULL; return NULL;
} }
} }
@ -3098,3 +3096,4 @@ _end:
} }
return code; return code;
} }

View File

@ -441,6 +441,7 @@ static int32_t filterUnqualifiedTables(const SStreamScanInfo* pScanInfo, const S
} }
_end: _end:
pAPI->metaReaderFn.clearReader(&mr); pAPI->metaReaderFn.clearReader(&mr);
(*ppArrayRes) = qa; (*ppArrayRes) = qa;
@ -599,6 +600,11 @@ void qUpdateOperatorParam(qTaskInfo_t tinfo, void* pParam) {
((SExecTaskInfo*)tinfo)->paramSet = false; ((SExecTaskInfo*)tinfo)->paramSet = false;
} }
int32_t qExecutorInit(void) {
taosThreadOnce(&initPoolOnce, initRefPool);
return TSDB_CODE_SUCCESS;
}
int32_t qCreateExecTask(SReadHandle* readHandle, int32_t vgId, uint64_t taskId, SSubplan* pSubplan, int32_t qCreateExecTask(SReadHandle* readHandle, int32_t vgId, uint64_t taskId, SSubplan* pSubplan,
qTaskInfo_t* pTaskInfo, DataSinkHandle* handle, int8_t compressResult, char* sql, qTaskInfo_t* pTaskInfo, DataSinkHandle* handle, int8_t compressResult, char* sql,
EOPTR_EXEC_MODEL model) { EOPTR_EXEC_MODEL model) {
@ -630,8 +636,18 @@ int32_t qCreateExecTask(SReadHandle* readHandle, int32_t vgId, uint64_t taskId,
goto _error; goto _error;
} }
SDataSinkNode* pSink = NULL;
if (readHandle->localExec) {
code = nodesCloneNode((SNode *)pSubplan->pDataSink, (SNode **)&pSink);
if (code != TSDB_CODE_SUCCESS) {
qError("failed to nodesCloneNode, srcType:%d, code:%s, %s", nodeType(pSubplan->pDataSink), tstrerror(code), (*pTask)->id.str);
taosMemoryFree(pSinkManager);
goto _error;
}
}
// pSinkParam has been freed during create sinker. // pSinkParam has been freed during create sinker.
code = dsCreateDataSinker(pSinkManager, pSubplan->pDataSink, handle, pSinkParam, (*pTask)->id.str); code = dsCreateDataSinker(pSinkManager, readHandle->localExec ? &pSink : &pSubplan->pDataSink, handle, pSinkParam, (*pTask)->id.str);
if (code) { if (code) {
qError("s-task:%s failed to create data sinker, code:%s", (*pTask)->id.str, tstrerror(code)); qError("s-task:%s failed to create data sinker, code:%s", (*pTask)->id.str, tstrerror(code));
} }
@ -726,7 +742,7 @@ int32_t qExecTaskOpt(qTaskInfo_t tinfo, SArray* pResList, uint64_t* useconds, bo
QUERY_CHECK_CODE(code, lino, _end); QUERY_CHECK_CODE(code, lino, _end);
void* tmp = taosArrayPush(pTaskInfo->pResultBlockList, &p1); 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; p = p1;
} else { } else {
void* tmp = taosArrayGet(pTaskInfo->pResultBlockList, blockIndex); void* tmp = taosArrayGet(pTaskInfo->pResultBlockList, blockIndex);
@ -881,7 +897,7 @@ int32_t qAppendTaskStopInfo(SExecTaskInfo* pTaskInfo, SExchangeOpStopInfo* pInfo
taosWUnLockLatch(&pTaskInfo->stopInfo.lock); taosWUnLockLatch(&pTaskInfo->stopInfo.lock);
if (!tmp) { 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 terrno;
} }
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
@ -1570,8 +1586,7 @@ void qProcessRspMsg(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet) {
if (pMsg->contLen > 0) { if (pMsg->contLen > 0) {
buf.pData = taosMemoryCalloc(1, pMsg->contLen); buf.pData = taosMemoryCalloc(1, pMsg->contLen);
if (buf.pData == NULL) { if (buf.pData == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; pMsg->code = terrno;
pMsg->code = TSDB_CODE_OUT_OF_MEMORY;
} else { } else {
memcpy(buf.pData, pMsg->pCont, pMsg->contLen); memcpy(buf.pData, pMsg->pCont, pMsg->contLen);
} }
@ -1590,7 +1605,6 @@ SArray* qGetQueriedTableListInfo(qTaskInfo_t tinfo) {
code = getTableListInfo(pTaskInfo, &plist); code = getTableListInfo(pTaskInfo, &plist);
if (code || plist == NULL) { if (code || plist == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY;
return NULL; return NULL;
} }

View File

@ -438,9 +438,6 @@ static int32_t doCreateConstantValColumnSMAInfo(SInputColumnInfoData* pInput, SF
return terrno; return terrno;
} }
pInput->pColumnDataAgg[paramIndex] = da; pInput->pColumnDataAgg[paramIndex] = da;
if (da == NULL) {
return TSDB_CODE_OUT_OF_MEMORY;
}
} else { } else {
da = pInput->pColumnDataAgg[paramIndex]; da = pInput->pColumnDataAgg[paramIndex];
} }
@ -974,7 +971,7 @@ void destroyExprInfo(SExprInfo* pExpr, int32_t numOfExprs) {
} }
} }
int32_t getBufferPgSize(int32_t rowSize, uint32_t* defaultPgsz, uint32_t* defaultBufsz) { int32_t getBufferPgSize(int32_t rowSize, uint32_t* defaultPgsz, int64_t* defaultBufsz) {
*defaultPgsz = 4096; *defaultPgsz = 4096;
uint32_t last = *defaultPgsz; uint32_t last = *defaultPgsz;
while (*defaultPgsz < rowSize * 4) { while (*defaultPgsz < rowSize * 4) {
@ -1056,7 +1053,7 @@ int32_t initExprSupp(SExprSupp* pSup, SExprInfo* pExprInfo, int32_t numOfExpr, S
if (pSup->pExprInfo != NULL) { if (pSup->pExprInfo != NULL) {
pSup->pCtx = createSqlFunctionCtx(pExprInfo, numOfExpr, &pSup->rowEntryInfoOffset, pStore); pSup->pCtx = createSqlFunctionCtx(pExprInfo, numOfExpr, &pSup->rowEntryInfoOffset, pStore);
if (pSup->pCtx == NULL) { 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) { if (!pTable) {
taosArrayDestroy(pDeleterParam->pUidList); taosArrayDestroy(pDeleterParam->pUidList);
taosMemoryFree(pDeleterParam); taosMemoryFree(pDeleterParam);
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR;
} }
void* tmp = taosArrayPush(pDeleterParam->pUidList, &pTable->uid); void* tmp = taosArrayPush(pDeleterParam->pUidList, &pTable->uid);
if (!tmp) { if (!tmp) {

View File

@ -387,10 +387,10 @@ static int32_t initFillInfo(SFillOperatorInfo* pInfo, SExprInfo* pExpr, int32_t
return terrno; return terrno;
} }
if (pInfo->pFillInfo == NULL || pInfo->p == NULL) { if (pInfo->pFillInfo == NULL) {
taosMemoryFree(pInfo->pFillInfo); taosMemoryFree(pInfo->pFillInfo);
taosMemoryFree(pInfo->p); taosMemoryFree(pInfo->p);
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR;
} else { } else {
return TSDB_CODE_SUCCESS; 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) { 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))) { if (0 != taosHashPut(pCache->pDirtyBlk, &pBufInfo->basic.blkId, sizeof(pBufInfo->basic.blkId), pBufInfo, sizeof(*pBufInfo))) {
freeGcBlkBufInfo(pBufInfo); freeGcBlkBufInfo(pBufInfo);
return TSDB_CODE_OUT_OF_MEMORY; return terrno;
} }
pBufInfo = taosHashGet(pCache->pDirtyBlk, &pBufInfo->basic.blkId, sizeof(pBufInfo->basic.blkId)); pBufInfo = taosHashGet(pCache->pDirtyBlk, &pBufInfo->basic.blkId, sizeof(pBufInfo->basic.blkId));
if (NULL == pBufInfo) { if (NULL == pBufInfo) {
@ -906,7 +906,7 @@ static int32_t addNewGroupData(struct SOperatorInfo* pOperator, SOperatorParam*
*ppGrp = taosHashGet(pGrpHash, &uid, sizeof(uid)); *ppGrp = taosHashGet(pGrpHash, &uid, sizeof(uid));
if (NULL == *ppGrp) { if (NULL == *ppGrp) {
return TSDB_CODE_OUT_OF_MEMORY; return terrno;
} }
QRY_ERR_RET(initNewGroupData(pCtx, *ppGrp, pParam->downstreamIdx, vgId, pGCache->batchFetch, pGcParam->needCache)); 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) { if (NULL == pGroup->waitQueue) {
pGroup->waitQueue = taosArrayInit(1, POINTER_BYTES); pGroup->waitQueue = taosArrayInit(1, POINTER_BYTES);
if (NULL == pGroup->waitQueue) { if (NULL == pGroup->waitQueue) {
QRY_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); QRY_ERR_JRET(terrno);
} }
} }
if (NULL == taosArrayPush(pGroup->waitQueue, &pSession)) { if (NULL == taosArrayPush(pGroup->waitQueue, &pSession)) {
QRY_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); QRY_ERR_JRET(terrno);
} }
if (!pSession->semInit) { if (!pSession->semInit) {
@ -1413,7 +1413,7 @@ static int32_t initGroupCacheDownstreamCtx(SOperatorInfo* pOperator) {
pCtx->lastBlkUid = 0; pCtx->lastBlkUid = 0;
pCtx->pVgTbHash = tSimpleHashInit(10, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT)); pCtx->pVgTbHash = tSimpleHashInit(10, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT));
if (NULL == pCtx->pVgTbHash) { if (NULL == pCtx->pVgTbHash) {
return TSDB_CODE_OUT_OF_MEMORY; return terrno;
} }
tSimpleHashSetFreeFp(pCtx->pVgTbHash, freeSGcVgroupCtx); tSimpleHashSetFreeFp(pCtx->pVgTbHash, freeSGcVgroupCtx);

View File

@ -614,7 +614,6 @@ SSDataBlock* createBlockDataNotLoaded(const SOperatorInfo* pOperator, SSDataBloc
if (pDataBlock->pBlockAgg) { if (pDataBlock->pBlockAgg) {
pDstBlock->pBlockAgg = taosMemoryCalloc(numOfCols, sizeof(SColumnDataAgg)); pDstBlock->pBlockAgg = taosMemoryCalloc(numOfCols, sizeof(SColumnDataAgg));
if (pDstBlock->pBlockAgg == NULL) { if (pDstBlock->pBlockAgg == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
blockDataDestroy(pDstBlock); blockDataDestroy(pDstBlock);
return NULL; return NULL;
} }
@ -1161,7 +1160,7 @@ int32_t createPartitionOperatorInfo(SOperatorInfo* downstream, SPartitionPhysiNo
} }
uint32_t defaultPgsz = 0; uint32_t defaultPgsz = 0;
uint32_t defaultBufsz = 0; int64_t defaultBufsz = 0;
pInfo->binfo.pRes = createDataBlockFromDescNode(pPartNode->node.pOutputDataBlockDesc); pInfo->binfo.pRes = createDataBlockFromDescNode(pPartNode->node.pOutputDataBlockDesc);
QUERY_CHECK_NULL(pInfo->binfo.pRes, code, lino, _error, terrno); QUERY_CHECK_NULL(pInfo->binfo.pRes, code, lino, _error, terrno);

View File

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

View File

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

View File

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

View File

@ -102,7 +102,6 @@ int32_t createExecTaskInfo(SSubplan* pPlan, SExecTaskInfo** pTaskInfo, SReadHand
int32_t code = doCreateTask(pPlan->id.queryId, taskId, vgId, model, &pHandle->api, pTaskInfo); int32_t code = doCreateTask(pPlan->id.queryId, taskId, vgId, model, &pHandle->api, pTaskInfo);
if (*pTaskInfo == NULL || code != 0) { if (*pTaskInfo == NULL || code != 0) {
nodesDestroyNode((SNode*)pPlan); nodesDestroyNode((SNode*)pPlan);
taosMemoryFree(sql);
return code; return code;
} }
@ -112,7 +111,16 @@ int32_t createExecTaskInfo(SSubplan* pPlan, SExecTaskInfo** pTaskInfo, SReadHand
} }
} }
TSWAP((*pTaskInfo)->sql, sql); if (NULL != sql) {
(*pTaskInfo)->sql = taosStrdup(sql);
if (NULL == (*pTaskInfo)->sql) {
code = terrno;
nodesDestroyNode((SNode*)pPlan);
doDestroyTask(*pTaskInfo);
(*pTaskInfo) = NULL;
return code;
}
}
(*pTaskInfo)->pSubplan = pPlan; (*pTaskInfo)->pSubplan = pPlan;
(*pTaskInfo)->pWorkerCb = pHandle->pWorkerCb; (*pTaskInfo)->pWorkerCb = pHandle->pWorkerCb;

View File

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

View File

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

View File

@ -549,7 +549,7 @@ void doStreamEventSaveCheckpoint(SOperatorInfo* pOperator) {
int32_t len = doStreamEventEncodeOpState(NULL, 0, pOperator); int32_t len = doStreamEventEncodeOpState(NULL, 0, pOperator);
void* buf = taosMemoryCalloc(1, len); void* buf = taosMemoryCalloc(1, len);
if (!buf) { 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; return;
} }
void* pBuf = buf; void* pBuf = buf;

View File

@ -1466,7 +1466,7 @@ void doStreamIntervalSaveCheckpoint(SOperatorInfo* pOperator) {
int32_t len = doStreamIntervalEncodeOpState(NULL, 0, pOperator); int32_t len = doStreamIntervalEncodeOpState(NULL, 0, pOperator);
void* buf = taosMemoryCalloc(1, len); void* buf = taosMemoryCalloc(1, len);
if (!buf) { 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; return;
} }
void* pBuf = buf; void* pBuf = buf;

View File

@ -609,7 +609,6 @@ static SSDataBlock* sysTableScanUserCols(SOperatorInfo* pOperator) {
} }
if (!pInfo->pCur || !pInfo->pSchema) { if (!pInfo->pCur || !pInfo->pSchema) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
qError("sysTableScanUserCols failed since %s", terrstr()); qError("sysTableScanUserCols failed since %s", terrstr());
blockDataDestroy(pDataBlock); blockDataDestroy(pDataBlock);
pInfo->loadInfo.totalRows = 0; pInfo->loadInfo.totalRows = 0;
@ -1014,7 +1013,7 @@ static int32_t sysTableGetGeomText(char* iGeom, int32_t nGeom, char** output, in
char* outputWKT = NULL; char* outputWKT = NULL;
if (nGeom == 0) { if (nGeom == 0) {
if (!(*output = taosStrdup(""))) code = TSDB_CODE_OUT_OF_MEMORY; if (!(*output = taosStrdup(""))) code = terrno;
*nOutput = 0; *nOutput = 0;
return code; return code;
} }
@ -1112,8 +1111,9 @@ static int32_t sysTableUserTagsFillOneTableTags(const SSysTableScanInfo* pInfo,
code = sysTableGetGeomText(tagVal.pData, tagVal.nData, &tagData, &tagLen); code = sysTableGetGeomText(tagVal.pData, tagVal.nData, &tagData, &tagLen);
QUERY_CHECK_CODE(code, lino, _end); QUERY_CHECK_CODE(code, lino, _end);
} else if (tagType == TSDB_DATA_TYPE_VARBINARY) { } else if (tagType == TSDB_DATA_TYPE_VARBINARY) {
if (taosAscii2Hex(tagVal.pData, tagVal.nData, (void**)&tagData, &tagLen) < 0) { code = taosAscii2Hex(tagVal.pData, tagVal.nData, (void**)&tagData, &tagLen);
qError("varbinary for systable failed since %s", tstrerror(TSDB_CODE_OUT_OF_MEMORY)); if (code < 0) {
qError("varbinary for systable failed since %s", tstrerror(code));
} }
} else if (IS_VAR_DATA_TYPE(tagType)) { } else if (IS_VAR_DATA_TYPE(tagType)) {
tagData = (char*)tagVal.pData; tagData = (char*)tagVal.pData;
@ -1438,7 +1438,7 @@ static int32_t doSetUserTableMetaInfo(SStoreMetaReader* pMetaReaderFn, SStoreMet
SMetaReader mr1 = {0}; SMetaReader mr1 = {0};
pMetaReaderFn->initReader(&mr1, pVnode, META_READER_NOLOCK, pMetaFn); pMetaReaderFn->initReader(&mr1, pVnode, META_READER_NOLOCK, pMetaFn);
int64_t suid = pMReader->me.ctbEntry.suid; int64_t suid = pMReader->me.ctbEntry.suid;
code = pMetaReaderFn->getTableEntryByUid(&mr1, suid); code = pMetaReaderFn->getTableEntryByUid(&mr1, suid);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
@ -1601,6 +1601,7 @@ static SSDataBlock* sysTableBuildUserTablesByUids(SOperatorInfo* pOperator) {
SMetaReader mr = {0}; SMetaReader mr = {0};
pAPI->metaReaderFn.initReader(&mr, pInfo->readHandle.vnode, META_READER_LOCK, &pAPI->metaFn); pAPI->metaReaderFn.initReader(&mr, pInfo->readHandle.vnode, META_READER_LOCK, &pAPI->metaFn);
code = doSetUserTableMetaInfo(&pAPI->metaReaderFn, &pAPI->metaFn, pInfo->readHandle.vnode, &mr, *uid, dbname, vgId, code = doSetUserTableMetaInfo(&pAPI->metaReaderFn, &pAPI->metaFn, pInfo->readHandle.vnode, &mr, *uid, dbname, vgId,
p, numOfRows, GET_TASKID(pTaskInfo)); p, numOfRows, GET_TASKID(pTaskInfo));
@ -1748,7 +1749,7 @@ static SSDataBlock* sysTableBuildUserTables(SOperatorInfo* pOperator) {
SMetaReader mr = {0}; SMetaReader mr = {0};
pAPI->metaReaderFn.initReader(&mr, pInfo->readHandle.vnode, META_READER_NOLOCK, &pAPI->metaFn); pAPI->metaReaderFn.initReader(&mr, pInfo->readHandle.vnode, META_READER_NOLOCK, &pAPI->metaFn);
uint64_t suid = pInfo->pCur->mr.me.ctbEntry.suid; uint64_t suid = pInfo->pCur->mr.me.ctbEntry.suid;
code = pAPI->metaReaderFn.getTableEntryByUid(&mr, suid); code = pAPI->metaReaderFn.getTableEntryByUid(&mr, suid);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
@ -2396,7 +2397,7 @@ static SSDataBlock* sysTableScanFromMNode(SOperatorInfo* pOperator, SSysTableSca
SMsgSendInfo* pMsgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo)); SMsgSendInfo* pMsgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo));
if (NULL == pMsgSendInfo) { if (NULL == pMsgSendInfo) {
qError("%s prepare message %d failed", GET_TASKID(pTaskInfo), (int32_t)sizeof(SMsgSendInfo)); 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); taosMemoryFree(buf1);
return NULL; 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, int32_t ret = setTimeWindowOutputBuf(pResultRowInfo, &w, (scanFlag == MAIN_SCAN), &pResult, groupId, pSup->pCtx,
numOfOutput, pSup->rowEntryInfoOffset, &pInfo->aggSup, pTaskInfo); numOfOutput, pSup->rowEntryInfoOffset, &pInfo->aggSup, pTaskInfo);
if (ret != TSDB_CODE_SUCCESS) { 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)) { if(isResultRowInterpolated(pResult, RESULT_ROW_END_INTERP)) {
@ -711,7 +711,7 @@ static bool filterWindowWithLimit(SIntervalAggOperatorInfo* pOperatorInfo, STime
if (pOperatorInfo->limit == 0) return true; if (pOperatorInfo->limit == 0) return true;
if (pOperatorInfo->pBQ == NULL) { if (pOperatorInfo->pBQ == NULL) {
pOperatorInfo->pBQ = createBoundedQueue(pOperatorInfo->limit - 1, tsKeyCompFn, taosMemoryFree, pOperatorInfo); pOperatorInfo->pBQ = createBoundedQueue(pOperatorInfo->limit - 1, tsKeyCompFn, taosAutoMemoryFree, pOperatorInfo);
QUERY_CHECK_NULL(pOperatorInfo->pBQ, code, lino, _end, terrno); QUERY_CHECK_NULL(pOperatorInfo->pBQ, code, lino, _end, terrno);
} }
@ -780,7 +780,7 @@ static bool hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul
int32_t ret = setTimeWindowOutputBuf(pResultRowInfo, &win, (scanFlag == MAIN_SCAN), &pResult, tableGroupId, int32_t ret = setTimeWindowOutputBuf(pResultRowInfo, &win, (scanFlag == MAIN_SCAN), &pResult, tableGroupId,
pSup->pCtx, numOfOutput, pSup->rowEntryInfoOffset, &pInfo->aggSup, pTaskInfo); pSup->pCtx, numOfOutput, pSup->rowEntryInfoOffset, &pInfo->aggSup, pTaskInfo);
if (ret != TSDB_CODE_SUCCESS || pResult == NULL) { 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; 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, int32_t code = setTimeWindowOutputBuf(pResultRowInfo, &nextWin, (scanFlag == MAIN_SCAN), &pResult, tableGroupId,
pSup->pCtx, numOfOutput, pSup->rowEntryInfoOffset, &pInfo->aggSup, pTaskInfo); pSup->pCtx, numOfOutput, pSup->rowEntryInfoOffset, &pInfo->aggSup, pTaskInfo);
if (code != TSDB_CODE_SUCCESS || pResult == NULL) { 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; 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, setTimeWindowOutputBuf(pResultRowInfo, &win, (scanFlag == MAIN_SCAN), &pResult, tableGroupId, pExprSup->pCtx,
numOfOutput, pExprSup->rowEntryInfoOffset, &iaInfo->aggSup, pTaskInfo); numOfOutput, pExprSup->rowEntryInfoOffset, &iaInfo->aggSup, pTaskInfo);
if (ret != TSDB_CODE_SUCCESS || pResult == NULL) { 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; 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); int32_t code = outputPrevIntervalResult(pOperatorInfo, tableGroupId, pResultBlock, &win);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(code)); 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; STimeWindow nextWin = win;
@ -2329,7 +2329,7 @@ static void doMergeIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultRowInfo*
setTimeWindowOutputBuf(pResultRowInfo, &nextWin, (scanFlag == MAIN_SCAN), &pResult, tableGroupId, setTimeWindowOutputBuf(pResultRowInfo, &nextWin, (scanFlag == MAIN_SCAN), &pResult, tableGroupId,
pExprSup->pCtx, numOfOutput, pExprSup->rowEntryInfoOffset, &iaInfo->aggSup, pTaskInfo); pExprSup->pCtx, numOfOutput, pExprSup->rowEntryInfoOffset, &iaInfo->aggSup, pTaskInfo);
if (code != TSDB_CODE_SUCCESS || pResult == NULL) { 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; ekey = ascScan ? nextWin.ekey : nextWin.skey;
@ -2354,7 +2354,7 @@ static void doMergeIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultRowInfo*
code = outputPrevIntervalResult(pOperatorInfo, tableGroupId, pResultBlock, &nextWin); code = outputPrevIntervalResult(pOperatorInfo, tableGroupId, pResultBlock, &nextWin);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(code)); 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

@ -1647,7 +1647,7 @@ SNode* qptMakeDownstreamSrcNode(SNode** ppNode) {
pDs->addr.nodeId = qptCtx.param.vnode.vgId; pDs->addr.nodeId = qptCtx.param.vnode.vgId;
memcpy(&pDs->addr.epSet, &qptCtx.param.vnode.epSet, sizeof(pDs->addr.epSet)); memcpy(&pDs->addr.epSet, &qptCtx.param.vnode.epSet, sizeof(pDs->addr.epSet));
pDs->taskId = (QPT_CORRECT_HIGH_PROB() && qptCtx.buildCtx.pCurrTask) ? qptCtx.buildCtx.pCurrTask->id.taskId : taosRand(); pDs->taskId = (QPT_CORRECT_HIGH_PROB() && qptCtx.buildCtx.pCurrTask) ? qptCtx.buildCtx.pCurrTask->id.taskId : taosRand();
pDs->schedId = QPT_CORRECT_HIGH_PROB() ? qptCtx.param.schedulerId : taosRand(); pDs->sId = QPT_CORRECT_HIGH_PROB() ? 0 : taosRand();
pDs->execId = taosRand(); pDs->execId = taosRand();
pDs->fetchMsgType = QPT_CORRECT_HIGH_PROB() ? (QPT_RAND_BOOL_V ? TDMT_SCH_FETCH : TDMT_SCH_MERGE_FETCH) : taosRand(); pDs->fetchMsgType = QPT_CORRECT_HIGH_PROB() ? (QPT_RAND_BOOL_V ? TDMT_SCH_FETCH : TDMT_SCH_MERGE_FETCH) : taosRand();
pDs->localExec = QPT_RAND_BOOL_V; pDs->localExec = QPT_RAND_BOOL_V;
@ -3133,7 +3133,7 @@ void qptExecPlan(SReadHandle* pReadHandle, SNode* pNode, SExecTaskInfo* pTaskInf
case QUERY_NODE_PHYSICAL_PLAN_QUERY_INSERT: case QUERY_NODE_PHYSICAL_PLAN_QUERY_INSERT:
case QUERY_NODE_PHYSICAL_PLAN_DELETE: { case QUERY_NODE_PHYSICAL_PLAN_DELETE: {
DataSinkHandle handle = NULL; DataSinkHandle handle = NULL;
qptCtx.result.code = dsCreateDataSinker(NULL, (SDataSinkNode*)pNode, &handle, NULL, NULL); qptCtx.result.code = dsCreateDataSinker(NULL, (SDataSinkNode**)&pNode, &handle, NULL, NULL);
dsDestroyDataSinker(handle); dsDestroyDataSinker(handle);
break; break;
} }

View File

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

View File

@ -836,6 +836,44 @@ static int32_t physiProjectCopy(const SProjectPhysiNode* pSrc, SProjectPhysiNode
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
static int32_t dataSinkNodeCopy(const SDataSinkNode* pSrc, SDataSinkNode* pDst) {
CLONE_NODE_FIELD_EX(pInputDataBlockDesc, SDataBlockDescNode*);
return TSDB_CODE_SUCCESS;
}
static int32_t physiDispatchCopy(const SDataDispatcherNode* pSrc, SDataDispatcherNode* pDst) {
COPY_BASE_OBJECT_FIELD(sink, dataSinkNodeCopy);
return TSDB_CODE_SUCCESS;
}
static int32_t physiInserterCopy(const SDataInserterNode* pSrc, SDataInserterNode* pDst) {
COPY_BASE_OBJECT_FIELD(sink, dataSinkNodeCopy);
return TSDB_CODE_SUCCESS;
}
static int32_t physiQueryInserterCopy(const SQueryInserterNode* pSrc, SQueryInserterNode* pDst) {
COPY_BASE_OBJECT_FIELD(sink, dataSinkNodeCopy);
CLONE_NODE_LIST_FIELD(pCols);
COPY_SCALAR_FIELD(tableId);
COPY_SCALAR_FIELD(stableId);
COPY_SCALAR_FIELD(tableType);
COPY_CHAR_ARRAY_FIELD(tableName);
COPY_SCALAR_FIELD(vgId);
COPY_OBJECT_FIELD(epSet, sizeof(SEpSet));
COPY_SCALAR_FIELD(explain);
return TSDB_CODE_SUCCESS;
}
static int32_t physiDeleterCopy(const SDataDeleterNode* pSrc, SDataDeleterNode* pDst) {
COPY_BASE_OBJECT_FIELD(sink, dataSinkNodeCopy);
COPY_SCALAR_FIELD(tableId);
COPY_SCALAR_FIELD(tableType);
COPY_CHAR_ARRAY_FIELD(tableFName);
COPY_CHAR_ARRAY_FIELD(tsColName);
COPY_OBJECT_FIELD(deleteTimeRange, sizeof(STimeWindow));
return TSDB_CODE_SUCCESS;
}
static int32_t dataBlockDescCopy(const SDataBlockDescNode* pSrc, SDataBlockDescNode* pDst) { static int32_t dataBlockDescCopy(const SDataBlockDescNode* pSrc, SDataBlockDescNode* pDst) {
COPY_SCALAR_FIELD(dataBlockId); COPY_SCALAR_FIELD(dataBlockId);
CLONE_NODE_LIST_FIELD(pSlots); CLONE_NODE_LIST_FIELD(pSlots);
@ -858,7 +896,7 @@ static int32_t downstreamSourceCopy(const SDownstreamSourceNode* pSrc, SDownstre
COPY_OBJECT_FIELD(addr, sizeof(SQueryNodeAddr)); COPY_OBJECT_FIELD(addr, sizeof(SQueryNodeAddr));
COPY_SCALAR_FIELD(clientId); COPY_SCALAR_FIELD(clientId);
COPY_SCALAR_FIELD(taskId); COPY_SCALAR_FIELD(taskId);
COPY_SCALAR_FIELD(schedId); COPY_SCALAR_FIELD(sId);
COPY_SCALAR_FIELD(execId); COPY_SCALAR_FIELD(execId);
COPY_SCALAR_FIELD(fetchMsgType); COPY_SCALAR_FIELD(fetchMsgType);
COPY_SCALAR_FIELD(localExec); COPY_SCALAR_FIELD(localExec);
@ -1091,6 +1129,18 @@ int32_t nodesCloneNode(const SNode* pNode, SNode** ppNode) {
case QUERY_NODE_PHYSICAL_PLAN_PROJECT: case QUERY_NODE_PHYSICAL_PLAN_PROJECT:
code = physiProjectCopy((const SProjectPhysiNode*)pNode, (SProjectPhysiNode*)pDst); code = physiProjectCopy((const SProjectPhysiNode*)pNode, (SProjectPhysiNode*)pDst);
break; break;
case QUERY_NODE_PHYSICAL_PLAN_DISPATCH:
code = physiDispatchCopy((const SDataDispatcherNode*)pNode, (SDataDispatcherNode*)pDst);
break;
//case QUERY_NODE_PHYSICAL_PLAN_INSERT:
// code = physiInserterCopy((const SDataInserterNode*)pNode, (SDataInserterNode*)pDst);
// break;
case QUERY_NODE_PHYSICAL_PLAN_QUERY_INSERT:
code = physiQueryInserterCopy((const SQueryInserterNode*)pNode, (SQueryInserterNode*)pDst);
break;
case QUERY_NODE_PHYSICAL_PLAN_DELETE:
code = physiDeleterCopy((const SDataDeleterNode*)pNode, (SDataDeleterNode*)pDst);
break;
default: default:
break; break;
} }

View File

@ -5333,7 +5333,7 @@ static int32_t jsonToColumnDefNode(const SJson* pJson, void* pObj) {
static const char* jkDownstreamSourceAddr = "Addr"; static const char* jkDownstreamSourceAddr = "Addr";
static const char* jkDownstreamSourceClientId = "ClientId"; static const char* jkDownstreamSourceClientId = "ClientId";
static const char* jkDownstreamSourceTaskId = "TaskId"; static const char* jkDownstreamSourceTaskId = "TaskId";
static const char* jkDownstreamSourceSchedId = "SchedId"; static const char* jkDownstreamSourceSeriousId = "SeriousId";
static const char* jkDownstreamSourceExecId = "ExecId"; static const char* jkDownstreamSourceExecId = "ExecId";
static const char* jkDownstreamSourceFetchMsgType = "FetchMsgType"; static const char* jkDownstreamSourceFetchMsgType = "FetchMsgType";
@ -5348,7 +5348,7 @@ static int32_t downstreamSourceNodeToJson(const void* pObj, SJson* pJson) {
code = tjsonAddIntegerToObject(pJson, jkDownstreamSourceTaskId, pNode->taskId); code = tjsonAddIntegerToObject(pJson, jkDownstreamSourceTaskId, pNode->taskId);
} }
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
code = tjsonAddIntegerToObject(pJson, jkDownstreamSourceSchedId, pNode->schedId); code = tjsonAddIntegerToObject(pJson, jkDownstreamSourceSeriousId, pNode->sId);
} }
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
code = tjsonAddIntegerToObject(pJson, jkDownstreamSourceExecId, pNode->execId); code = tjsonAddIntegerToObject(pJson, jkDownstreamSourceExecId, pNode->execId);
@ -5371,7 +5371,7 @@ static int32_t jsonToDownstreamSourceNode(const SJson* pJson, void* pObj) {
code = tjsonGetUBigIntValue(pJson, jkDownstreamSourceTaskId, &pNode->taskId); code = tjsonGetUBigIntValue(pJson, jkDownstreamSourceTaskId, &pNode->taskId);
} }
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
code = tjsonGetUBigIntValue(pJson, jkDownstreamSourceSchedId, &pNode->schedId); code = tjsonGetUBigIntValue(pJson, jkDownstreamSourceSeriousId, &pNode->sId);
} }
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
code = tjsonGetIntValue(pJson, jkDownstreamSourceExecId, &pNode->execId); code = tjsonGetIntValue(pJson, jkDownstreamSourceExecId, &pNode->execId);

View File

@ -1761,7 +1761,7 @@ static int32_t downstreamSourceNodeInlineToMsg(const void* pObj, STlvEncoder* pE
code = tlvEncodeValueU64(pEncoder, pNode->taskId); code = tlvEncodeValueU64(pEncoder, pNode->taskId);
} }
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
code = tlvEncodeValueU64(pEncoder, pNode->schedId); code = tlvEncodeValueU64(pEncoder, pNode->sId);
} }
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
code = tlvEncodeValueI32(pEncoder, pNode->execId); code = tlvEncodeValueI32(pEncoder, pNode->execId);
@ -1788,7 +1788,7 @@ static int32_t msgToDownstreamSourceNodeInlineToMsg(STlvDecoder* pDecoder, void*
code = tlvDecodeValueU64(pDecoder, &pNode->taskId); code = tlvDecodeValueU64(pDecoder, &pNode->taskId);
} }
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
code = tlvDecodeValueU64(pDecoder, &pNode->schedId); code = tlvDecodeValueU64(pDecoder, &pNode->sId);
} }
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
code = tlvDecodeValueI32(pDecoder, &pNode->execId); code = tlvDecodeValueI32(pDecoder, &pNode->execId);

View File

@ -1079,7 +1079,7 @@ void nodesDestroyNode(SNode* pNode) {
taosMemoryFreeClear(pReal->pMeta); taosMemoryFreeClear(pReal->pMeta);
taosMemoryFreeClear(pReal->pVgroupList); taosMemoryFreeClear(pReal->pVgroupList);
taosArrayDestroyEx(pReal->pSmaIndexes, destroySmaIndex); taosArrayDestroyEx(pReal->pSmaIndexes, destroySmaIndex);
taosArrayDestroyP(pReal->tsmaTargetTbVgInfo, taosMemoryFree); taosArrayDestroyP(pReal->tsmaTargetTbVgInfo, NULL);
taosArrayDestroy(pReal->tsmaTargetTbInfo); taosArrayDestroy(pReal->tsmaTargetTbInfo);
break; break;
} }
@ -1627,7 +1627,7 @@ void nodesDestroyNode(SNode* pNode) {
nodesDestroyList(pLogicNode->pTags); nodesDestroyList(pLogicNode->pTags);
nodesDestroyNode(pLogicNode->pSubtable); nodesDestroyNode(pLogicNode->pSubtable);
taosArrayDestroyEx(pLogicNode->pFuncTypes, destroyFuncParam); taosArrayDestroyEx(pLogicNode->pFuncTypes, destroyFuncParam);
taosArrayDestroyP(pLogicNode->pTsmaTargetTbVgInfo, taosMemoryFree); taosArrayDestroyP(pLogicNode->pTsmaTargetTbVgInfo, NULL);
taosArrayDestroy(pLogicNode->pTsmaTargetTbInfo); taosArrayDestroy(pLogicNode->pTsmaTargetTbInfo);
break; break;
} }
@ -2012,7 +2012,7 @@ int32_t nodesMakeList(SNodeList** ppListOut) {
int32_t nodesListAppend(SNodeList* pList, SNode* pNode) { int32_t nodesListAppend(SNodeList* pList, SNode* pNode) {
if (NULL == pList || NULL == pNode) { if (NULL == pList || NULL == pNode) {
return TSDB_CODE_FAILED; return TSDB_CODE_INVALID_PARA;
} }
SListCell* p = NULL; SListCell* p = NULL;
int32_t code = nodesCalloc(1, sizeof(SListCell), (void**)&p); int32_t code = nodesCalloc(1, sizeof(SListCell), (void**)&p);

Some files were not shown because too many files have changed in this diff Show More