Merge branch '3.0' into fix/TD-31899
This commit is contained in:
commit
6234369d12
|
@ -2,7 +2,7 @@
|
|||
# taosadapter
|
||||
ExternalProject_Add(taosadapter
|
||||
GIT_REPOSITORY https://github.com/taosdata/taosadapter.git
|
||||
GIT_TAG main
|
||||
GIT_TAG 3.0
|
||||
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taosadapter"
|
||||
BINARY_DIR ""
|
||||
#BUILD_IN_SOURCE TRUE
|
||||
|
|
|
@ -4,7 +4,7 @@ sidebar_label: Taos-Explorer
|
|||
description: User guide about taosExplorer
|
||||
---
|
||||
|
||||
taos-explorer is a web service which provides GUI based interactive database management tool.
|
||||
taos-explorer is a web service which provides GUI based interactive database management tool. To ensure the best experience when accessing taosExplorer, please use Chrome version 79 or higher, Edge version 79 or higher.
|
||||
|
||||
## Install
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ sidebar_label: taosExplorer
|
|||
toc_max_heading_level: 4
|
||||
---
|
||||
|
||||
taosExplorer 是一个为用户提供 TDengine 实例的可视化管理交互工具的 web 服务。本节主要讲述其安装和部署。它的各项功能都是基于简单易上手的图形界面,可以直接尝试,如果有需要也可以考高级功能和运维指南中的相关内容。
|
||||
taosExplorer 是一个为用户提供 TDengine 实例的可视化管理交互工具的 web 服务。本节主要讲述其安装和部署。它的各项功能都是基于简单易上手的图形界面,可以直接尝试,如果有需要也可以考高级功能和运维指南中的相关内容。为了确保访问 taosExplorer 的最佳体验,请使用 Chrome 79 及以上版本,或 Edge 79 及以上版本。
|
||||
|
||||
## 安装
|
||||
|
||||
|
|
|
@ -110,6 +110,8 @@ typedef struct SFirstLastRes {
|
|||
int32_t pkBytes;
|
||||
int8_t pkType;
|
||||
STuplePos pos;
|
||||
STuplePos nullTuplePos;
|
||||
bool nullTupleSaved;
|
||||
char buf[];
|
||||
} SFirstLastRes;
|
||||
|
||||
|
|
|
@ -233,6 +233,7 @@ int32_t blockDataSort(SSDataBlock* pDataBlock, SArray* pOrderInfo);
|
|||
* @brief find how many rows already in order start from first row
|
||||
*/
|
||||
int32_t blockDataGetSortedRows(SSDataBlock* pDataBlock, SArray* pOrderInfo);
|
||||
void blockDataCheck(const SSDataBlock* pDataBlock, bool forceChk);
|
||||
|
||||
int32_t colInfoDataEnsureCapacity(SColumnInfoData* pColumn, uint32_t numOfRows, bool clearPayload);
|
||||
int32_t blockDataEnsureCapacity(SSDataBlock* pDataBlock, uint32_t numOfRows);
|
||||
|
|
|
@ -74,26 +74,26 @@ int32_t tGetMachineId(char **result);
|
|||
#ifdef TD_ENTERPRISE
|
||||
#define GRANTS_SCHEMA \
|
||||
static const SSysDbTableSchema grantsSchema[] = { \
|
||||
{.name = "version", .bytes = 32 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \
|
||||
{.name = "version", .bytes = 64 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \
|
||||
{.name = "expire_time", .bytes = 19 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \
|
||||
{.name = "service_time", .bytes = 19 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \
|
||||
{.name = "expired", .bytes = 5 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \
|
||||
{.name = "state", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \
|
||||
{.name = "timeseries", .bytes = 21 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \
|
||||
{.name = "dnodes", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \
|
||||
{.name = "cpu_cores", .bytes = 13 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \
|
||||
{.name = "timeseries", .bytes = 43 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \
|
||||
{.name = "dnodes", .bytes = 21 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \
|
||||
{.name = "cpu_cores", .bytes = 21 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \
|
||||
}
|
||||
#else
|
||||
#define GRANTS_SCHEMA \
|
||||
static const SSysDbTableSchema grantsSchema[] = { \
|
||||
{.name = "version", .bytes = 32 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \
|
||||
{.name = "version", .bytes = 64 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \
|
||||
{.name = "expire_time", .bytes = 19 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \
|
||||
{.name = "service_time", .bytes = 19 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \
|
||||
{.name = "expired", .bytes = 5 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \
|
||||
{.name = "state", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \
|
||||
{.name = "timeseries", .bytes = 21 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \
|
||||
{.name = "dnodes", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \
|
||||
{.name = "cpu_cores", .bytes = 13 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \
|
||||
{.name = "timeseries", .bytes = 43 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \
|
||||
{.name = "dnodes", .bytes = 21 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \
|
||||
{.name = "cpu_cores", .bytes = 21 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \
|
||||
}
|
||||
#endif
|
||||
// #define GRANT_CFG_ADD
|
||||
|
|
|
@ -37,7 +37,7 @@ typedef struct SName {
|
|||
char tname[TSDB_TABLE_NAME_LEN];
|
||||
} SName;
|
||||
|
||||
void toName(int32_t acctId, const char* pDbName, const char* pTableName, SName* pName);
|
||||
void toName(int32_t acctId, const char* pDbName, const char* pTableName, SName* pName);
|
||||
|
||||
int32_t tNameExtractFullName(const SName* name, char* dst);
|
||||
|
||||
|
|
|
@ -29,5 +29,6 @@ int32_t qExecExplainBegin(SQueryPlan *pDag, SExplainCtx **pCtx, int64_t startTs)
|
|||
int32_t qExecExplainEnd(SExplainCtx *pCtx, SRetrieveTableRsp **pRsp);
|
||||
int32_t qExplainUpdateExecInfo(SExplainCtx *pCtx, SExplainRsp *pRspMsg, int32_t groupId, SRetrieveTableRsp **pRsp);
|
||||
void qExplainFreeCtx(SExplainCtx *pCtx);
|
||||
int32_t formatDurationOrKeep(char* buffer, int32_t timeInMinutes);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -143,7 +143,7 @@ int32_t taosWriteMsg(TdSocketPtr pSocket, void *ptr, int32_t nbytes);
|
|||
int32_t taosReadMsg(TdSocketPtr pSocket, void *ptr, int32_t nbytes);
|
||||
int32_t taosNonblockwrite(TdSocketPtr pSocket, char *ptr, int32_t nbytes);
|
||||
int64_t taosCopyFds(TdSocketPtr pSrcSocket, TdSocketPtr pDestSocket, int64_t len);
|
||||
void taosWinSocketInit();
|
||||
int32_t taosWinSocketInit();
|
||||
|
||||
/*
|
||||
* set timeout(ms)
|
||||
|
|
|
@ -35,6 +35,8 @@ extern STaosError errors[];
|
|||
#define TAOS_DEF_ERROR_CODE(mod, code) ((int32_t)((0x80000000 | ((mod)<<16) | (code))))
|
||||
|
||||
#define TAOS_SYSTEM_ERROR(code) (0x80ff0000 | (code))
|
||||
#define TAOS_SYSTEM_WINAPI_ERROR(code) (0x81ff0000 | (code))
|
||||
#define TAOS_SYSTEM_WINSOCKET_ERROR(code) (0x82ff0000 | (code))
|
||||
#define TAOS_SUCCEEDED(err) ((err) >= 0)
|
||||
#define TAOS_FAILED(err) ((err) < 0)
|
||||
|
||||
|
@ -153,6 +155,7 @@ int32_t taosGetErrSize();
|
|||
#define TSDB_CODE_MSG_PREPROCESSED TAOS_DEF_ERROR_CODE(0, 0x0136) // internal
|
||||
#define TSDB_CODE_OUT_OF_BUFFER TAOS_DEF_ERROR_CODE(0, 0x0137)
|
||||
#define TSDB_CODE_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x0138)
|
||||
#define TSDB_CODE_SOCKET_ERROR TAOS_DEF_ERROR_CODE(0, 0x0139)
|
||||
|
||||
//client
|
||||
#define TSDB_CODE_TSC_INVALID_OPERATION TAOS_DEF_ERROR_CODE(0, 0x0200)
|
||||
|
|
|
@ -55,7 +55,8 @@ Source: favicon.ico; DestDir: "{app}\include"; Flags: igNoreversion;
|
|||
Source: {#MyAppSourceDir}{#MyAppDLLName}; DestDir: "{win}\System32"; Flags: igNoreversion recursesubdirs createallsubdirs 64bit;Check:IsWin64;
|
||||
Source: {#MyAppSourceDir}{#MyAppCfgName}; DestDir: "{app}\cfg"; Flags: igNoreversion recursesubdirs createallsubdirs onlyifdoesntexist uninsneveruninstall
|
||||
Source: {#MyAppSourceDir}{#MyAppDriverName}; DestDir: "{app}\driver"; Flags: igNoreversion recursesubdirs createallsubdirs
|
||||
Source: {#MyAppSourceDir}\taos_odbc\*; DestDir: "{app}\taos_odbc\"; Flags: igNoreversion recursesubdirs createallsubdirs
|
||||
Source: {#MyAppSourceDir}\taos_odbc\*; DestDir: "{app}\taos_odbc"; Flags: igNoreversion recursesubdirs createallsubdirs
|
||||
Source: {#MyAppSourceDir}\*.dll; DestDir: "{app}"; Flags: igNoreversion recursesubdirs createallsubdirs
|
||||
;Source: {#MyAppSourceDir}{#MyAppConnectorName}; DestDir: "{app}\connector"; Flags: igNoreversion recursesubdirs createallsubdirs
|
||||
;Source: {#MyAppSourceDir}{#MyAppExamplesName}; DestDir: "{app}\examples"; Flags: igNoreversion recursesubdirs createallsubdirs
|
||||
Source: {#MyAppSourceDir}{#MyAppIncludeName}; DestDir: "{app}\include"; Flags: igNoreversion recursesubdirs createallsubdirs
|
||||
|
@ -69,7 +70,9 @@ Source: {#MyAppSourceDir}\taosdump.exe; DestDir: "{app}"; DestName: "{#CusPrompt
|
|||
[run]
|
||||
Filename: {sys}\sc.exe; Parameters: "create taosd start= DEMAND binPath= ""C:\\TDengine\\taosd.exe --win_service""" ; Flags: runhidden
|
||||
Filename: {sys}\sc.exe; Parameters: "create taosadapter start= DEMAND binPath= ""C:\\TDengine\\taosadapter.exe""" ; Flags: runhidden
|
||||
Filename: "{cmd}"; Parameters: "/c odbcconf /F ""C:\TDengine\taos_odbc\win_odbcinst.in"""; WorkingDir: "{app}"; Flags: runhidden; StatusMsg: "Configuring ODBC"
|
||||
|
||||
Filename: "C:\Windows\System32\odbcconf.exe"; Parameters: "/S /F win_odbcinst.ini"; WorkingDir: "{app}\taos_odbc\x64"; Flags: runhidden; StatusMsg: "Configuring ODBC x64"
|
||||
Filename: "C:\Windows\SysWOW64\odbcconf.exe"; Parameters: "/S /F win_odbcinst.ini"; WorkingDir: "{app}\taos_odbc\x86"; Flags: runhidden; StatusMsg: "Configuring ODBC x86"
|
||||
|
||||
[UninstallRun]
|
||||
RunOnceId: "stoptaosd"; Filename: {sys}\sc.exe; Parameters: "stop taosd" ; Flags: runhidden
|
||||
|
@ -100,32 +103,26 @@ begin
|
|||
end;
|
||||
|
||||
function DeleteOdbcDsnRegistry: Boolean;
|
||||
var
|
||||
Names: TArrayOfString;
|
||||
I: Integer;
|
||||
Value: String;
|
||||
begin
|
||||
if RegGetValueNames(HKCU64, 'SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources', Names) then
|
||||
begin
|
||||
for I := 0 to GetArrayLength(Names) - 1 do
|
||||
begin
|
||||
if RegQueryStringValue(HKCU64, 'SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources', Names[I], Value) then
|
||||
begin
|
||||
if Value = 'TDengine' then
|
||||
begin
|
||||
RegDeleteKeyIncludingSubkeys(HKCU64, 'SOFTWARE\ODBC\ODBC.INI\' + Names[I]);
|
||||
RegDeleteValue(HKCU64, 'SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources\', Names[I]);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
RegDeleteKeyIncludingSubkeys(HKCU, 'SOFTWARE\ODBC\ODBC.INI\TAOS_ODBC_DSN');
|
||||
RegDeleteKeyIncludingSubkeys(HKCU, 'SOFTWARE\ODBC\ODBC.INI\TAOS_ODBC_WS_DSN')
|
||||
|
||||
RegDeleteValue(HKCU, 'SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources', 'TAOS_ODBC_DSN');
|
||||
RegDeleteValue(HKCU, 'SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources', 'TAOS_ODBC_WS_DSN');
|
||||
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
function DeleteOdbcDriverRegistry: Boolean;
|
||||
begin
|
||||
RegDeleteKeyIncludingSubkeys(HKLM64, 'SOFTWARE\ODBC\ODBCINST.INI\TDengine');
|
||||
RegDeleteValue(HKLM64, 'SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers', 'TDengine');
|
||||
// Delete 64-bit ODBC driver registry
|
||||
RegDeleteKeyIncludingSubkeys(HKLM64, 'SOFTWARE\ODBC\ODBCINST.INI\TAOS_ODBC_DRIVER');
|
||||
RegDeleteValue(HKLM64, 'SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers', 'TAOS_ODBC_DRIVER');
|
||||
|
||||
// Delete 32-bit ODBC driver registry
|
||||
RegDeleteKeyIncludingSubkeys(HKLM64, 'SOFTWARE\Wow6432Node\ODBC\ODBCINST.INI\TAOS_ODBC_DRIVER');
|
||||
RegDeleteValue(HKLM64, 'SOFTWARE\Wow6432Node\ODBC\ODBCINST.INI\ODBC Drivers', 'TAOS_ODBC_DRIVER');
|
||||
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
|
|
|
@ -180,7 +180,7 @@ static int32_t hbGenerateVgInfoFromRsp(SDBVgInfo **pInfo, SUseDbRsp *rsp) {
|
|||
vgInfo->vgHash = taosHashInit(rsp->vgNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_ENTRY_LOCK);
|
||||
if (NULL == vgInfo->vgHash) {
|
||||
tscError("hash init[%d] failed", rsp->vgNum);
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto _return;
|
||||
}
|
||||
|
||||
|
@ -188,7 +188,7 @@ static int32_t hbGenerateVgInfoFromRsp(SDBVgInfo **pInfo, SUseDbRsp *rsp) {
|
|||
SVgroupInfo *pInfo = taosArrayGet(rsp->pVgroupInfos, j);
|
||||
if (taosHashPut(vgInfo->vgHash, &pInfo->vgId, sizeof(int32_t), pInfo, sizeof(SVgroupInfo)) != 0) {
|
||||
tscError("hash push failed, errno:%d", errno);
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto _return;
|
||||
}
|
||||
}
|
||||
|
@ -689,7 +689,7 @@ int32_t hbBuildQueryDesc(SQueryHbReqBasic *hbBasic, STscObj *pObj) {
|
|||
(void)releaseRequest(*rid);
|
||||
if (NULL == taosArrayPush(hbBasic->queryDesc, &desc)) {
|
||||
taosArrayDestroy(desc.subDesc);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
pIter = taosHashIterate(pObj->pRequests, pIter);
|
||||
|
@ -777,7 +777,7 @@ static int32_t hbGetUserAuthInfo(SClientHbKey *connKey, SHbParam *param, SClient
|
|||
pKv->value = qUserAuth;
|
||||
pKv->valueLen += sizeof(SUserAuthVersion);
|
||||
} else {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
}
|
||||
goto _return;
|
||||
}
|
||||
|
@ -785,7 +785,7 @@ static int32_t hbGetUserAuthInfo(SClientHbKey *connKey, SHbParam *param, SClient
|
|||
// key/user not exist, add user
|
||||
SUserAuthVersion *user = taosMemoryMalloc(sizeof(SUserAuthVersion));
|
||||
if (!user) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto _return;
|
||||
}
|
||||
tstrncpy(user->user, pTscObj->user, TSDB_USER_LEN);
|
||||
|
@ -1436,7 +1436,7 @@ int32_t appHbMgrInit(SAppInstInfo *pAppInstInfo, char *key, SAppHbMgr **pAppHbMg
|
|||
TSC_ERR_RET(hbMgrInit());
|
||||
*pAppHbMgr = taosMemoryMalloc(sizeof(SAppHbMgr));
|
||||
if (*pAppHbMgr == NULL) {
|
||||
TSC_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
TSC_ERR_JRET(terrno);
|
||||
}
|
||||
// init stat
|
||||
(*pAppHbMgr)->startTime = taosGetTimestampMs();
|
||||
|
@ -1456,14 +1456,14 @@ int32_t appHbMgrInit(SAppInstInfo *pAppInstInfo, char *key, SAppHbMgr **pAppHbMg
|
|||
(*pAppHbMgr)->activeInfo = taosHashInit(64, hbKeyHashFunc, 1, HASH_ENTRY_LOCK);
|
||||
|
||||
if ((*pAppHbMgr)->activeInfo == NULL) {
|
||||
TSC_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
TSC_ERR_JRET(terrno);
|
||||
}
|
||||
|
||||
// taosHashSetFreeFp(pAppHbMgr->activeInfo, tFreeClientHbReq);
|
||||
|
||||
TSC_ERR_JRET(taosThreadMutexLock(&clientHbMgr.lock));
|
||||
if (taosArrayPush(clientHbMgr.appHbMgrs, &(*pAppHbMgr)) == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
(void)taosThreadMutexUnlock(&clientHbMgr.lock);
|
||||
goto _return;
|
||||
}
|
||||
|
|
|
@ -228,7 +228,7 @@ int32_t buildRequest(uint64_t connId, const char* sql, int sqlLen, void* param,
|
|||
tscError("0x%" PRIx64 " failed to prepare sql string buffer, %s", (*pRequest)->self, sql);
|
||||
destroyRequest(*pRequest);
|
||||
*pRequest = NULL;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
(void)strntolower((*pRequest)->sqlstr, sql, (int32_t)sqlLen);
|
||||
|
@ -247,7 +247,7 @@ int32_t buildRequest(uint64_t connId, const char* sql, int sqlLen, void* param,
|
|||
(*pRequest)->self, (*pRequest)->requestId, pTscObj->id, sql);
|
||||
destroyRequest(*pRequest);
|
||||
*pRequest = NULL;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
(*pRequest)->allocatorRefId = -1;
|
||||
|
@ -258,7 +258,7 @@ int32_t buildRequest(uint64_t connId, const char* sql, int sqlLen, void* param,
|
|||
(*pRequest)->requestId, pTscObj->id, sql);
|
||||
destroyRequest(*pRequest);
|
||||
*pRequest = NULL;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -595,7 +595,7 @@ int32_t buildVnodePolicyNodeList(SRequestObj* pRequest, SArray** pNodeList, SArr
|
|||
|
||||
if (NULL == taosArrayPush(nodeList, &load)) {
|
||||
taosArrayDestroy(nodeList);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -619,7 +619,7 @@ int32_t buildVnodePolicyNodeList(SRequestObj* pRequest, SArray** pNodeList, SArr
|
|||
}
|
||||
if (NULL == taosArrayAddBatch(nodeList, pData, mnodeNum)) {
|
||||
taosArrayDestroy(nodeList);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
tscDebug("0x%" PRIx64 " %s policy, use mnode list, num:%d", pRequest->requestId, policy, mnodeNum);
|
||||
|
@ -646,7 +646,7 @@ int32_t buildQnodePolicyNodeList(SRequestObj* pRequest, SArray** pNodeList, SArr
|
|||
}
|
||||
if (NULL == taosArrayAddBatch(nodeList, pData, qNodeNum)) {
|
||||
taosArrayDestroy(nodeList);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
tscDebug("0x%" PRIx64 " qnode policy, use qnode list, num:%d", pRequest->requestId, qNodeNum);
|
||||
goto _return;
|
||||
|
@ -665,7 +665,7 @@ int32_t buildQnodePolicyNodeList(SRequestObj* pRequest, SArray** pNodeList, SArr
|
|||
}
|
||||
if (NULL == taosArrayAddBatch(nodeList, pData, mnodeNum)) {
|
||||
taosArrayDestroy(nodeList);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
tscDebug("0x%" PRIx64 " qnode policy, use mnode list, num:%d", pRequest->requestId, mnodeNum);
|
||||
|
@ -699,7 +699,7 @@ int32_t buildAsyncExecNodeList(SRequestObj* pRequest, SArray** pNodeList, SArray
|
|||
}
|
||||
|
||||
if (NULL == taosArrayPush(pDbVgList, &pRes->pRes)) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto _return;
|
||||
}
|
||||
}
|
||||
|
@ -791,7 +791,7 @@ int32_t buildSyncExecNodeList(SRequestObj* pRequest, SArray** pNodeList, SArray*
|
|||
}
|
||||
|
||||
if (NULL == taosArrayPush(pDbVgList, &pVgList)) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto _return;
|
||||
}
|
||||
}
|
||||
|
@ -903,8 +903,7 @@ int32_t handleQueryExecRes(SRequestObj* pRequest, void* res, SCatalog* pCatalog,
|
|||
|
||||
pArray = taosArrayInit(tbNum, sizeof(STbSVersion));
|
||||
if (NULL == pArray) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < tbNum; ++i) {
|
||||
|
@ -915,7 +914,7 @@ int32_t handleQueryExecRes(SRequestObj* pRequest, void* res, SCatalog* pCatalog,
|
|||
}
|
||||
STbSVersion tbSver = {.tbFName = tbInfo->tbFName, .sver = tbInfo->sversion, .tver = tbInfo->tversion};
|
||||
if (NULL == taosArrayPush(pArray, &tbSver)) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto _return;
|
||||
}
|
||||
}
|
||||
|
@ -1662,7 +1661,7 @@ static int32_t buildConnectMsg(SRequestObj* pRequest, SMsgSendInfo** pMsgSendInf
|
|||
void* pReq = taosMemoryMalloc(contLen);
|
||||
if (NULL == pReq) {
|
||||
taosMemoryFree(*pMsgSendInfo);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
if (-1 == tSerializeSConnectReq(pReq, contLen, &connectReq)) {
|
||||
|
@ -2050,7 +2049,7 @@ static int32_t doConvertUCS4(SReqResultInfo* pResultInfo, int32_t numOfRows, int
|
|||
char* p = taosMemoryRealloc(pResultInfo->convertBuf[i], colLength[i]);
|
||||
if (p == NULL) {
|
||||
taosReleaseConv(idx, conv, C2M);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
pResultInfo->convertBuf[i] = p;
|
||||
|
@ -2441,7 +2440,6 @@ int32_t setQueryResultFromRsp(SReqResultInfo* pResultInfo, const SRetrieveTableR
|
|||
if (pResultInfo->decompBuf == NULL) {
|
||||
pResultInfo->decompBuf = taosMemoryMalloc(payloadLen);
|
||||
if (pResultInfo->decompBuf == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
tscError("failed to prepare the decompress buffer, size:%d", payloadLen);
|
||||
return terrno;
|
||||
}
|
||||
|
@ -2450,7 +2448,6 @@ int32_t setQueryResultFromRsp(SReqResultInfo* pResultInfo, const SRetrieveTableR
|
|||
if (pResultInfo->decompBufSize < payloadLen) {
|
||||
char* p = taosMemoryRealloc(pResultInfo->decompBuf, payloadLen);
|
||||
if (p == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
tscError("failed to prepare the decompress buffer, size:%d", payloadLen);
|
||||
return terrno;
|
||||
}
|
||||
|
|
|
@ -216,7 +216,7 @@ int32_t fetchWhiteListCallbackFn(void *param, SDataBuf *pMsg, int32_t code) {
|
|||
taosMemoryFree(pMsg->pEpSet);
|
||||
taosMemoryFree(pInfo);
|
||||
tFreeSGetUserWhiteListRsp(&wlRsp);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
for (int i = 0; i < wlRsp.numWhiteLists; ++i) {
|
||||
|
|
|
@ -34,11 +34,11 @@ static void processFileInTheEnd(TdFilePtr pFile, char* path) {
|
|||
return;
|
||||
}
|
||||
if (taosFtruncateFile(pFile, 0) != 0) {
|
||||
tscError("failed to truncate file:%s, errno:%d", path, errno);
|
||||
tscError("failed to truncate file:%s, errno:%d", path, terrno);
|
||||
return;
|
||||
}
|
||||
if (taosUnLockFile(pFile) != 0) {
|
||||
tscError("failed to unlock file:%s, errno:%d", path, errno);
|
||||
tscError("failed to unlock file:%s, errno:%d", path, terrno);
|
||||
return;
|
||||
}
|
||||
if (taosCloseFile(&(pFile)) != 0) {
|
||||
|
@ -388,7 +388,7 @@ static void monitorWriteSlowLog2File(MonitorSlowLogData* slowLogData, char* tmpP
|
|||
tscInfo("[monitor] create slow log file:%s", path);
|
||||
pFile = taosOpenFile(path, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_APPEND | TD_FILE_READ | TD_FILE_TRUNC);
|
||||
if (pFile == NULL) {
|
||||
tscError("failed to open file:%s since %d", path, errno);
|
||||
tscError("failed to open file:%s since %d", path, terrno);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -424,7 +424,7 @@ static void monitorWriteSlowLog2File(MonitorSlowLogData* slowLogData, char* tmpP
|
|||
}
|
||||
|
||||
if (taosLSeekFile(pFile, 0, SEEK_END) < 0) {
|
||||
tscError("failed to seek file:%p code: %d", pFile, errno);
|
||||
tscError("failed to seek file:%p code: %d", pFile, terrno);
|
||||
return;
|
||||
}
|
||||
if (taosWriteFile(pFile, slowLogData->data, strlen(slowLogData->data) + 1) < 0) {
|
||||
|
@ -436,7 +436,7 @@ static void monitorWriteSlowLog2File(MonitorSlowLogData* slowLogData, char* tmpP
|
|||
static char* readFile(TdFilePtr pFile, int64_t* offset, int64_t size) {
|
||||
tscDebug("[monitor] readFile slow begin pFile:%p, offset:%" PRId64 ", size:%" PRId64, pFile, *offset, size);
|
||||
if (taosLSeekFile(pFile, *offset, SEEK_SET) < 0) {
|
||||
tscError("failed to seek file:%p code: %d", pFile, errno);
|
||||
tscError("failed to seek file:%p code: %d", pFile, terrno);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -576,7 +576,7 @@ static void monitorSendSlowLogAtRunning(int64_t clusterId) {
|
|||
int64_t size = getFileSize(pClient->path);
|
||||
if (size <= pClient->offset) {
|
||||
if (taosFtruncateFile(pClient->pFile, 0) < 0) {
|
||||
tscError("failed to truncate file:%p code: %d", pClient->pFile, errno);
|
||||
tscError("failed to truncate file:%p code: %d", pClient->pFile, terrno);
|
||||
}
|
||||
tscDebug("[monitor] monitorSendSlowLogAtRunning truncate file to 0 file:%p", pClient->pFile);
|
||||
pClient->offset = 0;
|
||||
|
@ -633,7 +633,7 @@ static void monitorSendAllSlowLogAtQuit() {
|
|||
|
||||
static void processFileRemoved(SlowLogClient* pClient) {
|
||||
if (taosUnLockFile(pClient->pFile) != 0) {
|
||||
tscError("failed to unlock file:%s since %d", pClient->path, errno);
|
||||
tscError("failed to unlock file:%s since %d", pClient->path, terrno);
|
||||
return;
|
||||
}
|
||||
int32_t ret = taosCloseFile(&(pClient->pFile));
|
||||
|
@ -645,7 +645,7 @@ static void processFileRemoved(SlowLogClient* pClient) {
|
|||
TdFilePtr pFile =
|
||||
taosOpenFile(pClient->path, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_APPEND | TD_FILE_READ | TD_FILE_TRUNC);
|
||||
if (pFile == NULL) {
|
||||
tscError("failed to open file:%s since %d", pClient->path, errno);
|
||||
tscError("failed to open file:%s since %d", pClient->path, terrno);
|
||||
} else {
|
||||
pClient->pFile = pFile;
|
||||
}
|
||||
|
@ -857,9 +857,10 @@ int32_t monitorInit() {
|
|||
return code;
|
||||
}
|
||||
|
||||
if (taosMulModeMkDir(tmpSlowLogPath, 0777, true) != 0) {
|
||||
code = taosMulModeMkDir(tmpSlowLogPath, 0777, true);
|
||||
if (code != 0) {
|
||||
tscError("failed to create dir:%s since %s", tmpSlowLogPath, terrstr());
|
||||
return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||
return code;
|
||||
}
|
||||
|
||||
if (tsem2_init(&monitorSem, 0, 0) != 0) {
|
||||
|
|
|
@ -522,19 +522,19 @@ static int32_t buildShowVariablesBlock(SArray* pVars, SSDataBlock** block) {
|
|||
pBlock->info.hasVarCol = true;
|
||||
|
||||
pBlock->pDataBlock = taosArrayInit(SHOW_VARIABLES_RESULT_COLS, sizeof(SColumnInfoData));
|
||||
TSDB_CHECK_NULL(pBlock->pDataBlock, code, line, END, TSDB_CODE_OUT_OF_MEMORY);
|
||||
TSDB_CHECK_NULL(pBlock->pDataBlock, code, line, END, terrno);
|
||||
SColumnInfoData infoData = {0};
|
||||
infoData.info.type = TSDB_DATA_TYPE_VARCHAR;
|
||||
infoData.info.bytes = SHOW_VARIABLES_RESULT_FIELD1_LEN;
|
||||
TSDB_CHECK_NULL(taosArrayPush(pBlock->pDataBlock, &infoData), code, line, END, TSDB_CODE_OUT_OF_MEMORY);
|
||||
TSDB_CHECK_NULL(taosArrayPush(pBlock->pDataBlock, &infoData), code, line, END, terrno);
|
||||
|
||||
infoData.info.type = TSDB_DATA_TYPE_VARCHAR;
|
||||
infoData.info.bytes = SHOW_VARIABLES_RESULT_FIELD2_LEN;
|
||||
TSDB_CHECK_NULL(taosArrayPush(pBlock->pDataBlock, &infoData), code, line, END, TSDB_CODE_OUT_OF_MEMORY);
|
||||
TSDB_CHECK_NULL(taosArrayPush(pBlock->pDataBlock, &infoData), code, line, END, terrno);
|
||||
|
||||
infoData.info.type = TSDB_DATA_TYPE_VARCHAR;
|
||||
infoData.info.bytes = SHOW_VARIABLES_RESULT_FIELD3_LEN;
|
||||
TSDB_CHECK_NULL(taosArrayPush(pBlock->pDataBlock, &infoData), code, line, END, TSDB_CODE_OUT_OF_MEMORY);
|
||||
TSDB_CHECK_NULL(taosArrayPush(pBlock->pDataBlock, &infoData), code, line, END, terrno);
|
||||
|
||||
int32_t numOfCfg = taosArrayGetSize(pVars);
|
||||
code = blockDataEnsureCapacity(pBlock, numOfCfg);
|
||||
|
@ -542,26 +542,26 @@ static int32_t buildShowVariablesBlock(SArray* pVars, SSDataBlock** block) {
|
|||
|
||||
for (int32_t i = 0, c = 0; i < numOfCfg; ++i, c = 0) {
|
||||
SVariablesInfo* pInfo = taosArrayGet(pVars, i);
|
||||
TSDB_CHECK_NULL(pInfo, code, line, END, TSDB_CODE_OUT_OF_MEMORY);
|
||||
TSDB_CHECK_NULL(pInfo, code, line, END, terrno);
|
||||
|
||||
char name[TSDB_CONFIG_OPTION_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(name, pInfo->name, TSDB_CONFIG_OPTION_LEN + VARSTR_HEADER_SIZE);
|
||||
SColumnInfoData* pColInfo = taosArrayGet(pBlock->pDataBlock, c++);
|
||||
TSDB_CHECK_NULL(pColInfo, code, line, END, TSDB_CODE_OUT_OF_MEMORY);
|
||||
TSDB_CHECK_NULL(pColInfo, code, line, END, terrno);
|
||||
code = colDataSetVal(pColInfo, i, name, false);
|
||||
TSDB_CHECK_CODE(code, line, END);
|
||||
|
||||
char value[TSDB_CONFIG_VALUE_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(value, pInfo->value, TSDB_CONFIG_VALUE_LEN + VARSTR_HEADER_SIZE);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, c++);
|
||||
TSDB_CHECK_NULL(pColInfo, code, line, END, TSDB_CODE_OUT_OF_MEMORY);
|
||||
TSDB_CHECK_NULL(pColInfo, code, line, END, terrno);
|
||||
code = colDataSetVal(pColInfo, i, value, false);
|
||||
TSDB_CHECK_CODE(code, line, END);
|
||||
|
||||
char scope[TSDB_CONFIG_SCOPE_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(scope, pInfo->scope, TSDB_CONFIG_SCOPE_LEN + VARSTR_HEADER_SIZE);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, c++);
|
||||
TSDB_CHECK_NULL(pColInfo, code, line, END, TSDB_CODE_OUT_OF_MEMORY);
|
||||
TSDB_CHECK_NULL(pColInfo, code, line, END, terrno);
|
||||
code = colDataSetVal(pColInfo, i, scope, false);
|
||||
TSDB_CHECK_CODE(code, line, END);
|
||||
}
|
||||
|
@ -675,29 +675,29 @@ static int32_t buildCompactDbBlock(SCompactDbRsp* pRsp, SSDataBlock** block) {
|
|||
pBlock->info.hasVarCol = true;
|
||||
|
||||
pBlock->pDataBlock = taosArrayInit(COMPACT_DB_RESULT_COLS, sizeof(SColumnInfoData));
|
||||
TSDB_CHECK_NULL(pBlock->pDataBlock, code, line, END, TSDB_CODE_OUT_OF_MEMORY);
|
||||
TSDB_CHECK_NULL(pBlock->pDataBlock, code, line, END, terrno);
|
||||
SColumnInfoData infoData = {0};
|
||||
infoData.info.type = TSDB_DATA_TYPE_VARCHAR;
|
||||
infoData.info.bytes = COMPACT_DB_RESULT_FIELD1_LEN;
|
||||
TSDB_CHECK_NULL(taosArrayPush(pBlock->pDataBlock, &infoData), code, line, END, TSDB_CODE_OUT_OF_MEMORY);
|
||||
TSDB_CHECK_NULL(taosArrayPush(pBlock->pDataBlock, &infoData), code, line, END, terrno);
|
||||
|
||||
infoData.info.type = TSDB_DATA_TYPE_INT;
|
||||
infoData.info.bytes = tDataTypes[TSDB_DATA_TYPE_INT].bytes;
|
||||
TSDB_CHECK_NULL(taosArrayPush(pBlock->pDataBlock, &infoData), code, line, END, TSDB_CODE_OUT_OF_MEMORY);
|
||||
TSDB_CHECK_NULL(taosArrayPush(pBlock->pDataBlock, &infoData), code, line, END, terrno);
|
||||
|
||||
infoData.info.type = TSDB_DATA_TYPE_VARCHAR;
|
||||
infoData.info.bytes = COMPACT_DB_RESULT_FIELD3_LEN;
|
||||
TSDB_CHECK_NULL(taosArrayPush(pBlock->pDataBlock, &infoData), code, line, END, TSDB_CODE_OUT_OF_MEMORY);
|
||||
TSDB_CHECK_NULL(taosArrayPush(pBlock->pDataBlock, &infoData), code, line, END, terrno);
|
||||
|
||||
code = blockDataEnsureCapacity(pBlock, 1);
|
||||
TSDB_CHECK_CODE(code, line, END);
|
||||
|
||||
SColumnInfoData* pResultCol = taosArrayGet(pBlock->pDataBlock, 0);
|
||||
TSDB_CHECK_NULL(pResultCol, code, line, END, TSDB_CODE_OUT_OF_MEMORY);
|
||||
TSDB_CHECK_NULL(pResultCol, code, line, END, terrno);
|
||||
SColumnInfoData* pIdCol = taosArrayGet(pBlock->pDataBlock, 1);
|
||||
TSDB_CHECK_NULL(pIdCol, code, line, END, TSDB_CODE_OUT_OF_MEMORY);
|
||||
TSDB_CHECK_NULL(pIdCol, code, line, END, terrno);
|
||||
SColumnInfoData* pReasonCol = taosArrayGet(pBlock->pDataBlock, 2);
|
||||
TSDB_CHECK_NULL(pReasonCol, code, line, END, TSDB_CODE_OUT_OF_MEMORY);
|
||||
TSDB_CHECK_NULL(pReasonCol, code, line, END, terrno);
|
||||
|
||||
char result[COMPACT_DB_RESULT_FIELD1_LEN] = {0};
|
||||
char reason[COMPACT_DB_RESULT_FIELD3_LEN] = {0};
|
||||
|
|
|
@ -178,7 +178,7 @@ int32_t smlBuildTableInfo(int numRows, const char *measure, int32_t measureLen,
|
|||
if (tag->cols == NULL) {
|
||||
uError("SML:smlBuildTableInfo failed to allocate memory");
|
||||
taosMemoryFree(tag);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
*tInfo = tag;
|
||||
|
@ -210,7 +210,7 @@ int32_t smlBuildSuperTableInfo(SSmlHandle *info, SSmlLineInfo *currElement, SSml
|
|||
if (currElement->measureEscaped) {
|
||||
measure = (char *)taosMemoryMalloc(measureLen);
|
||||
if (measure == NULL){
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
(void)memcpy(measure, currElement->measure, measureLen);
|
||||
PROCESS_SLASH_IN_MEASUREMENT(measure, measureLen);
|
||||
|
@ -251,11 +251,11 @@ int32_t smlBuildSuperTableInfo(SSmlHandle *info, SSmlLineInfo *currElement, SSml
|
|||
|
||||
if (i < pTableMeta->tableInfo.numOfColumns) {
|
||||
if(taosArrayPush((*sMeta)->cols, &kv) == NULL){
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
} else {
|
||||
if(taosArrayPush((*sMeta)->tags, &kv) == NULL){
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -328,7 +328,7 @@ END:
|
|||
int32_t smlJoinMeasureTag(SSmlLineInfo *elements) {
|
||||
elements->measureTag = (char *)taosMemoryMalloc(elements->measureLen + elements->tagsLen);
|
||||
if (elements->measureTag == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
(void)memcpy(elements->measureTag, elements->measure, elements->measureLen);
|
||||
(void)memcpy(elements->measureTag + elements->measureLen, elements->tags, elements->tagsLen);
|
||||
|
@ -455,14 +455,14 @@ int32_t smlParseEndTelnetJson(SSmlHandle *info, SSmlLineInfo *elements, SSmlKv *
|
|||
if (elements->colArray == NULL) {
|
||||
elements->colArray = taosArrayInit(16, sizeof(SSmlKv));
|
||||
if (elements->colArray == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
}
|
||||
if (taosArrayPush(elements->colArray, kvTs) == NULL){
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
if (taosArrayPush(elements->colArray, kv) == NULL){
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
}
|
||||
info->preLine = *elements;
|
||||
|
@ -937,7 +937,7 @@ static int32_t smlCheckMeta(SSchema *schema, int32_t length, SArray *cols, bool
|
|||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
SHashObj *hashTmp = taosHashInit(length, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK);
|
||||
if (hashTmp == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto END;
|
||||
}
|
||||
int32_t i = 0;
|
||||
|
@ -997,7 +997,7 @@ static int32_t smlBuildFieldsList(SSmlHandle *info, SSchema *schemaField, SHashO
|
|||
field.bytes = getBytes(kv->type, kv->length);
|
||||
(void)memcpy(field.name, kv->key, kv->keyLen);
|
||||
if (taosArrayPush(results, &field) == NULL){
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
} else if (action == SCHEMA_ACTION_CHANGE_COLUMN_SIZE || action == SCHEMA_ACTION_CHANGE_TAG_SIZE) {
|
||||
uint16_t *index = (uint16_t *)taosHashGet(schemaHash, kv->key, kv->keyLen);
|
||||
|
@ -1046,7 +1046,7 @@ static int32_t smlSendMetaMsg(SSmlHandle *info, SName *pName, SArray *pColumns,
|
|||
|
||||
pReq.pColumns = taosArrayInit(pReq.numOfColumns, sizeof(SFieldWithOptions));
|
||||
if (pReq.pColumns == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto end;
|
||||
}
|
||||
for (int32_t i = 0; i < pReq.numOfColumns; ++i) {
|
||||
|
@ -1059,7 +1059,7 @@ static int32_t smlSendMetaMsg(SSmlHandle *info, SName *pName, SArray *pColumns,
|
|||
setFieldWithOptions(&fieldWithOption, pField);
|
||||
setDefaultOptionsForField(&fieldWithOption);
|
||||
if (taosArrayPush(pReq.pColumns, &fieldWithOption) == NULL){
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
@ -1106,7 +1106,7 @@ static int32_t smlSendMetaMsg(SSmlHandle *info, SName *pName, SArray *pColumns,
|
|||
field.bytes = TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE;
|
||||
tstrncpy(field.name, tsSmlTagName, sizeof(field.name));
|
||||
if (taosArrayPush(pReq.pTags, &field) == NULL){
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
@ -1114,7 +1114,7 @@ static int32_t smlSendMetaMsg(SSmlHandle *info, SName *pName, SArray *pColumns,
|
|||
pReq.commentLen = -1;
|
||||
pReq.igExists = true;
|
||||
code = tNameExtractFullName(pName, pReq.name);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1127,7 +1127,7 @@ static int32_t smlSendMetaMsg(SSmlHandle *info, SName *pName, SArray *pColumns,
|
|||
}
|
||||
pCmdMsg.pMsg = taosMemoryMalloc(pCmdMsg.msgLen);
|
||||
if (NULL == pCmdMsg.pMsg) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -1188,7 +1188,7 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
|
|||
void *superTable = taosHashGetKey(tmp, &superTableLen);
|
||||
char *measure = taosMemoryMalloc(superTableLen);
|
||||
if (measure == NULL){
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto end;
|
||||
}
|
||||
(void)memcpy(measure, superTable, superTableLen);
|
||||
|
@ -1208,12 +1208,12 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
|
|||
uDebug("SML:0x%" PRIx64 " smlModifyDBSchemas create table:%s", info->id, pName.tname);
|
||||
SArray *pColumns = taosArrayInit(taosArrayGetSize(sTableData->cols), sizeof(SField));
|
||||
if (pColumns == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto end;
|
||||
}
|
||||
SArray *pTags = taosArrayInit(taosArrayGetSize(sTableData->tags), sizeof(SField));
|
||||
if (pTags == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
taosArrayDestroy(pColumns);
|
||||
goto end;
|
||||
}
|
||||
|
@ -1255,7 +1255,7 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
|
|||
hashTmp = taosHashInit(pTableMeta->tableInfo.numOfTags, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true,
|
||||
HASH_NO_LOCK);
|
||||
if (hashTmp == NULL){
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto end;
|
||||
}
|
||||
for (uint16_t i = pTableMeta->tableInfo.numOfColumns;
|
||||
|
@ -1281,14 +1281,14 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
|
|||
SArray *pColumns =
|
||||
taosArrayInit(taosArrayGetSize(sTableData->cols) + pTableMeta->tableInfo.numOfColumns, sizeof(SField));
|
||||
if (pColumns == NULL){
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto end;
|
||||
}
|
||||
SArray *pTags =
|
||||
taosArrayInit(taosArrayGetSize(sTableData->tags) + pTableMeta->tableInfo.numOfTags, sizeof(SField));
|
||||
if (pTags == NULL){
|
||||
taosArrayDestroy(pColumns);
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto end;
|
||||
}
|
||||
for (uint16_t i = 0; i < pTableMeta->tableInfo.numOfColumns + pTableMeta->tableInfo.numOfTags; i++) {
|
||||
|
@ -1300,14 +1300,14 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
|
|||
if (taosArrayPush(pColumns, &field) == NULL){
|
||||
taosArrayDestroy(pColumns);
|
||||
taosArrayDestroy(pTags);
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto end;
|
||||
}
|
||||
} else {
|
||||
if (taosArrayPush(pTags, &field) == NULL){
|
||||
taosArrayDestroy(pColumns);
|
||||
taosArrayDestroy(pTags);
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
@ -1377,14 +1377,14 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
|
|||
SArray *pColumns =
|
||||
taosArrayInit(taosArrayGetSize(sTableData->cols) + pTableMeta->tableInfo.numOfColumns, sizeof(SField));
|
||||
if (pColumns == NULL){
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto end;
|
||||
}
|
||||
SArray *pTags =
|
||||
taosArrayInit(taosArrayGetSize(sTableData->tags) + pTableMeta->tableInfo.numOfTags, sizeof(SField));
|
||||
if (pTags == NULL){
|
||||
taosArrayDestroy(pColumns);
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto end;
|
||||
}
|
||||
for (uint16_t i = 0; i < pTableMeta->tableInfo.numOfColumns + pTableMeta->tableInfo.numOfTags; i++) {
|
||||
|
@ -1396,14 +1396,14 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
|
|||
if (taosArrayPush(pColumns, &field) == NULL){
|
||||
taosArrayDestroy(pColumns);
|
||||
taosArrayDestroy(pTags);
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto end;
|
||||
}
|
||||
} else {
|
||||
if (taosArrayPush(pTags, &field) == NULL){
|
||||
taosArrayDestroy(pColumns);
|
||||
taosArrayDestroy(pTags);
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
@ -1500,7 +1500,7 @@ static int32_t smlInsertMeta(SHashObj *metaHash, SArray *metaArray, SArray *cols
|
|||
int ret = taosHashPut(metaHash, kv->key, kv->keyLen, &i, SHORT_BYTES);
|
||||
if (ret == 0) {
|
||||
if (taosArrayPush(metaArray, kv) == NULL){
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
if(taosHashGet(checkDuplicate, kv->key, kv->keyLen) != NULL) {
|
||||
return TSDB_CODE_PAR_DUPLICATED_COLUMN;
|
||||
|
@ -1550,7 +1550,7 @@ static int32_t smlUpdateMeta(SHashObj *metaHash, SArray *metaArray, SArray *cols
|
|||
int ret = taosHashPut(metaHash, kv->key, kv->keyLen, &size, SHORT_BYTES);
|
||||
if (ret == 0) {
|
||||
if(taosArrayPush(metaArray, kv) == NULL){
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
if(taosHashGet(checkDuplicate, kv->key, kv->keyLen) != NULL) {
|
||||
return TSDB_CODE_PAR_DUPLICATED_COLUMN;
|
||||
|
@ -1649,7 +1649,7 @@ int32_t smlBuildSmlInfo(TAOS *taos, SSmlHandle **handle) {
|
|||
info->superTables = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK);
|
||||
if (info->pVgHash == NULL || info->childTables == NULL || info->superTables == NULL || info->tableUids == NULL) {
|
||||
uError("create SSmlHandle hash obj failed");
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto FAILED;
|
||||
}
|
||||
taosHashSetFreeFp(info->superTables, smlDestroySTableMeta);
|
||||
|
@ -1668,7 +1668,7 @@ int32_t smlBuildSmlInfo(TAOS *taos, SSmlHandle **handle) {
|
|||
|
||||
if (info->tagJsonArray == NULL || info->valueJsonArray == NULL || info->preLineTagKV == NULL) {
|
||||
uError("SML:0x%" PRIx64 " failed to allocate memory", info->id);
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto FAILED;
|
||||
}
|
||||
|
||||
|
@ -1684,7 +1684,7 @@ static int32_t smlPushCols(SArray *colsArray, SArray *cols) {
|
|||
SHashObj *kvHash = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK);
|
||||
if (!kvHash) {
|
||||
uError("SML:smlDealCols failed to allocate memory");
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
for (size_t i = 0; i < taosArrayGetSize(cols); i++) {
|
||||
SSmlKv *kv = (SSmlKv *)taosArrayGet(cols, i);
|
||||
|
@ -1706,7 +1706,7 @@ static int32_t smlPushCols(SArray *colsArray, SArray *cols) {
|
|||
|
||||
if (taosArrayPush(colsArray, &kvHash) == NULL) {
|
||||
taosHashCleanup(kvHash);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -1802,12 +1802,12 @@ static int32_t smlInsertData(SSmlHandle *info) {
|
|||
if (info->pRequest->dbList == NULL) {
|
||||
info->pRequest->dbList = taosArrayInit(1, TSDB_DB_FNAME_LEN);
|
||||
if (info->pRequest->dbList == NULL){
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
}
|
||||
char *data = (char *)taosArrayReserve(info->pRequest->dbList, 1);
|
||||
if (data == NULL){
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
SName pName = {TSDB_TABLE_NAME_T, info->taos->acctId, {0}, {0}};
|
||||
tstrncpy(pName.dbname, info->pRequest->pDb, sizeof(pName.dbname));
|
||||
|
@ -1820,7 +1820,7 @@ static int32_t smlInsertData(SSmlHandle *info) {
|
|||
int measureLen = tableData->sTableNameLen;
|
||||
char *measure = (char *)taosMemoryMalloc(tableData->sTableNameLen);
|
||||
if (measure == NULL){
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
(void)memcpy(measure, tableData->sTableName, tableData->sTableNameLen);
|
||||
PROCESS_SLASH_IN_MEASUREMENT(measure, measureLen);
|
||||
|
@ -1831,11 +1831,11 @@ static int32_t smlInsertData(SSmlHandle *info) {
|
|||
if (info->pRequest->tableList == NULL) {
|
||||
info->pRequest->tableList = taosArrayInit(1, sizeof(SName));
|
||||
if (info->pRequest->tableList == NULL){
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
}
|
||||
if (taosArrayPush(info->pRequest->tableList, &pName) == NULL){
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
tstrncpy(pName.tname, tableData->childTableName, sizeof(pName.tname));
|
||||
|
|
|
@ -526,7 +526,7 @@ static int32_t smlProcessTagJson(SSmlHandle *info, cJSON *tags){
|
|||
return ret;
|
||||
}
|
||||
if (taosArrayPush(preLineKV, &kv) == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
if (info->dataFormat && !isSmlTagAligned(info, cnt, &kv)) {
|
||||
|
@ -873,7 +873,7 @@ static int32_t smlParseJSONString(SSmlHandle *info, char **start, SSmlLineInfo *
|
|||
if (taosArrayPush(info->tagJsonArray, &valueJson) == NULL){
|
||||
cJSON_Delete(valueJson);
|
||||
elements->cols[elements->colsLen] = tmp;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
ret = smlParseValueFromJSONObj(valueJson, &kv);
|
||||
if (ret != TSDB_CODE_SUCCESS) {
|
||||
|
@ -901,7 +901,7 @@ static int32_t smlParseJSONString(SSmlHandle *info, char **start, SSmlLineInfo *
|
|||
if (taosArrayPush(info->tagJsonArray, &tagsJson) == NULL){
|
||||
cJSON_Delete(tagsJson);
|
||||
uError("SML:0x%" PRIx64 " taosArrayPush failed", info->id);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
ret = smlParseTagsFromJSON(info, tagsJson, elements);
|
||||
if (unlikely(ret)) {
|
||||
|
@ -965,7 +965,7 @@ int32_t smlParseJSON(SSmlHandle *info, char *payload) {
|
|||
payloadNum = payloadNum << 1;
|
||||
void *tmp = taosMemoryRealloc(info->lines, payloadNum * sizeof(SSmlLineInfo));
|
||||
if (tmp == NULL) {
|
||||
ret = TSDB_CODE_OUT_OF_MEMORY;
|
||||
ret = terrno;
|
||||
return ret;
|
||||
}
|
||||
info->lines = (SSmlLineInfo *)tmp;
|
||||
|
|
|
@ -150,7 +150,7 @@ int32_t smlParseValue(SSmlKv *pVal, SSmlMsgBuf *msg) {
|
|||
}
|
||||
void *data = taosMemoryMalloc(pVal->length);
|
||||
if(data == NULL){
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
(void)memcpy(data, pVal->value + (NCHAR_ADD_LEN - 1), pVal->length);
|
||||
pVal->value = data;
|
||||
|
@ -271,7 +271,7 @@ static int32_t smlProcessTagLine(SSmlHandle *info, char **sql, char *sqlEnd){
|
|||
if (keyEscaped) {
|
||||
char *tmp = (char *)taosMemoryMalloc(keyLen);
|
||||
if (tmp == NULL){
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
(void)memcpy(tmp, key, keyLen);
|
||||
PROCESS_SLASH_IN_TAG_FIELD_KEY(tmp, keyLen);
|
||||
|
@ -280,7 +280,7 @@ static int32_t smlProcessTagLine(SSmlHandle *info, char **sql, char *sqlEnd){
|
|||
if (valueEscaped) {
|
||||
char *tmp = (char *)taosMemoryMalloc(valueLen);
|
||||
if (tmp == NULL){
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
(void)memcpy(tmp, value, valueLen);
|
||||
PROCESS_SLASH_IN_TAG_FIELD_KEY(tmp, valueLen);
|
||||
|
@ -294,7 +294,7 @@ static int32_t smlProcessTagLine(SSmlHandle *info, char **sql, char *sqlEnd){
|
|||
.keyEscaped = keyEscaped,
|
||||
.valueEscaped = valueEscaped};
|
||||
if(taosArrayPush(preLineKV, &kv) == NULL){
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
if (info->dataFormat && !isSmlTagAligned(info, cnt, &kv)) {
|
||||
|
@ -422,7 +422,7 @@ static int32_t smlParseColLine(SSmlHandle *info, char **sql, char *sqlEnd, SSmlL
|
|||
if (keyEscaped) {
|
||||
char *tmp = (char *)taosMemoryMalloc(kv.keyLen);
|
||||
if (tmp == NULL){
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
(void)memcpy(tmp, key, kv.keyLen);
|
||||
PROCESS_SLASH_IN_TAG_FIELD_KEY(tmp, kv.keyLen);
|
||||
|
@ -433,7 +433,7 @@ static int32_t smlParseColLine(SSmlHandle *info, char **sql, char *sqlEnd, SSmlL
|
|||
if (valueEscaped) {
|
||||
char *tmp = (char *)taosMemoryMalloc(kv.length);
|
||||
if (tmp == NULL){
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
(void)memcpy(tmp, kv.value, kv.length);
|
||||
PROCESS_SLASH_IN_FIELD_VALUE(tmp, kv.length);
|
||||
|
@ -459,11 +459,11 @@ static int32_t smlParseColLine(SSmlHandle *info, char **sql, char *sqlEnd, SSmlL
|
|||
if (currElement->colArray == NULL) {
|
||||
currElement->colArray = taosArrayInit_s(sizeof(SSmlKv), 1);
|
||||
if (currElement->colArray == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
}
|
||||
if (taosArrayPush(currElement->colArray, &kv) == NULL){ // reserve for timestamp
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -132,7 +132,7 @@ static int32_t smlProcessTagTelnet(SSmlHandle *info, char *data, char *sqlEnd){
|
|||
.keyEscaped = false,
|
||||
.valueEscaped = false};
|
||||
if (taosArrayPush(preLineKV, &kv) == NULL){
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
if (info->dataFormat && !isSmlTagAligned(info, cnt, &kv)) {
|
||||
return TSDB_CODE_SML_INVALID_DATA;
|
||||
|
|
|
@ -15,7 +15,7 @@ static FORCE_INLINE int32_t stmtAllocQNodeFromBuf(STableBufInfo* pTblBuf, void**
|
|||
} else if (pTblBuf->buffIdx < taosArrayGetSize(pTblBuf->pBufList)) {
|
||||
pTblBuf->pCurBuff = taosArrayGetP(pTblBuf->pBufList, pTblBuf->buffIdx++);
|
||||
if (NULL == pTblBuf->pCurBuff) {
|
||||
return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||
return TAOS_GET_TERRNO(terrno);
|
||||
}
|
||||
*pBuf = pTblBuf->pCurBuff;
|
||||
pTblBuf->buffOffset = pTblBuf->buffUnit;
|
||||
|
@ -186,7 +186,7 @@ int32_t stmtBackupQueryFields(STscStmt* pStmt) {
|
|||
pRes->fields = taosMemoryMalloc(size);
|
||||
pRes->userFields = taosMemoryMalloc(size);
|
||||
if (NULL == pRes->fields || NULL == pRes->userFields) {
|
||||
STMT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
STMT_ERR_RET(terrno);
|
||||
}
|
||||
(void)memcpy(pRes->fields, pStmt->exec.pRequest->body.resInfo.fields, size);
|
||||
(void)memcpy(pRes->userFields, pStmt->exec.pRequest->body.resInfo.userFields, size);
|
||||
|
@ -204,7 +204,7 @@ int32_t stmtRestoreQueryFields(STscStmt* pStmt) {
|
|||
if (NULL == pStmt->exec.pRequest->body.resInfo.fields) {
|
||||
pStmt->exec.pRequest->body.resInfo.fields = taosMemoryMalloc(size);
|
||||
if (NULL == pStmt->exec.pRequest->body.resInfo.fields) {
|
||||
STMT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
STMT_ERR_RET(terrno);
|
||||
}
|
||||
(void)memcpy(pStmt->exec.pRequest->body.resInfo.fields, pRes->fields, size);
|
||||
}
|
||||
|
@ -212,7 +212,7 @@ int32_t stmtRestoreQueryFields(STscStmt* pStmt) {
|
|||
if (NULL == pStmt->exec.pRequest->body.resInfo.userFields) {
|
||||
pStmt->exec.pRequest->body.resInfo.userFields = taosMemoryMalloc(size);
|
||||
if (NULL == pStmt->exec.pRequest->body.resInfo.userFields) {
|
||||
STMT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
STMT_ERR_RET(terrno);
|
||||
}
|
||||
(void)memcpy(pStmt->exec.pRequest->body.resInfo.userFields, pRes->userFields, size);
|
||||
}
|
||||
|
@ -306,7 +306,7 @@ int32_t stmtCacheBlock(STscStmt* pStmt) {
|
|||
};
|
||||
|
||||
if (taosHashPut(pStmt->sql.pTableCache, &cacheUid, sizeof(cacheUid), &cache, sizeof(cache))) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
if (pStmt->sql.autoCreateTbl) {
|
||||
|
@ -369,7 +369,7 @@ int32_t stmtParseSql(STscStmt* pStmt) {
|
|||
if (NULL == pStmt->sql.pBindInfo) {
|
||||
pStmt->sql.pBindInfo = taosMemoryMalloc(pTableCtx->boundColsInfo.numOfBound * sizeof(*pStmt->sql.pBindInfo));
|
||||
if (NULL == pStmt->sql.pBindInfo) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -612,7 +612,7 @@ int32_t stmtGetFromCache(STscStmt* pStmt) {
|
|||
|
||||
if (taosHashPut(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName), &pNewBlock,
|
||||
POINTER_BYTES)) {
|
||||
STMT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
STMT_ERR_RET(terrno);
|
||||
}
|
||||
|
||||
pStmt->exec.pCurrBlock = pNewBlock;
|
||||
|
@ -702,7 +702,7 @@ int32_t stmtGetFromCache(STscStmt* pStmt) {
|
|||
|
||||
if (taosHashPut(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName), &pNewBlock,
|
||||
POINTER_BYTES)) {
|
||||
STMT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
STMT_ERR_RET(terrno);
|
||||
}
|
||||
|
||||
pStmt->exec.pCurrBlock = pNewBlock;
|
||||
|
@ -722,7 +722,6 @@ int32_t stmtResetStmt(STscStmt* pStmt) {
|
|||
|
||||
pStmt->sql.pTableCache = taosHashInit(100, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
|
||||
if (NULL == pStmt->sql.pTableCache) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
STMT_ERR_RET(terrno);
|
||||
}
|
||||
|
||||
|
@ -739,7 +738,7 @@ int32_t stmtAsyncOutput(STscStmt* pStmt, void* param) {
|
|||
SArray** p = (SArray**)TARRAY_GET_ELEM(pStmt->sql.siInfo.pTableCols, i);
|
||||
*p = taosArrayInit(20, POINTER_BYTES);
|
||||
if (*p == NULL) {
|
||||
STMT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
STMT_ERR_RET(terrno);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -815,15 +814,15 @@ int32_t stmtInitTableBuf(STableBufInfo* pTblBuf) {
|
|||
pTblBuf->buffSize = pTblBuf->buffUnit * 1000;
|
||||
pTblBuf->pBufList = taosArrayInit(100, POINTER_BYTES);
|
||||
if (NULL == pTblBuf->pBufList) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
void* buff = taosMemoryMalloc(pTblBuf->buffSize);
|
||||
if (NULL == buff) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
if (taosArrayPush(pTblBuf->pBufList, &buff) == NULL){
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
pTblBuf->pCurBuff = buff;
|
||||
|
@ -951,11 +950,11 @@ int32_t stmtInitStbInterlaceTableInfo(STscStmt* pStmt) {
|
|||
for (int32_t i = 0; i < STMT_TABLE_COLS_NUM; i++) {
|
||||
pTblCols = taosArrayInit(20, POINTER_BYTES);
|
||||
if (NULL == pTblCols) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
if (taosArrayPush(pStmt->sql.siInfo.pTableCols, &pTblCols) == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1187,11 +1186,11 @@ static FORCE_INLINE int32_t stmtGetTableColsFromCache(STscStmt* pStmt, SArray**
|
|||
for (int32_t i = 0; i < 100; i++) {
|
||||
pTblCols = taosArrayInit(20, POINTER_BYTES);
|
||||
if (NULL == pTblCols) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
if (taosArrayPush(pStmt->sql.siInfo.pTableCols, &pTblCols) == NULL){
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -643,7 +643,6 @@ static int32_t stmtResetStmt(STscStmt2* pStmt) {
|
|||
|
||||
pStmt->sql.pTableCache = taosHashInit(100, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
|
||||
if (NULL == pStmt->sql.pTableCache) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
STMT_ERR_RET(terrno);
|
||||
}
|
||||
|
||||
|
@ -660,7 +659,7 @@ static int32_t stmtAsyncOutput(STscStmt2* pStmt, void* param) {
|
|||
SArray** p = (SArray**)TARRAY_GET_ELEM(pStmt->sql.siInfo.pTableCols, i);
|
||||
*p = taosArrayInit(20, POINTER_BYTES);
|
||||
if (*p == NULL) {
|
||||
STMT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
STMT_ERR_RET(terrno);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -733,15 +732,15 @@ static int32_t stmtInitTableBuf(STableBufInfo* pTblBuf) {
|
|||
pTblBuf->buffSize = pTblBuf->buffUnit * 1000;
|
||||
pTblBuf->pBufList = taosArrayInit(100, POINTER_BYTES);
|
||||
if (NULL == pTblBuf->pBufList) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
void* buff = taosMemoryMalloc(pTblBuf->buffSize);
|
||||
if (NULL == buff) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
if (taosArrayPush(pTblBuf->pBufList, &buff) == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
pTblBuf->pCurBuff = buff;
|
||||
|
@ -796,7 +795,7 @@ TAOS_STMT2* stmtInit2(STscObj* taos, TAOS_STMT2_OPTION* pOptions) {
|
|||
}
|
||||
pStmt->sql.siInfo.pTableCols = taosArrayInit(STMT_TABLE_COLS_NUM, POINTER_BYTES);
|
||||
if (NULL == pStmt->sql.siInfo.pTableCols) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
terrno = terrno;
|
||||
(void)stmtClose(pStmt);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -889,11 +888,11 @@ static int32_t stmtInitStbInterlaceTableInfo(STscStmt2* pStmt) {
|
|||
for (int32_t i = 0; i < STMT_TABLE_COLS_NUM; i++) {
|
||||
pTblCols = taosArrayInit(20, POINTER_BYTES);
|
||||
if (NULL == pTblCols) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
if (taosArrayPush(pStmt->sql.siInfo.pTableCols, &pTblCols) == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1121,11 +1120,11 @@ static FORCE_INLINE int32_t stmtGetTableColsFromCache(STscStmt2* pStmt, SArray**
|
|||
for (int32_t i = 0; i < 100; i++) {
|
||||
pTblCols = taosArrayInit(20, POINTER_BYTES);
|
||||
if (NULL == pTblCols) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
if (taosArrayPush(pStmt->sql.siInfo.pTableCols, &pTblCols) == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1160,7 +1159,7 @@ static int32_t stmtCacheBlock(STscStmt2* pStmt) {
|
|||
};
|
||||
|
||||
if (taosHashPut(pStmt->sql.pTableCache, &cacheUid, sizeof(cacheUid), &cache, sizeof(cache))) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
if (pStmt->sql.autoCreateTbl) {
|
||||
|
@ -1554,7 +1553,7 @@ static int32_t createParseContext(const SRequestObj* pRequest, SParseContext** p
|
|||
|
||||
*pCxt = taosMemoryCalloc(1, sizeof(SParseContext));
|
||||
if (*pCxt == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
**pCxt = (SParseContext){.requestId = pRequest->requestId,
|
||||
|
@ -1671,7 +1670,7 @@ int stmtExec2(TAOS_STMT2* stmt, int* affected_rows) {
|
|||
} else {
|
||||
SSqlCallbackWrapper* pWrapper = taosMemoryCalloc(1, sizeof(SSqlCallbackWrapper));
|
||||
if (pWrapper == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
} else {
|
||||
pWrapper->pRequest = pRequest;
|
||||
pRequest->pWrapper = pWrapper;
|
||||
|
|
|
@ -1109,7 +1109,7 @@ int32_t tmq_subscription(tmq_t* tmq, tmq_list_t** topics) {
|
|||
if (*topics == NULL) {
|
||||
*topics = tmq_list_new();
|
||||
if (*topics == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
}
|
||||
taosRLockLatch(&tmq->lock);
|
||||
|
@ -1375,7 +1375,7 @@ int32_t tmq_subscribe(tmq_t* tmq, const tmq_list_t* topic_list) {
|
|||
|
||||
req.topicNames = taosArrayInit(sz, sizeof(void*));
|
||||
if (req.topicNames == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto FAIL;
|
||||
}
|
||||
|
||||
|
@ -1416,7 +1416,7 @@ int32_t tmq_subscribe(tmq_t* tmq, const tmq_list_t* topic_list) {
|
|||
}
|
||||
|
||||
if (taosArrayPush(req.topicNames, &topicFName) == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
taosMemoryFree(topicFName);
|
||||
goto FAIL;
|
||||
}
|
||||
|
@ -1426,7 +1426,7 @@ int32_t tmq_subscribe(tmq_t* tmq, const tmq_list_t* topic_list) {
|
|||
int32_t tlen = tSerializeSCMSubscribeReq(NULL, &req);
|
||||
buf = taosMemoryMalloc(tlen);
|
||||
if (buf == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto FAIL;
|
||||
}
|
||||
|
||||
|
@ -2048,7 +2048,7 @@ static int32_t doTmqPollImpl(tmq_t* pTmq, SMqClientTopic* pTopic, SMqClientVg* p
|
|||
|
||||
pParam = taosMemoryMalloc(sizeof(SMqPollCbParam));
|
||||
if (pParam == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
taosMemoryFreeClear(msg);
|
||||
return code;
|
||||
}
|
||||
|
@ -2746,7 +2746,7 @@ int32_t tmq_commit_sync(tmq_t* tmq, const TAOS_RES* pRes) {
|
|||
SSyncCommitInfo* pInfo = taosMemoryMalloc(sizeof(SSyncCommitInfo));
|
||||
if (pInfo == NULL) {
|
||||
tscError("failed to allocate memory for sync commit");
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
if (tsem2_init(&pInfo->sem, 0, 0) != 0) {
|
||||
tscError("failed to init sem for sync commit");
|
||||
|
@ -2822,7 +2822,7 @@ int32_t tmq_commit_offset_sync(tmq_t* tmq, const char* pTopicName, int32_t vgId,
|
|||
SSyncCommitInfo* pInfo = taosMemoryMalloc(sizeof(SSyncCommitInfo));
|
||||
if (pInfo == NULL) {
|
||||
tscError("consumer:0x%" PRIx64 " failed to prepare seek operation", tmq->consumerId);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
if (tsem2_init(&pInfo->sem, 0, 0) != 0) {
|
||||
|
@ -2974,7 +2974,7 @@ FAIL:
|
|||
|
||||
int32_t syncAskEp(tmq_t* pTmq) {
|
||||
SAskEpInfo* pInfo = taosMemoryMalloc(sizeof(SAskEpInfo));
|
||||
if (pInfo == NULL) return TSDB_CODE_OUT_OF_MEMORY;
|
||||
if (pInfo == NULL) return terrno;
|
||||
if (tsem2_init(&pInfo->sem, 0, 0) != 0) {
|
||||
taosMemoryFree(pInfo);
|
||||
return TSDB_CODE_TSC_INTERNAL_ERROR;
|
||||
|
@ -3495,7 +3495,7 @@ int32_t tmq_get_topic_assignment(tmq_t* tmq, const char* pTopicName, tmq_topic_a
|
|||
|
||||
pCommon->pList = taosArrayInit(4, sizeof(tmq_topic_assignment));
|
||||
if (pCommon->pList == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto end;
|
||||
}
|
||||
if (tsem2_init(&pCommon->rsp, 0, 0) != 0) {
|
||||
|
@ -3513,7 +3513,7 @@ int32_t tmq_get_topic_assignment(tmq_t* tmq, const char* pTopicName, tmq_topic_a
|
|||
}
|
||||
SMqVgWalInfoParam* pParam = taosMemoryMalloc(sizeof(SMqVgWalInfoParam));
|
||||
if (pParam == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -3721,7 +3721,7 @@ int32_t tmq_offset_seek(tmq_t* tmq, const char* pTopicName, int32_t vgId, int64_
|
|||
if (pParam == NULL) {
|
||||
taosMemoryFree(msg);
|
||||
taosMemoryFree(sendInfo);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
if (tsem2_init(&pParam->sem, 0, 0) != 0) {
|
||||
taosMemoryFree(msg);
|
||||
|
|
|
@ -128,15 +128,15 @@ int32_t s3CheckCfg() {
|
|||
if (!fp) {
|
||||
(void)fprintf(stderr, "failed to open test file: %s.\n", path);
|
||||
// uError("ERROR: %s Failed to open %s", __func__, path);
|
||||
TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), &lino, _next);
|
||||
TAOS_CHECK_GOTO(terrno, &lino, _next);
|
||||
}
|
||||
if (taosWriteFile(fp, testdata, strlen(testdata)) < 0) {
|
||||
(void)fprintf(stderr, "failed to write test file: %s.\n", path);
|
||||
TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), &lino, _next);
|
||||
TAOS_CHECK_GOTO(terrno, &lino, _next);
|
||||
}
|
||||
if (taosFsyncFile(fp) < 0) {
|
||||
(void)fprintf(stderr, "failed to fsync test file: %s.\n", path);
|
||||
TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), &lino, _next);
|
||||
TAOS_CHECK_GOTO(terrno, &lino, _next);
|
||||
}
|
||||
(void)taosCloseFile(&fp);
|
||||
|
||||
|
@ -872,7 +872,7 @@ upload:
|
|||
|
||||
if (i > 0 && cp.parts[i - 1].completed) {
|
||||
if (taosLSeekFile(data->infileFD, cp.parts[i].offset, SEEK_SET) < 0) {
|
||||
TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), &lino, _exit);
|
||||
TAOS_CHECK_GOTO(terrno, &lino, _exit);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -988,12 +988,12 @@ int32_t s3PutObjectFromFile2ByEp(const char *file, const char *object_name, int8
|
|||
|
||||
if (taosStatFile(file, (int64_t *)&contentLength, &lmtime, NULL) < 0) {
|
||||
uError("ERROR: %s Failed to stat file %s: ", __func__, file);
|
||||
TAOS_RETURN(TAOS_SYSTEM_ERROR(errno));
|
||||
TAOS_RETURN(terrno);
|
||||
}
|
||||
|
||||
if (!(data.infileFD = taosOpenFile(file, TD_FILE_READ))) {
|
||||
uError("ERROR: %s Failed to open file %s: ", __func__, file);
|
||||
TAOS_RETURN(TAOS_SYSTEM_ERROR(errno));
|
||||
TAOS_RETURN(terrno);
|
||||
}
|
||||
|
||||
data.totalContentLength = data.totalOriginalContentLength = data.contentLength = data.originalContentLength =
|
||||
|
@ -1065,18 +1065,18 @@ static int32_t s3PutObjectFromFileOffsetByEp(const char *file, const char *objec
|
|||
|
||||
if (taosStatFile(file, (int64_t *)&contentLength, &lmtime, NULL) < 0) {
|
||||
uError("ERROR: %s Failed to stat file %s: ", __func__, file);
|
||||
TAOS_RETURN(TAOS_SYSTEM_ERROR(errno));
|
||||
TAOS_RETURN(terrno);
|
||||
}
|
||||
|
||||
contentLength = size;
|
||||
|
||||
if (!(data.infileFD = taosOpenFile(file, TD_FILE_READ))) {
|
||||
uError("ERROR: %s Failed to open file %s: ", __func__, file);
|
||||
TAOS_RETURN(TAOS_SYSTEM_ERROR(errno));
|
||||
TAOS_RETURN(terrno);
|
||||
}
|
||||
if (taosLSeekFile(data.infileFD, offset, SEEK_SET) < 0) {
|
||||
(void)taosCloseFile(&data.infileFD);
|
||||
TAOS_RETURN(TAOS_SYSTEM_ERROR(errno));
|
||||
TAOS_RETURN(terrno);
|
||||
}
|
||||
|
||||
data.totalContentLength = data.totalOriginalContentLength = data.contentLength = data.originalContentLength =
|
||||
|
@ -1412,8 +1412,8 @@ static int32_t s3GetObjectToFileByEp(const char *object_name, const char *fileNa
|
|||
|
||||
TdFilePtr pFile = taosOpenFile(fileName, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC);
|
||||
if (pFile == NULL) {
|
||||
uError("[s3] open file error, errno:%d, fileName:%s", TAOS_SYSTEM_ERROR(errno), fileName);
|
||||
TAOS_RETURN(TAOS_SYSTEM_ERROR(errno));
|
||||
uError("[s3] open file error, errno:%d, fileName:%s", terrno, fileName);
|
||||
TAOS_RETURN(terrno);
|
||||
}
|
||||
|
||||
TS3GetData cbd = {0};
|
||||
|
@ -1881,7 +1881,6 @@ void s3EvictCache(const char *path, long object_size) {
|
|||
// 1, list data files' atime under dir(path)
|
||||
tdbDirPtr pDir = taosOpenDir(dir_name);
|
||||
if (pDir == NULL) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
vError("failed to open %s since %s", dir_name, terrstr());
|
||||
}
|
||||
SArray *evict_files = taosArrayInit(16, sizeof(SEvictFile));
|
||||
|
|
|
@ -10,7 +10,7 @@ int32_t cos_cp_open(char const* cp_path, SCheckpoint* checkpoint) {
|
|||
TdFilePtr fd = taosOpenFile(cp_path, TD_FILE_WRITE | TD_FILE_CREATE /* | TD_FILE_TRUNC*/ | TD_FILE_WRITE_THROUGH);
|
||||
if (!fd) {
|
||||
uError("%s Failed to open %s", __func__, cp_path);
|
||||
TAOS_CHECK_RETURN(TAOS_SYSTEM_ERROR(errno));
|
||||
TAOS_CHECK_RETURN(terrno);
|
||||
}
|
||||
|
||||
checkpoint->thefile = fd;
|
||||
|
@ -162,7 +162,7 @@ int32_t cos_cp_load(char const* filepath, SCheckpoint* checkpoint) {
|
|||
|
||||
TdFilePtr fd = taosOpenFile(filepath, TD_FILE_READ);
|
||||
if (!fd) {
|
||||
TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), &lino, _exit);
|
||||
TAOS_CHECK_GOTO(terrno, &lino, _exit);
|
||||
}
|
||||
|
||||
int64_t size = -1;
|
||||
|
@ -175,7 +175,7 @@ int32_t cos_cp_load(char const* filepath, SCheckpoint* checkpoint) {
|
|||
|
||||
int64_t n = taosReadFile(fd, cp_body, size);
|
||||
if (n < 0) {
|
||||
TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), &lino, _exit);
|
||||
TAOS_CHECK_GOTO(terrno, &lino, _exit);
|
||||
} else if (n != size) {
|
||||
TAOS_CHECK_GOTO(TSDB_CODE_FILE_CORRUPTED, &lino, _exit);
|
||||
}
|
||||
|
@ -207,13 +207,13 @@ static int32_t cos_cp_save_json(cJSON const* json, SCheckpoint* checkpoint) {
|
|||
|
||||
TdFilePtr fp = checkpoint->thefile;
|
||||
if (taosFtruncateFile(fp, 0) < 0) {
|
||||
TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), &lino, _exit);
|
||||
TAOS_CHECK_GOTO(terrno, &lino, _exit);
|
||||
}
|
||||
if (taosLSeekFile(fp, 0, SEEK_SET) < 0) {
|
||||
TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), &lino, _exit);
|
||||
TAOS_CHECK_GOTO(terrno, &lino, _exit);
|
||||
}
|
||||
if (taosWriteFile(fp, data, strlen(data)) < 0) {
|
||||
TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), &lino, _exit);
|
||||
TAOS_CHECK_GOTO(terrno, &lino, _exit);
|
||||
}
|
||||
|
||||
if (taosFsyncFile(fp) < 0) {
|
||||
|
|
|
@ -58,7 +58,7 @@ static int32_t generateConfigFile(char* confDir) {
|
|||
TdFilePtr pFile = taosOpenFile(confDir, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC);
|
||||
if (pFile == NULL) {
|
||||
uError("[rsync] open conf file error, dir:%s," ERRNO_ERR_FORMAT, confDir, ERRNO_ERR_DATA);
|
||||
return TAOS_SYSTEM_ERROR(errno);
|
||||
return terrno;
|
||||
}
|
||||
|
||||
#ifdef WINDOWS
|
||||
|
@ -90,10 +90,10 @@ static int32_t generateConfigFile(char* confDir) {
|
|||
#endif
|
||||
);
|
||||
uDebug("[rsync] conf:%s", confContent);
|
||||
if (taosWriteFile(pFile, confContent, strlen(confContent)) <= 0) {
|
||||
if (taosWriteFile(pFile, confContent, strlen(confContent)) != TSDB_CODE_SUCCESS) {
|
||||
uError("[rsync] write conf file error," ERRNO_ERR_FORMAT, ERRNO_ERR_DATA);
|
||||
(void)taosCloseFile(&pFile);
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
return code;
|
||||
}
|
||||
|
||||
|
|
|
@ -731,6 +731,10 @@ int32_t blockDataMergeNRows(SSDataBlock* pDest, const SSDataBlock* pSrc, int32_t
|
|||
}
|
||||
|
||||
void blockDataShrinkNRows(SSDataBlock* pBlock, int32_t numOfRows) {
|
||||
if (numOfRows == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (numOfRows >= pBlock->info.rows) {
|
||||
blockDataCleanup(pBlock);
|
||||
return;
|
||||
|
@ -2936,6 +2940,8 @@ int32_t buildCtbNameByGroupIdImpl(const char* stbFullName, uint64_t groupId, cha
|
|||
|
||||
// return length of encoded data, return -1 if failed
|
||||
int32_t blockEncode(const SSDataBlock* pBlock, char* data, int32_t numOfCols) {
|
||||
blockDataCheck(pBlock, false);
|
||||
|
||||
int32_t dataLen = 0;
|
||||
|
||||
// todo extract method
|
||||
|
@ -3177,6 +3183,9 @@ int32_t blockDecode(SSDataBlock* pBlock, const char* pData, const char** pEndPos
|
|||
}
|
||||
|
||||
*pEndPos = pStart;
|
||||
|
||||
blockDataCheck(pBlock, false);
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -3386,3 +3395,77 @@ int32_t blockDataGetSortedRows(SSDataBlock* pDataBlock, SArray* pOrderInfo) {
|
|||
|
||||
return nextRowIdx;
|
||||
}
|
||||
|
||||
void blockDataCheck(const SSDataBlock* pDataBlock, bool forceChk) {
|
||||
return;
|
||||
|
||||
if (NULL == pDataBlock || pDataBlock->info.rows == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
#define BLOCK_DATA_CHECK_TRESSA(o) ;
|
||||
//#define BLOCK_DATA_CHECK_TRESSA(o) A S S E R T(o)
|
||||
|
||||
BLOCK_DATA_CHECK_TRESSA(pDataBlock->info.rows > 0);
|
||||
|
||||
if (!pDataBlock->info.dataLoad && !forceChk) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool isVarType = false;
|
||||
int32_t colLen = 0;
|
||||
int32_t nextPos = 0;
|
||||
int64_t checkRows = 0;
|
||||
int64_t typeValue = 0;
|
||||
int32_t colNum = taosArrayGetSize(pDataBlock->pDataBlock);
|
||||
for (int32_t i = 0; i < colNum; ++i) {
|
||||
SColumnInfoData* pCol = (SColumnInfoData*)taosArrayGet(pDataBlock->pDataBlock, i);
|
||||
isVarType = IS_VAR_DATA_TYPE(pCol->info.type);
|
||||
checkRows = pDataBlock->info.rows;
|
||||
|
||||
if (isVarType) {
|
||||
BLOCK_DATA_CHECK_TRESSA(pCol->varmeta.offset);
|
||||
} else {
|
||||
BLOCK_DATA_CHECK_TRESSA(pCol->nullbitmap);
|
||||
}
|
||||
|
||||
nextPos = 0;
|
||||
for (int64_t r = 0; r < checkRows; ++r) {
|
||||
if (!colDataIsNull_s(pCol, r)) {
|
||||
BLOCK_DATA_CHECK_TRESSA(pCol->pData);
|
||||
BLOCK_DATA_CHECK_TRESSA(pCol->varmeta.length <= pCol->varmeta.allocLen);
|
||||
|
||||
if (isVarType) {
|
||||
BLOCK_DATA_CHECK_TRESSA(pCol->varmeta.allocLen > 0);
|
||||
BLOCK_DATA_CHECK_TRESSA(pCol->varmeta.offset[r] < pCol->varmeta.length);
|
||||
if (pCol->reassigned) {
|
||||
BLOCK_DATA_CHECK_TRESSA(pCol->varmeta.offset[r] >= 0);
|
||||
} else if (0 == r) {
|
||||
nextPos = pCol->varmeta.offset[r];
|
||||
} else {
|
||||
BLOCK_DATA_CHECK_TRESSA(pCol->varmeta.offset[r] == nextPos);
|
||||
}
|
||||
|
||||
colLen = varDataTLen(pCol->pData + pCol->varmeta.offset[r]);
|
||||
BLOCK_DATA_CHECK_TRESSA(colLen >= VARSTR_HEADER_SIZE);
|
||||
BLOCK_DATA_CHECK_TRESSA(colLen <= pCol->info.bytes);
|
||||
|
||||
if (pCol->reassigned) {
|
||||
BLOCK_DATA_CHECK_TRESSA((pCol->varmeta.offset[r] + colLen) <= pCol->varmeta.length);
|
||||
} else {
|
||||
nextPos += colLen;
|
||||
BLOCK_DATA_CHECK_TRESSA(nextPos <= pCol->varmeta.length);
|
||||
}
|
||||
|
||||
typeValue = *(char*)(pCol->pData + pCol->varmeta.offset[r] + colLen - 1);
|
||||
} else {
|
||||
GET_TYPED_DATA(typeValue, int64_t, pCol->info.type, colDataGetNumData(pCol, r));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -71,20 +71,20 @@ int32_t mmReadFile(const char *path, SMnodeOpt *pOption) {
|
|||
}
|
||||
|
||||
if (taosStatFile(file, NULL, NULL, NULL) < 0) {
|
||||
dInfo("mnode file:%s not exist, reason:%s", file, tstrerror(TAOS_SYSTEM_ERROR(errno)));
|
||||
dInfo("mnode file:%s not exist, reason:%s", file, tstrerror(terrno));
|
||||
return 0;
|
||||
}
|
||||
|
||||
pFile = taosOpenFile(file, TD_FILE_READ);
|
||||
if (pFile == NULL) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
dError("failed to open mnode file:%s since %s", file, tstrerror(code));
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
int64_t size = 0;
|
||||
if (taosFStatFile(pFile, &size, NULL) < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = taosFStatFile(pFile, &size, NULL);
|
||||
if (code != 0) {
|
||||
dError("failed to fstat mnode file:%s since %s", file, tstrerror(code));
|
||||
goto _OVER;
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ int32_t mmReadFile(const char *path, SMnodeOpt *pOption) {
|
|||
}
|
||||
|
||||
if (taosReadFile(pFile, pData, size) != size) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
dError("failed to read mnode file:%s since %s", file, tstrerror(code));
|
||||
goto _OVER;
|
||||
}
|
||||
|
@ -197,17 +197,17 @@ int32_t mmWriteFile(const char *path, const SMnodeOpt *pOption) {
|
|||
|
||||
pFile = taosOpenFile(file, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC | TD_FILE_WRITE_THROUGH);
|
||||
if (pFile == NULL) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
int32_t len = strlen(buffer);
|
||||
if (taosWriteFile(pFile, buffer, len) <= 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
goto _OVER;
|
||||
}
|
||||
if (taosFsyncFile(pFile) < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
|
@ -215,10 +215,7 @@ int32_t mmWriteFile(const char *path, const SMnodeOpt *pOption) {
|
|||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
goto _OVER;
|
||||
}
|
||||
if (taosRenameFile(file, realfile) != 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
goto _OVER;
|
||||
}
|
||||
TAOS_CHECK_GOTO(taosRenameFile(file, realfile), NULL, _OVER);
|
||||
|
||||
dInfo("succeed to write mnode file:%s, deloyed:%d", realfile, pOption->deploy);
|
||||
|
||||
|
|
|
@ -106,7 +106,7 @@ int32_t vmGetVnodeListFromFile(SVnodeMgmt *pMgmt, SWrapperCfg **ppCfgs, int32_t
|
|||
snprintf(file, sizeof(file), "%s%svnodes.json", pMgmt->path, TD_DIRSEP);
|
||||
|
||||
if (taosStatFile(file, NULL, NULL, NULL) < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
dInfo("vnode file:%s not exist, reason:%s", file, tstrerror(code));
|
||||
code = 0;
|
||||
return code;
|
||||
|
@ -114,14 +114,14 @@ int32_t vmGetVnodeListFromFile(SVnodeMgmt *pMgmt, SWrapperCfg **ppCfgs, int32_t
|
|||
|
||||
pFile = taosOpenFile(file, TD_FILE_READ);
|
||||
if (pFile == NULL) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
dError("failed to open vnode file:%s since %s", file, tstrerror(code));
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
int64_t size = 0;
|
||||
if (taosFStatFile(pFile, &size, NULL) < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = taosFStatFile(pFile, &size, NULL);
|
||||
if (code != 0) {
|
||||
dError("failed to fstat mnode file:%s since %s", file, tstrerror(code));
|
||||
goto _OVER;
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ int32_t vmGetVnodeListFromFile(SVnodeMgmt *pMgmt, SWrapperCfg **ppCfgs, int32_t
|
|||
}
|
||||
|
||||
if (taosReadFile(pFile, pData, size) != size) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
dError("failed to read vnode file:%s since %s", file, tstrerror(code));
|
||||
goto _OVER;
|
||||
}
|
||||
|
@ -234,13 +234,13 @@ int32_t vmWriteVnodeListToFile(SVnodeMgmt *pMgmt) {
|
|||
|
||||
pFile = taosOpenFile(file, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC | TD_FILE_WRITE_THROUGH);
|
||||
if (pFile == NULL) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
int32_t len = strlen(buffer);
|
||||
if (taosWriteFile(pFile, buffer, len) <= 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
goto _OVER;
|
||||
}
|
||||
if (taosFsyncFile(pFile) < 0) {
|
||||
|
@ -253,12 +253,8 @@ int32_t vmWriteVnodeListToFile(SVnodeMgmt *pMgmt) {
|
|||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
goto _OVER;
|
||||
}
|
||||
if (taosRenameFile(file, realfile) != 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
goto _OVER;
|
||||
}
|
||||
TAOS_CHECK_GOTO(taosRenameFile(file, realfile), NULL, _OVER);
|
||||
|
||||
code = 0;
|
||||
dInfo("succeed to write vnodes file:%s, vnodes:%d", realfile, numOfVnodes);
|
||||
|
||||
_OVER:
|
||||
|
|
|
@ -203,14 +203,14 @@ int32_t dmReadEps(SDnodeData *pData) {
|
|||
|
||||
pFile = taosOpenFile(file, TD_FILE_READ);
|
||||
if (pFile == NULL) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
dError("failed to open dnode file:%s since %s", file, terrstr());
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
int64_t size = 0;
|
||||
if (taosFStatFile(pFile, &size, NULL) < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = taosFStatFile(pFile, &size, NULL);
|
||||
if (code != 0) {
|
||||
dError("failed to fstat dnode file:%s since %s", file, terrstr());
|
||||
goto _OVER;
|
||||
}
|
||||
|
@ -222,7 +222,7 @@ int32_t dmReadEps(SDnodeData *pData) {
|
|||
}
|
||||
|
||||
if (taosReadFile(pFile, content, size) != size) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
dError("failed to read dnode file:%s since %s", file, terrstr());
|
||||
goto _OVER;
|
||||
}
|
||||
|
@ -333,16 +333,15 @@ int32_t dmWriteEps(SDnodeData *pData) {
|
|||
}
|
||||
|
||||
pFile = taosOpenFile(file, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC | TD_FILE_WRITE_THROUGH);
|
||||
if (pFile == NULL) TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), NULL, _OVER);
|
||||
if (pFile == NULL) TAOS_CHECK_GOTO(terrno, NULL, _OVER);
|
||||
|
||||
int32_t len = strlen(buffer);
|
||||
if (taosWriteFile(pFile, buffer, len) <= 0) TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), NULL, _OVER);
|
||||
if (taosFsyncFile(pFile) < 0) TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), NULL, _OVER);
|
||||
if (taosWriteFile(pFile, buffer, len) <= 0) TAOS_CHECK_GOTO(terrno, NULL, _OVER);
|
||||
if (taosFsyncFile(pFile) < 0) TAOS_CHECK_GOTO(terrno, NULL, _OVER);
|
||||
|
||||
(void)taosCloseFile(&pFile);
|
||||
if (taosRenameFile(file, realfile) != 0) TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), NULL, _OVER);
|
||||
TAOS_CHECK_GOTO(taosRenameFile(file, realfile), NULL, _OVER);
|
||||
|
||||
code = 0;
|
||||
pData->updateTime = taosGetTimestampMs();
|
||||
dInfo("succeed to write dnode file:%s, num:%d ver:%" PRId64, realfile, (int32_t)taosArrayGetSize(pData->dnodeEps),
|
||||
pData->dnodeVer);
|
||||
|
@ -599,7 +598,7 @@ static int32_t dmReadDnodePairs(SDnodeData *pData) {
|
|||
snprintf(file, sizeof(file), "%s%sdnode%sep.json", tsDataDir, TD_DIRSEP, TD_DIRSEP);
|
||||
|
||||
if (taosStatFile(file, NULL, NULL, NULL) < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
dDebug("dnode file:%s not exist, reason:%s", file, tstrerror(code));
|
||||
code = 0;
|
||||
goto _OVER;
|
||||
|
@ -607,14 +606,14 @@ static int32_t dmReadDnodePairs(SDnodeData *pData) {
|
|||
|
||||
pFile = taosOpenFile(file, TD_FILE_READ);
|
||||
if (pFile == NULL) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
dError("failed to open dnode file:%s since %s", file, terrstr());
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
int64_t size = 0;
|
||||
if (taosFStatFile(pFile, &size, NULL) < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = taosFStatFile(pFile, &size, NULL);
|
||||
if (code != 0) {
|
||||
dError("failed to fstat dnode file:%s since %s", file, terrstr());
|
||||
goto _OVER;
|
||||
}
|
||||
|
@ -626,7 +625,7 @@ static int32_t dmReadDnodePairs(SDnodeData *pData) {
|
|||
}
|
||||
|
||||
if (taosReadFile(pFile, content, size) != size) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
terrno = terrno;
|
||||
dError("failed to read dnode file:%s since %s", file, terrstr());
|
||||
goto _OVER;
|
||||
}
|
||||
|
|
|
@ -56,14 +56,14 @@ int32_t dmReadFile(const char *path, const char *name, bool *pDeployed) {
|
|||
|
||||
pFile = taosOpenFile(file, TD_FILE_READ);
|
||||
if (pFile == NULL) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
dError("failed to open file:%s since %s", file, tstrerror(code));
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
int64_t size = 0;
|
||||
if (taosFStatFile(pFile, &size, NULL) < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = taosFStatFile(pFile, &size, NULL);
|
||||
if (code != 0) {
|
||||
dError("failed to fstat file:%s since %s", file, tstrerror(code));
|
||||
goto _OVER;
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ int32_t dmReadFile(const char *path, const char *name, bool *pDeployed) {
|
|||
}
|
||||
|
||||
if (taosReadFile(pFile, content, size) != size) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
dError("failed to read file:%s since %s", file, tstrerror(code));
|
||||
goto _OVER;
|
||||
}
|
||||
|
@ -148,17 +148,17 @@ int32_t dmWriteFile(const char *path, const char *name, bool deployed) {
|
|||
|
||||
pFile = taosOpenFile(file, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC | TD_FILE_WRITE_THROUGH);
|
||||
if (pFile == NULL) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
int32_t len = strlen(buffer);
|
||||
if (taosWriteFile(pFile, buffer, len) <= 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
goto _OVER;
|
||||
}
|
||||
if (taosFsyncFile(pFile) < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
|
@ -166,12 +166,8 @@ int32_t dmWriteFile(const char *path, const char *name, bool deployed) {
|
|||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
goto _OVER;
|
||||
}
|
||||
if (taosRenameFile(file, realfile) != 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
goto _OVER;
|
||||
}
|
||||
TAOS_CHECK_GOTO(taosRenameFile(file, realfile), NULL, _OVER);
|
||||
|
||||
code = 0;
|
||||
dInfo("succeed to write file:%s, deloyed:%d", realfile, deployed);
|
||||
|
||||
_OVER:
|
||||
|
@ -192,7 +188,7 @@ int32_t dmCheckRunning(const char *dataDir, TdFilePtr *pFile) {
|
|||
|
||||
*pFile = taosOpenFile(filepath, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC | TD_FILE_CLOEXEC);
|
||||
if (*pFile == NULL) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
dError("failed to open file:%s since %s", filepath, tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
@ -203,7 +199,7 @@ int32_t dmCheckRunning(const char *dataDir, TdFilePtr *pFile) {
|
|||
ret = taosLockFile(*pFile);
|
||||
if (ret == 0) break;
|
||||
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
taosMsleep(1000);
|
||||
retryTimes++;
|
||||
dError("failed to lock file:%s since %s, retryTimes:%d", filepath, tstrerror(code), retryTimes);
|
||||
|
@ -243,12 +239,12 @@ static int32_t dmWriteCheckCodeFile(char *file, char *realfile, char *key, bool
|
|||
|
||||
pFile = taosOpenFile(file, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC | TD_FILE_WRITE_THROUGH);
|
||||
if (pFile == NULL) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
if (taosWriteFile(pFile, opts.result, len) <= 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
|
@ -262,10 +258,7 @@ static int32_t dmWriteCheckCodeFile(char *file, char *realfile, char *key, bool
|
|||
goto _OVER;
|
||||
}
|
||||
|
||||
if (taosRenameFile(file, realfile) != 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
goto _OVER;
|
||||
}
|
||||
TAOS_CHECK_GOTO(taosRenameFile(file, realfile), NULL, _OVER);
|
||||
|
||||
encryptDebug("succeed to write checkCode file:%s", realfile);
|
||||
|
||||
|
@ -283,17 +276,17 @@ static int32_t dmWriteEncryptCodeFile(char *file, char *realfile, char *encryptC
|
|||
|
||||
pFile = taosOpenFile(file, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC | TD_FILE_WRITE_THROUGH);
|
||||
if (pFile == NULL) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
int32_t len = strlen(encryptCode);
|
||||
if (taosWriteFile(pFile, encryptCode, len) <= 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
goto _OVER;
|
||||
}
|
||||
if (taosFsyncFile(pFile) < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
|
@ -302,10 +295,7 @@ static int32_t dmWriteEncryptCodeFile(char *file, char *realfile, char *encryptC
|
|||
goto _OVER;
|
||||
}
|
||||
|
||||
if (taosRenameFile(file, realfile) != 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
goto _OVER;
|
||||
}
|
||||
TAOS_CHECK_GOTO(taosRenameFile(file, realfile), NULL, _OVER);
|
||||
|
||||
encryptDebug("succeed to write encryptCode file:%s", realfile);
|
||||
|
||||
|
@ -325,25 +315,25 @@ static int32_t dmCompareEncryptKey(char *file, char *key, bool toLogFile) {
|
|||
|
||||
pFile = taosOpenFile(file, TD_FILE_READ);
|
||||
if (pFile == NULL) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
encryptError("failed to open dnode file:%s since %s", file, tstrerror(code));
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
if (taosFStatFile(pFile, &size, NULL) < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = taosFStatFile(pFile, &size, NULL);
|
||||
if (code != 0) {
|
||||
encryptError("failed to fstat dnode file:%s since %s", file, tstrerror(code));
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
content = taosMemoryMalloc(size);
|
||||
if (content == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
if (taosReadFile(pFile, content, size) != size) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
encryptError("failed to read dnode file:%s since %s", file, tstrerror(code));
|
||||
goto _OVER;
|
||||
}
|
||||
|
@ -465,14 +455,14 @@ static int32_t dmReadEncryptCodeFile(char *file, char **output) {
|
|||
|
||||
pFile = taosOpenFile(file, TD_FILE_READ);
|
||||
if (pFile == NULL) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
dError("failed to open dnode file:%s since %s", file, tstrerror(code));
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
int64_t size = 0;
|
||||
if (taosFStatFile(pFile, &size, NULL) < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = taosFStatFile(pFile, &size, NULL);
|
||||
if (code != 0) {
|
||||
dError("failed to fstat dnode file:%s since %s", file, tstrerror(code));
|
||||
goto _OVER;
|
||||
}
|
||||
|
@ -484,7 +474,7 @@ static int32_t dmReadEncryptCodeFile(char *file, char **output) {
|
|||
}
|
||||
|
||||
if (taosReadFile(pFile, content, size) != size) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
dError("failed to read dnode file:%s since %s", file, tstrerror(code));
|
||||
goto _OVER;
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "systable.h"
|
||||
#include "thttp.h"
|
||||
#include "tjson.h"
|
||||
#include "command.h"
|
||||
|
||||
#define DB_VER_NUMBER 1
|
||||
#define DB_RESERVE_SIZE 27
|
||||
|
@ -2321,18 +2322,25 @@ static void mndDumpDbInfoData(SMnode *pMnode, SSDataBlock *pBlock, SDbObj *pDb,
|
|||
(void)colDataSetVal(pColInfo, rows, (const char *)strictVstr, false);
|
||||
|
||||
char durationVstr[128] = {0};
|
||||
int32_t len = sprintf(&durationVstr[VARSTR_HEADER_SIZE], "%dm", pDb->cfg.daysPerFile);
|
||||
int32_t len = formatDurationOrKeep(&durationVstr[VARSTR_HEADER_SIZE], pDb->cfg.daysPerFile);
|
||||
|
||||
varDataSetLen(durationVstr, len);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, rows, (const char *)durationVstr, false);
|
||||
|
||||
char keepVstr[128] = {0};
|
||||
char keepVstr[512] = {0};
|
||||
char keep0Str[128] = {0};
|
||||
char keep1Str[128] = {0};
|
||||
char keep2Str[128] = {0};
|
||||
|
||||
int32_t lenKeep0 = formatDurationOrKeep(keep0Str, pDb->cfg.daysToKeep0);
|
||||
int32_t lenKeep1 = formatDurationOrKeep(keep1Str, pDb->cfg.daysToKeep1);
|
||||
int32_t lenKeep2 = formatDurationOrKeep(keep2Str, pDb->cfg.daysToKeep2);
|
||||
|
||||
if (pDb->cfg.daysToKeep0 > pDb->cfg.daysToKeep1 || pDb->cfg.daysToKeep0 > pDb->cfg.daysToKeep2) {
|
||||
len = sprintf(&keepVstr[VARSTR_HEADER_SIZE], "%dm,%dm,%dm", pDb->cfg.daysToKeep1, pDb->cfg.daysToKeep2,
|
||||
pDb->cfg.daysToKeep0);
|
||||
len = sprintf(&keepVstr[VARSTR_HEADER_SIZE], "%s,%s,%s", keep1Str, keep2Str, keep0Str);
|
||||
} else {
|
||||
len = sprintf(&keepVstr[VARSTR_HEADER_SIZE], "%dm,%dm,%dm", pDb->cfg.daysToKeep0, pDb->cfg.daysToKeep1,
|
||||
pDb->cfg.daysToKeep2);
|
||||
len = sprintf(&keepVstr[VARSTR_HEADER_SIZE], "%s,%s,%s", keep0Str, keep1Str, keep2Str);
|
||||
}
|
||||
varDataSetLen(keepVstr, len);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
|
|
|
@ -616,7 +616,7 @@ void mndDumpSdb() {
|
|||
char file[] = "sdb.json";
|
||||
TdFilePtr pFile = taosOpenFile(file, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC | TD_FILE_WRITE_THROUGH);
|
||||
if (pFile == NULL) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
terrno = terrno;
|
||||
mError("failed to write %s since %s", file, terrstr());
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -368,7 +368,11 @@ static void *mndBuildVDropSmaReq(SMnode *pMnode, SVgObj *pVgroup, SSmaObj *pSma,
|
|||
SEncoder encoder = {0};
|
||||
int32_t contLen;
|
||||
SName name = {0};
|
||||
(void)tNameFromString(&name, pSma->name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
int32_t code = tNameFromString(&name, pSma->name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
terrno = code;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SVDropTSmaReq req = {0};
|
||||
req.indexUid = pSma->uid;
|
||||
|
@ -1669,8 +1673,7 @@ static int32_t mndSetUpdateDbTsmaVersionPrepareLogs(SMnode *pMnode, STrans *pTra
|
|||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
(void)sdbSetRawStatus(pRedoRaw, SDB_STATUS_READY);
|
||||
TAOS_RETURN(code);
|
||||
TAOS_RETURN(sdbSetRawStatus(pRedoRaw, SDB_STATUS_READY));
|
||||
}
|
||||
|
||||
static int32_t mndSetUpdateDbTsmaVersionCommitLogs(SMnode *pMnode, STrans *pTrans, SDbObj *pOld, SDbObj *pNew) {
|
||||
|
@ -1686,8 +1689,7 @@ static int32_t mndSetUpdateDbTsmaVersionCommitLogs(SMnode *pMnode, STrans *pTran
|
|||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
(void)sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY);
|
||||
TAOS_RETURN(code);
|
||||
TAOS_RETURN(sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY));
|
||||
}
|
||||
|
||||
static int32_t mndCreateTSMATxnPrepare(SCreateTSMACxt* pCxt) {
|
||||
|
|
|
@ -64,6 +64,8 @@ static int32_t mndProcessKillTransReq(SRpcMsg *pReq);
|
|||
static int32_t mndRetrieveTrans(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
|
||||
static void mndCancelGetNextTrans(SMnode *pMnode, void *pIter);
|
||||
|
||||
static int32_t tsMaxTransId = 0;
|
||||
|
||||
int32_t mndInitTrans(SMnode *pMnode) {
|
||||
SSdbTable table = {
|
||||
.sdbType = SDB_TRANS,
|
||||
|
@ -602,7 +604,10 @@ STrans *mndTransCreate(SMnode *pMnode, ETrnPolicy policy, ETrnConflct conflict,
|
|||
tstrncpy(pTrans->opername, opername, TSDB_TRANS_OPER_LEN);
|
||||
}
|
||||
|
||||
pTrans->id = sdbGetMaxId(pMnode->pSdb, SDB_TRANS);
|
||||
int32_t sdbMaxId = sdbGetMaxId(pMnode->pSdb, SDB_TRANS);
|
||||
sdbReadLock(pMnode->pSdb, SDB_TRANS);
|
||||
pTrans->id = TMAX(sdbMaxId, tsMaxTransId + 1);
|
||||
sdbUnLock(pMnode->pSdb, SDB_TRANS);
|
||||
pTrans->stage = TRN_STAGE_PREPARE;
|
||||
pTrans->policy = policy;
|
||||
pTrans->conflict = conflict;
|
||||
|
@ -1027,6 +1032,9 @@ int32_t mndTransPrepare(SMnode *pMnode, STrans *pTrans) {
|
|||
mInfo("trans:%d, prepare transaction", pTrans->id);
|
||||
if ((code = mndTransSync(pMnode, pTrans)) != 0) {
|
||||
mError("trans:%d, failed to prepare since %s", pTrans->id, tstrerror(code));
|
||||
sdbWriteLock(pMnode->pSdb, SDB_TRANS);
|
||||
tsMaxTransId = TMAX(pTrans->id, tsMaxTransId);
|
||||
sdbUnLock(pMnode->pSdb, SDB_TRANS);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
mInfo("trans:%d, prepare finished", pTrans->id);
|
||||
|
|
|
@ -86,8 +86,7 @@ static int32_t sdbReadFileHead(SSdb *pSdb, TdFilePtr pFile) {
|
|||
int64_t sver = 0;
|
||||
int32_t ret = taosReadFile(pFile, &sver, sizeof(int64_t));
|
||||
if (ret < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
TAOS_RETURN(code);
|
||||
return terrno;
|
||||
}
|
||||
if (ret != sizeof(int64_t)) {
|
||||
code = TSDB_CODE_FILE_CORRUPTED;
|
||||
|
@ -100,8 +99,7 @@ static int32_t sdbReadFileHead(SSdb *pSdb, TdFilePtr pFile) {
|
|||
|
||||
ret = taosReadFile(pFile, &pSdb->applyIndex, sizeof(int64_t));
|
||||
if (ret < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
TAOS_RETURN(code);
|
||||
return terrno;
|
||||
}
|
||||
if (ret != sizeof(int64_t)) {
|
||||
code = TSDB_CODE_FILE_CORRUPTED;
|
||||
|
@ -110,8 +108,7 @@ static int32_t sdbReadFileHead(SSdb *pSdb, TdFilePtr pFile) {
|
|||
|
||||
ret = taosReadFile(pFile, &pSdb->applyTerm, sizeof(int64_t));
|
||||
if (ret < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
TAOS_RETURN(code);
|
||||
return terrno;
|
||||
}
|
||||
if (ret != sizeof(int64_t)) {
|
||||
code = TSDB_CODE_FILE_CORRUPTED;
|
||||
|
@ -120,8 +117,7 @@ static int32_t sdbReadFileHead(SSdb *pSdb, TdFilePtr pFile) {
|
|||
|
||||
ret = taosReadFile(pFile, &pSdb->applyConfig, sizeof(int64_t));
|
||||
if (ret < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
TAOS_RETURN(code);
|
||||
return terrno;
|
||||
}
|
||||
if (ret != sizeof(int64_t)) {
|
||||
code = TSDB_CODE_FILE_CORRUPTED;
|
||||
|
@ -132,8 +128,7 @@ static int32_t sdbReadFileHead(SSdb *pSdb, TdFilePtr pFile) {
|
|||
int64_t maxId = 0;
|
||||
ret = taosReadFile(pFile, &maxId, sizeof(int64_t));
|
||||
if (ret < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
TAOS_RETURN(code);
|
||||
return terrno;
|
||||
}
|
||||
if (ret != sizeof(int64_t)) {
|
||||
code = TSDB_CODE_FILE_CORRUPTED;
|
||||
|
@ -148,8 +143,7 @@ static int32_t sdbReadFileHead(SSdb *pSdb, TdFilePtr pFile) {
|
|||
int64_t ver = 0;
|
||||
ret = taosReadFile(pFile, &ver, sizeof(int64_t));
|
||||
if (ret < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
TAOS_RETURN(code);
|
||||
return terrno;
|
||||
}
|
||||
if (ret != sizeof(int64_t)) {
|
||||
code = TSDB_CODE_FILE_CORRUPTED;
|
||||
|
@ -163,8 +157,7 @@ static int32_t sdbReadFileHead(SSdb *pSdb, TdFilePtr pFile) {
|
|||
char reserve[SDB_RESERVE_SIZE] = {0};
|
||||
ret = taosReadFile(pFile, reserve, sizeof(reserve));
|
||||
if (ret < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
TAOS_RETURN(code);
|
||||
return terrno;
|
||||
}
|
||||
if (ret != sizeof(reserve)) {
|
||||
code = TSDB_CODE_FILE_CORRUPTED;
|
||||
|
@ -175,26 +168,21 @@ static int32_t sdbReadFileHead(SSdb *pSdb, TdFilePtr pFile) {
|
|||
}
|
||||
|
||||
static int32_t sdbWriteFileHead(SSdb *pSdb, TdFilePtr pFile) {
|
||||
int32_t code = 0;
|
||||
int64_t sver = SDB_FILE_VER;
|
||||
if (taosWriteFile(pFile, &sver, sizeof(int64_t)) != sizeof(int64_t)) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
TAOS_RETURN(code);
|
||||
return terrno;
|
||||
}
|
||||
|
||||
if (taosWriteFile(pFile, &pSdb->applyIndex, sizeof(int64_t)) != sizeof(int64_t)) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
TAOS_RETURN(code);
|
||||
return terrno;
|
||||
}
|
||||
|
||||
if (taosWriteFile(pFile, &pSdb->applyTerm, sizeof(int64_t)) != sizeof(int64_t)) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
TAOS_RETURN(code);
|
||||
return terrno;
|
||||
}
|
||||
|
||||
if (taosWriteFile(pFile, &pSdb->applyConfig, sizeof(int64_t)) != sizeof(int64_t)) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
TAOS_RETURN(code);
|
||||
return terrno;
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < SDB_TABLE_SIZE; ++i) {
|
||||
|
@ -203,8 +191,7 @@ static int32_t sdbWriteFileHead(SSdb *pSdb, TdFilePtr pFile) {
|
|||
maxId = pSdb->maxId[i];
|
||||
}
|
||||
if (taosWriteFile(pFile, &maxId, sizeof(int64_t)) != sizeof(int64_t)) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
TAOS_RETURN(code);
|
||||
return terrno;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -214,15 +201,13 @@ static int32_t sdbWriteFileHead(SSdb *pSdb, TdFilePtr pFile) {
|
|||
ver = pSdb->tableVer[i];
|
||||
}
|
||||
if (taosWriteFile(pFile, &ver, sizeof(int64_t)) != sizeof(int64_t)) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
TAOS_RETURN(code);
|
||||
return terrno;
|
||||
}
|
||||
}
|
||||
|
||||
char reserve[SDB_RESERVE_SIZE] = {0};
|
||||
if (taosWriteFile(pFile, reserve, sizeof(reserve)) != sizeof(reserve)) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
TAOS_RETURN(code);
|
||||
return terrno;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -249,7 +234,7 @@ static int32_t sdbReadFileImp(SSdb *pSdb) {
|
|||
TdFilePtr pFile = taosOpenFile(file, TD_FILE_READ);
|
||||
if (pFile == NULL) {
|
||||
taosMemoryFree(pRaw);
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
mInfo("read sdb file:%s finished since %s", file, tstrerror(code));
|
||||
return 0;
|
||||
}
|
||||
|
@ -274,7 +259,7 @@ static int32_t sdbReadFileImp(SSdb *pSdb) {
|
|||
if (ret == 0) break;
|
||||
|
||||
if (ret < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
mError("failed to read sdb file:%s since %s", file, tstrerror(code));
|
||||
goto _OVER;
|
||||
}
|
||||
|
@ -305,7 +290,7 @@ static int32_t sdbReadFileImp(SSdb *pSdb) {
|
|||
|
||||
ret = taosReadFile(pFile, pRaw->pData, readLen);
|
||||
if (ret < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
mError("failed to read sdb file:%s since %s, ret:%" PRId64 " readLen:%d", file, tstrerror(code), ret, readLen);
|
||||
goto _OVER;
|
||||
}
|
||||
|
@ -401,7 +386,7 @@ static int32_t sdbWriteFileImp(SSdb *pSdb, int32_t skip_type) {
|
|||
|
||||
TdFilePtr pFile = taosOpenFile(tmpfile, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC);
|
||||
if (pFile == NULL) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
mError("failed to open sdb file:%s for write since %s", tmpfile, tstrerror(code));
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
@ -447,7 +432,7 @@ static int32_t sdbWriteFileImp(SSdb *pSdb, int32_t skip_type) {
|
|||
pRaw->status = pRow->status;
|
||||
|
||||
if (taosWriteFile(pFile, pRaw, sizeof(SSdbRaw)) != sizeof(SSdbRaw)) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
taosHashCancelIterate(hash, ppRow);
|
||||
sdbFreeRaw(pRaw);
|
||||
break;
|
||||
|
@ -479,7 +464,7 @@ static int32_t sdbWriteFileImp(SSdb *pSdb, int32_t skip_type) {
|
|||
}
|
||||
|
||||
if (taosWriteFile(pFile, newData, newDataLen) != newDataLen) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
taosHashCancelIterate(hash, ppRow);
|
||||
sdbFreeRaw(pRaw);
|
||||
break;
|
||||
|
@ -491,7 +476,7 @@ static int32_t sdbWriteFileImp(SSdb *pSdb, int32_t skip_type) {
|
|||
|
||||
int32_t cksum = taosCalcChecksum(0, (const uint8_t *)pRaw, sizeof(SSdbRaw) + pRaw->dataLen);
|
||||
if (taosWriteFile(pFile, &cksum, sizeof(int32_t)) != sizeof(int32_t)) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = errno;
|
||||
taosHashCancelIterate(hash, ppRow);
|
||||
sdbFreeRaw(pRaw);
|
||||
break;
|
||||
|
@ -523,7 +508,6 @@ static int32_t sdbWriteFileImp(SSdb *pSdb, int32_t skip_type) {
|
|||
if (code == 0) {
|
||||
code = taosRenameFile(tmpfile, curfile);
|
||||
if (code != 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
mError("failed to write sdb file:%s since %s", curfile, tstrerror(code));
|
||||
}
|
||||
}
|
||||
|
@ -654,8 +638,8 @@ int32_t sdbStartRead(SSdb *pSdb, SSdbIter **ppIter, int64_t *index, int64_t *ter
|
|||
int64_t commitTerm = pSdb->commitTerm;
|
||||
int64_t commitConfig = pSdb->commitConfig;
|
||||
if (taosCopyFile(datafile, pIter->name) < 0) {
|
||||
code = terrno;
|
||||
(void)taosThreadMutexUnlock(&pSdb->filelock);
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
mError("failed to copy sdb file %s to %s since %s", datafile, pIter->name, tstrerror(code));
|
||||
sdbCloseIter(pIter);
|
||||
TAOS_RETURN(code);
|
||||
|
@ -664,7 +648,7 @@ int32_t sdbStartRead(SSdb *pSdb, SSdbIter **ppIter, int64_t *index, int64_t *ter
|
|||
|
||||
pIter->file = taosOpenFile(pIter->name, TD_FILE_READ);
|
||||
if (pIter->file == NULL) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
mError("failed to open sdb file:%s since %s", pIter->name, tstrerror(code));
|
||||
sdbCloseIter(pIter);
|
||||
TAOS_RETURN(code);
|
||||
|
@ -693,7 +677,7 @@ int32_t sdbDoRead(SSdb *pSdb, SSdbIter *pIter, void **ppBuf, int32_t *len) {
|
|||
|
||||
int32_t readlen = taosReadFile(pIter->file, pBuf, maxlen);
|
||||
if (readlen < 0 || readlen > maxlen) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
mError("sdbiter:%p, failed to read snapshot since %s, total:%" PRId64, pIter, tstrerror(code), pIter->total);
|
||||
*ppBuf = NULL;
|
||||
*len = 0;
|
||||
|
@ -724,7 +708,7 @@ int32_t sdbStartWrite(SSdb *pSdb, SSdbIter **ppIter) {
|
|||
|
||||
pIter->file = taosOpenFile(pIter->name, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC);
|
||||
if (pIter->file == NULL) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
mError("failed to open %s since %s", pIter->name, tstrerror(code));
|
||||
sdbCloseIter(pIter);
|
||||
TAOS_RETURN(code);
|
||||
|
@ -758,8 +742,8 @@ int32_t sdbStopWrite(SSdb *pSdb, SSdbIter *pIter, bool isApply, int64_t index, i
|
|||
|
||||
char datafile[PATH_MAX] = {0};
|
||||
snprintf(datafile, sizeof(datafile), "%s%ssdb.data", pSdb->currDir, TD_DIRSEP);
|
||||
if (taosRenameFile(pIter->name, datafile) != 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = taosRenameFile(pIter->name, datafile);
|
||||
if (code != 0) {
|
||||
mError("sdbiter:%p, failed to rename file %s to %s since %s", pIter, pIter->name, datafile, tstrerror(code));
|
||||
goto _OVER;
|
||||
}
|
||||
|
@ -792,7 +776,7 @@ int32_t sdbDoWrite(SSdb *pSdb, SSdbIter *pIter, void *pBuf, int32_t len) {
|
|||
int32_t code = 0;
|
||||
int32_t writelen = taosWriteFile(pIter->file, pBuf, len);
|
||||
if (writelen != len) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
mError("failed to write len:%d since %s, total:%" PRId64, len, tstrerror(code), pIter->total);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
|
|
@ -280,19 +280,19 @@ void tsdbGetCurrentFName(STsdb *pTsdb, char *current, char *current_t);
|
|||
// tsdbReaderWriter.c ==============================================================================================
|
||||
// SDataFReader
|
||||
int32_t tsdbDataFReaderOpen(SDataFReader **ppReader, STsdb *pTsdb, SDFileSet *pSet);
|
||||
int32_t tsdbDataFReaderClose(SDataFReader **ppReader);
|
||||
void tsdbDataFReaderClose(SDataFReader **ppReader);
|
||||
int32_t tsdbReadBlockIdx(SDataFReader *pReader, SArray *aBlockIdx);
|
||||
int32_t tsdbReadDataBlk(SDataFReader *pReader, SBlockIdx *pBlockIdx, SMapData *mDataBlk);
|
||||
int32_t tsdbReadSttBlk(SDataFReader *pReader, int32_t iStt, SArray *aSttBlk);
|
||||
// SDelFReader
|
||||
int32_t tsdbDelFReaderOpen(SDelFReader **ppReader, SDelFile *pFile, STsdb *pTsdb);
|
||||
int32_t tsdbDelFReaderClose(SDelFReader **ppReader);
|
||||
void tsdbDelFReaderClose(SDelFReader **ppReader);
|
||||
int32_t tsdbReadDelDatav1(SDelFReader *pReader, SDelIdx *pDelIdx, SArray *aDelData, int64_t maxVer);
|
||||
int32_t tsdbReadDelData(SDelFReader *pReader, SDelIdx *pDelIdx, SArray *aDelData);
|
||||
int32_t tsdbReadDelIdx(SDelFReader *pReader, SArray *aDelIdx);
|
||||
|
||||
// tsdbRead.c ==============================================================================================
|
||||
int32_t tsdbTakeReadSnap2(STsdbReader *pReader, _query_reseek_func_t reseek, STsdbReadSnap **ppSnap);
|
||||
int32_t tsdbTakeReadSnap2(STsdbReader *pReader, _query_reseek_func_t reseek, STsdbReadSnap **ppSnap, const char* id);
|
||||
void tsdbUntakeReadSnap2(STsdbReader *pReader, STsdbReadSnap *pSnap, bool proactive);
|
||||
int32_t tsdbGetTableSchema(SMeta *pMeta, int64_t uid, STSchema **pSchema, int64_t *suid);
|
||||
|
||||
|
@ -342,7 +342,6 @@ typedef struct {
|
|||
rocksdb_writeoptions_t *writeoptions;
|
||||
rocksdb_readoptions_t *readoptions;
|
||||
rocksdb_writebatch_t *writebatch;
|
||||
rocksdb_writebatch_t *rwritebatch;
|
||||
STSchema *pTSchema;
|
||||
} SRocksCache;
|
||||
|
||||
|
@ -363,7 +362,6 @@ struct STsdb {
|
|||
SMemTable *imem;
|
||||
STsdbFS fs; // old
|
||||
SLRUCache *lruCache;
|
||||
SCacheFlushState flushState;
|
||||
TdThreadMutex lruMutex;
|
||||
SLRUCache *biCache;
|
||||
TdThreadMutex biMutex;
|
||||
|
@ -678,8 +676,8 @@ typedef TARRAY2(STFileSet *) TFileSetArray;
|
|||
typedef struct STFileSetRange STFileSetRange;
|
||||
typedef TARRAY2(STFileSetRange *) TFileSetRangeArray; // disjoint ranges
|
||||
|
||||
int32_t tsdbTFileSetRangeClear(STFileSetRange **fsr);
|
||||
void tsdbTFileSetRangeArrayDestroy(TFileSetRangeArray **ppArr);
|
||||
void tsdbTFileSetRangeClear(STFileSetRange **fsr);
|
||||
void tsdbTFileSetRangeArrayDestroy(TFileSetRangeArray **ppArr);
|
||||
|
||||
// fset partition
|
||||
enum {
|
||||
|
|
|
@ -214,10 +214,8 @@ static int32_t tsdbOpenRocksCache(STsdb *pTsdb) {
|
|||
}
|
||||
|
||||
rocksdb_writebatch_t *writebatch = rocksdb_writebatch_create();
|
||||
rocksdb_writebatch_t *rwritebatch = rocksdb_writebatch_create();
|
||||
|
||||
pTsdb->rCache.writebatch = writebatch;
|
||||
pTsdb->rCache.rwritebatch = rwritebatch;
|
||||
pTsdb->rCache.my_comparator = cmp;
|
||||
pTsdb->rCache.options = options;
|
||||
pTsdb->rCache.writeoptions = writeoptions;
|
||||
|
@ -248,7 +246,6 @@ static void tsdbCloseRocksCache(STsdb *pTsdb) {
|
|||
rocksdb_close(pTsdb->rCache.db);
|
||||
rocksdb_flushoptions_destroy(pTsdb->rCache.flushoptions);
|
||||
rocksdb_writebatch_destroy(pTsdb->rCache.writebatch);
|
||||
rocksdb_writebatch_destroy(pTsdb->rCache.rwritebatch);
|
||||
rocksdb_readoptions_destroy(pTsdb->rCache.readoptions);
|
||||
rocksdb_writeoptions_destroy(pTsdb->rCache.writeoptions);
|
||||
rocksdb_options_destroy(pTsdb->rCache.options);
|
||||
|
@ -258,8 +255,8 @@ static void tsdbCloseRocksCache(STsdb *pTsdb) {
|
|||
taosMemoryFree(pTsdb->rCache.pTSchema);
|
||||
}
|
||||
|
||||
static void rocksMayWrite(STsdb *pTsdb, bool force, bool read) {
|
||||
rocksdb_writebatch_t *wb = read ? pTsdb->rCache.rwritebatch : pTsdb->rCache.writebatch;
|
||||
static void rocksMayWrite(STsdb *pTsdb, bool force) {
|
||||
rocksdb_writebatch_t *wb = pTsdb->rCache.writebatch;
|
||||
|
||||
int count = rocksdb_writebatch_count(wb);
|
||||
if ((force && count > 0) || count >= ROCKS_BATCH_SIZE) {
|
||||
|
@ -270,7 +267,6 @@ static void rocksMayWrite(STsdb *pTsdb, bool force, bool read) {
|
|||
tsdbError("vgId:%d, %s failed at line %d, count: %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__, count,
|
||||
err);
|
||||
rocksdb_free(err);
|
||||
// pTsdb->flushState.flush_count = 0;
|
||||
}
|
||||
|
||||
rocksdb_writebatch_clear(wb);
|
||||
|
@ -459,47 +455,23 @@ static int32_t tsdbCacheSerialize(SLastCol *pLastCol, char **value, size_t *size
|
|||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||
}
|
||||
|
||||
static void tsdbCachePutBatch(SLastCol *pLastCol, const void *key, size_t klen, SCacheFlushState *state) {
|
||||
int32_t code = 0;
|
||||
STsdb *pTsdb = state->pTsdb;
|
||||
SRocksCache *rCache = &pTsdb->rCache;
|
||||
rocksdb_writebatch_t *wb = rCache->writebatch;
|
||||
char *rocks_value = NULL;
|
||||
size_t vlen = 0;
|
||||
|
||||
code = tsdbCacheSerialize(pLastCol, &rocks_value, &vlen);
|
||||
if (code) {
|
||||
tsdbError("tsdb/cache: vgId:%d, serialize failed since %s.", TD_VID(pTsdb->pVnode), tstrerror(code));
|
||||
return;
|
||||
}
|
||||
|
||||
rocksdb_writebatch_put(wb, (char *)key, klen, rocks_value, vlen);
|
||||
|
||||
taosMemoryFree(rocks_value);
|
||||
|
||||
if (++state->flush_count >= ROCKS_BATCH_SIZE) {
|
||||
char *err = NULL;
|
||||
|
||||
rocksdb_write(rCache->db, rCache->writeoptions, wb, &err);
|
||||
if (NULL != err) {
|
||||
tsdbError("vgId:%d, %s failed at line %d, count: %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
||||
state->flush_count, err);
|
||||
rocksdb_free(err);
|
||||
}
|
||||
|
||||
rocksdb_writebatch_clear(wb);
|
||||
|
||||
state->flush_count = 0;
|
||||
}
|
||||
}
|
||||
static int32_t tsdbCachePutToRocksdb(STsdb *pTsdb, SLastKey *pLastKey, SLastCol *pLastCol);
|
||||
|
||||
int tsdbCacheFlushDirty(const void *key, size_t klen, void *value, void *ud) {
|
||||
SLastCol *pLastCol = (SLastCol *)value;
|
||||
|
||||
if (pLastCol->dirty) {
|
||||
tsdbCachePutBatch(pLastCol, key, klen, (SCacheFlushState *)ud);
|
||||
STsdb *pTsdb = (STsdb *)ud;
|
||||
|
||||
int32_t code = tsdbCachePutToRocksdb(pTsdb, (SLastKey *)key, pLastCol);
|
||||
if (code) {
|
||||
tsdbError("tsdb/cache: vgId:%d, flush dirty lru failed since %s.", TD_VID(pTsdb->pVnode), tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
||||
pLastCol->dirty = 0;
|
||||
|
||||
rocksMayWrite(pTsdb, false);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -514,10 +486,9 @@ int32_t tsdbCacheCommit(STsdb *pTsdb) {
|
|||
|
||||
(void)taosThreadMutexLock(&pTsdb->lruMutex);
|
||||
|
||||
taosLRUCacheApply(pCache, tsdbCacheFlushDirty, &pTsdb->flushState);
|
||||
taosLRUCacheApply(pCache, tsdbCacheFlushDirty, pTsdb);
|
||||
|
||||
rocksMayWrite(pTsdb, true, false);
|
||||
rocksMayWrite(pTsdb, true, true);
|
||||
rocksMayWrite(pTsdb, true);
|
||||
rocksdb_flush(pTsdb->rCache.db, pTsdb->rCache.flushoptions, &err);
|
||||
|
||||
(void)taosThreadMutexUnlock(&pTsdb->lruMutex);
|
||||
|
@ -606,7 +577,7 @@ static void tsdbCacheDeleter(const void *key, size_t klen, void *value, void *ud
|
|||
SLastCol *pLastCol = (SLastCol *)value;
|
||||
|
||||
if (pLastCol->dirty) {
|
||||
tsdbCachePutBatch(pLastCol, key, klen, (SCacheFlushState *)ud);
|
||||
(void)tsdbCacheFlushDirty(key, klen, pLastCol, ud);
|
||||
}
|
||||
|
||||
for (uint8_t i = 0; i < pLastCol->rowKey.numOfPKs; ++i) {
|
||||
|
@ -643,11 +614,11 @@ static int32_t tsdbCacheNewTableColumn(STsdb *pTsdb, int64_t uid, int16_t cid, i
|
|||
|
||||
SLastKey *pLastKey = &(SLastKey){.lflag = lflag, .uid = uid, .cid = cid};
|
||||
LRUStatus status = taosLRUCacheInsert(pCache, pLastKey, ROCKS_KEY_LEN, pLastCol, charge, tsdbCacheDeleter, NULL,
|
||||
TAOS_LRU_PRIORITY_LOW, &pTsdb->flushState);
|
||||
TAOS_LRU_PRIORITY_LOW, pTsdb);
|
||||
if (status != TAOS_LRU_STATUS_OK) {
|
||||
tsdbError("vgId:%d, %s failed at line %d status %d.", TD_VID(pTsdb->pVnode), __func__, __LINE__, status);
|
||||
tsdbCacheFreeSLastColItem(pLastCol);
|
||||
code = TSDB_CODE_FAILED;
|
||||
pLastCol = NULL;
|
||||
}
|
||||
|
||||
_exit:
|
||||
|
@ -665,10 +636,9 @@ int32_t tsdbCacheCommitNoLock(STsdb *pTsdb) {
|
|||
SLRUCache *pCache = pTsdb->lruCache;
|
||||
rocksdb_writebatch_t *wb = pTsdb->rCache.writebatch;
|
||||
|
||||
taosLRUCacheApply(pCache, tsdbCacheFlushDirty, &pTsdb->flushState);
|
||||
taosLRUCacheApply(pCache, tsdbCacheFlushDirty, pTsdb);
|
||||
|
||||
rocksMayWrite(pTsdb, true, false);
|
||||
rocksMayWrite(pTsdb, true, true);
|
||||
rocksMayWrite(pTsdb, true);
|
||||
rocksdb_flush(pTsdb->rCache.db, pTsdb->rCache.flushoptions, &err);
|
||||
|
||||
if (NULL != err) {
|
||||
|
@ -738,6 +708,10 @@ static int32_t tsdbCacheDropTableColumn(STsdb *pTsdb, int64_t uid, int16_t cid,
|
|||
|
||||
char **values_list = NULL;
|
||||
size_t *values_list_sizes = NULL;
|
||||
|
||||
// was written by caller
|
||||
// rocksMayWrite(pTsdb, true); // flush writebatch cache
|
||||
|
||||
TAOS_CHECK_GOTO(tsdbCacheGetValuesFromRocks(pTsdb, 2, (const char *const *)keys_list, keys_list_sizes, &values_list,
|
||||
&values_list_sizes),
|
||||
NULL, _exit);
|
||||
|
@ -862,7 +836,7 @@ int32_t tsdbCacheDropTable(STsdb *pTsdb, tb_uid_t uid, tb_uid_t suid, SSchemaWra
|
|||
taosMemoryFree(pTSchema);
|
||||
}
|
||||
|
||||
rocksMayWrite(pTsdb, true, false);
|
||||
rocksMayWrite(pTsdb, false);
|
||||
|
||||
(void)taosThreadMutexUnlock(&pTsdb->lruMutex);
|
||||
|
||||
|
@ -903,7 +877,7 @@ int32_t tsdbCacheDropSubTables(STsdb *pTsdb, SArray *uids, tb_uid_t suid) {
|
|||
|
||||
taosMemoryFree(pTSchema);
|
||||
|
||||
rocksMayWrite(pTsdb, true, false);
|
||||
rocksMayWrite(pTsdb, false);
|
||||
|
||||
(void)taosThreadMutexUnlock(&pTsdb->lruMutex);
|
||||
|
||||
|
@ -934,7 +908,7 @@ int32_t tsdbCacheDropNTableColumn(STsdb *pTsdb, int64_t uid, int16_t cid, bool h
|
|||
|
||||
(void)tsdbCacheDropTableColumn(pTsdb, uid, cid, hasPrimayKey);
|
||||
|
||||
rocksMayWrite(pTsdb, true, false);
|
||||
rocksMayWrite(pTsdb, false);
|
||||
|
||||
(void)taosThreadMutexUnlock(&pTsdb->lruMutex);
|
||||
|
||||
|
@ -973,7 +947,7 @@ int32_t tsdbCacheDropSTableColumn(STsdb *pTsdb, SArray *uids, int16_t cid, bool
|
|||
(void)tsdbCacheDropTableColumn(pTsdb, uid, cid, hasPrimayKey);
|
||||
}
|
||||
|
||||
rocksMayWrite(pTsdb, true, false);
|
||||
rocksMayWrite(pTsdb, false);
|
||||
|
||||
(void)taosThreadMutexUnlock(&pTsdb->lruMutex);
|
||||
|
||||
|
@ -1083,11 +1057,11 @@ static int32_t tsdbCachePutToLRU(STsdb *pTsdb, SLastKey *pLastKey, SLastCol *pLa
|
|||
TAOS_CHECK_EXIT(tsdbCacheReallocSLastCol(pLRULastCol, &charge));
|
||||
|
||||
LRUStatus status = taosLRUCacheInsert(pTsdb->lruCache, pLastKey, ROCKS_KEY_LEN, pLRULastCol, charge, tsdbCacheDeleter,
|
||||
NULL, TAOS_LRU_PRIORITY_LOW, &pTsdb->flushState);
|
||||
NULL, TAOS_LRU_PRIORITY_LOW, pTsdb);
|
||||
if (TAOS_LRU_STATUS_OK != status && TAOS_LRU_STATUS_OK_OVERWRITTEN != status) {
|
||||
tsdbError("vgId:%d, %s failed at line %d status %d.", TD_VID(pTsdb->pVnode), __func__, __LINE__, status);
|
||||
tsdbCacheFreeSLastColItem(pLRULastCol);
|
||||
code = TSDB_CODE_FAILED;
|
||||
pLRULastCol = NULL;
|
||||
}
|
||||
|
||||
_exit:
|
||||
|
@ -1177,6 +1151,8 @@ static int32_t tsdbCacheUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, SArray
|
|||
keys_list_sizes[i] = ROCKS_KEY_LEN;
|
||||
}
|
||||
|
||||
rocksMayWrite(pTsdb, true); // flush writebatch cache
|
||||
|
||||
code = tsdbCacheGetValuesFromRocks(pTsdb, num_keys, (const char *const *)keys_list, keys_list_sizes, &values_list,
|
||||
&values_list_sizes);
|
||||
if (code) {
|
||||
|
@ -1243,7 +1219,7 @@ static int32_t tsdbCacheUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, SArray
|
|||
taosMemoryFreeClear(pToFree);
|
||||
}
|
||||
|
||||
rocksMayWrite(pTsdb, true, false);
|
||||
rocksMayWrite(pTsdb, false);
|
||||
|
||||
taosMemoryFree(keys_list);
|
||||
taosMemoryFree(keys_list_sizes);
|
||||
|
@ -1573,32 +1549,22 @@ static int32_t tsdbCacheLoadFromRaw(STsdb *pTsdb, tb_uid_t uid, SArray *pLastArr
|
|||
}
|
||||
|
||||
LRUStatus status = taosLRUCacheInsert(pCache, &idxKey->key, ROCKS_KEY_LEN, pLastCol, charge, tsdbCacheDeleter, NULL,
|
||||
TAOS_LRU_PRIORITY_LOW, &pTsdb->flushState);
|
||||
TAOS_LRU_PRIORITY_LOW, pTsdb);
|
||||
if (TAOS_LRU_STATUS_OK != status && TAOS_LRU_STATUS_OK_OVERWRITTEN != status) {
|
||||
tsdbError("vgId:%d, %s failed at line %d status %d.", TD_VID(pTsdb->pVnode), __func__, __LINE__, status);
|
||||
tsdbCacheFreeSLastColItem(pLastCol);
|
||||
taosMemoryFree(pLastCol);
|
||||
pLastCol = NULL;
|
||||
TAOS_CHECK_EXIT(TSDB_CODE_FAILED);
|
||||
}
|
||||
|
||||
// store result back to rocks cache
|
||||
wb = pTsdb->rCache.rwritebatch;
|
||||
char *value = NULL;
|
||||
size_t vlen = 0;
|
||||
code = tsdbCacheSerialize(pLastCol, &value, &vlen);
|
||||
code = tsdbCachePutToRocksdb(pTsdb, &idxKey->key, pLastCol);
|
||||
if (code) {
|
||||
tsdbError("tsdb/cache: vgId:%d, serialize failed since %s.", TD_VID(pTsdb->pVnode), tstrerror(code));
|
||||
} else {
|
||||
SLastKey *key = &idxKey->key;
|
||||
size_t klen = ROCKS_KEY_LEN;
|
||||
rocksdb_writebatch_put(wb, (char *)key, klen, value, vlen);
|
||||
taosMemoryFree(value);
|
||||
tsdbError("vgId:%d, %s failed at line %d since %s.", TD_VID(pTsdb->pVnode), __func__, __LINE__, tstrerror(code));
|
||||
TAOS_CHECK_EXIT(code);
|
||||
}
|
||||
}
|
||||
|
||||
if (wb) {
|
||||
rocksMayWrite(pTsdb, false, true);
|
||||
}
|
||||
rocksMayWrite(pTsdb, false);
|
||||
|
||||
_exit:
|
||||
taosArrayDestroy(lastrowTmpIndexArray);
|
||||
|
@ -1638,6 +1604,8 @@ static int32_t tsdbCacheLoadFromRocks(STsdb *pTsdb, tb_uid_t uid, SArray *pLastA
|
|||
keys_list_sizes[i] = ROCKS_KEY_LEN;
|
||||
}
|
||||
|
||||
rocksMayWrite(pTsdb, true); // flush writebatch cache
|
||||
|
||||
code = tsdbCacheGetValuesFromRocks(pTsdb, num_keys, (const char *const *)keys_list, keys_list_sizes, &values_list,
|
||||
&values_list_sizes);
|
||||
if (code) {
|
||||
|
@ -1686,11 +1654,9 @@ static int32_t tsdbCacheLoadFromRocks(STsdb *pTsdb, tb_uid_t uid, SArray *pLastA
|
|||
}
|
||||
|
||||
LRUStatus status = taosLRUCacheInsert(pCache, &idxKey->key, ROCKS_KEY_LEN, pLastCol, charge, tsdbCacheDeleter,
|
||||
NULL, TAOS_LRU_PRIORITY_LOW, &pTsdb->flushState);
|
||||
NULL, TAOS_LRU_PRIORITY_LOW, pTsdb);
|
||||
if (TAOS_LRU_STATUS_OK != status && TAOS_LRU_STATUS_OK_OVERWRITTEN != status) {
|
||||
tsdbError("vgId:%d, %s failed at line %d status %d.", TD_VID(pTsdb->pVnode), __func__, __LINE__, status);
|
||||
tsdbCacheFreeSLastColItem(pLastCol);
|
||||
taosMemoryFreeClear(pLastCol);
|
||||
taosMemoryFreeClear(pToFree);
|
||||
TAOS_CHECK_EXIT(TSDB_CODE_FAILED);
|
||||
}
|
||||
|
@ -1797,6 +1763,7 @@ int32_t tsdbCacheGetBatch(STsdb *pTsdb, tb_uid_t uid, SArray *pLastArray, SCache
|
|||
|
||||
if (remainCols && TARRAY_SIZE(remainCols) > 0) {
|
||||
(void)taosThreadMutexLock(&pTsdb->lruMutex);
|
||||
|
||||
for (int i = 0; i < TARRAY_SIZE(remainCols);) {
|
||||
SIdxKey *idxKey = &((SIdxKey *)TARRAY_DATA(remainCols))[i];
|
||||
LRUHandle *h = taosLRUCacheLookup(pCache, &idxKey->key, ROCKS_KEY_LEN);
|
||||
|
@ -1910,6 +1877,8 @@ int32_t tsdbCacheDel(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, TSKEY sKey, TSKE
|
|||
keys_list_sizes[i] = klen;
|
||||
}
|
||||
|
||||
rocksMayWrite(pTsdb, true); // flush writebatch cache
|
||||
|
||||
TAOS_CHECK_GOTO(tsdbCacheGetValuesFromRocks(pTsdb, numKeys, (const char *const *)keys_list, keys_list_sizes,
|
||||
&values_list, &values_list_sizes),
|
||||
NULL, _exit);
|
||||
|
@ -1944,7 +1913,7 @@ int32_t tsdbCacheDel(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, TSKEY sKey, TSKE
|
|||
taosMemoryFreeClear(pLastCol);
|
||||
}
|
||||
|
||||
rocksMayWrite(pTsdb, true, false);
|
||||
rocksMayWrite(pTsdb, false);
|
||||
|
||||
_exit:
|
||||
(void)taosThreadMutexUnlock(&pTsdb->lruMutex);
|
||||
|
@ -1986,9 +1955,6 @@ int32_t tsdbOpenCache(STsdb *pTsdb) {
|
|||
|
||||
(void)taosThreadMutexInit(&pTsdb->lruMutex, NULL);
|
||||
|
||||
pTsdb->flushState.pTsdb = pTsdb;
|
||||
pTsdb->flushState.flush_count = 0;
|
||||
|
||||
_err:
|
||||
if (code) {
|
||||
tsdbError("tsdb/cache: vgId:%d, open failed at line %d since %s.", TD_VID(pTsdb->pVnode), lino, tstrerror(code));
|
||||
|
@ -2685,12 +2651,14 @@ static int32_t getNextRowFromMem(void *iter, TSDBROW **ppRow, bool *pIgnoreEarli
|
|||
switch (state->state) {
|
||||
case SMEMNEXTROW_ENTER: {
|
||||
if (state->pMem != NULL) {
|
||||
/*
|
||||
if (state->pMem->maxKey <= state->lastTs) {
|
||||
*ppRow = NULL;
|
||||
*pIgnoreEarlierTs = true;
|
||||
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
*/
|
||||
tsdbTbDataIterOpen(state->pMem, NULL, 1, &state->iter);
|
||||
|
||||
TSDBROW *pMemRow = tsdbTbDataIterGet(&state->iter);
|
||||
|
|
|
@ -473,7 +473,7 @@ int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32
|
|||
}
|
||||
|
||||
(void)taosThreadMutexLock(&pr->readerMutex);
|
||||
code = tsdbTakeReadSnap2((STsdbReader*)pr, tsdbCacheQueryReseek, &pr->pReadSnap);
|
||||
code = tsdbTakeReadSnap2((STsdbReader*)pr, tsdbCacheQueryReseek, &pr->pReadSnap, pr->idstr);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _end;
|
||||
}
|
||||
|
|
|
@ -572,7 +572,7 @@ static int32_t tsdbCommitInfoBuild(STsdb *tsdb) {
|
|||
// begin tasks on file set
|
||||
for (int i = 0; i < taosArrayGetSize(tsdb->commitInfo->arr); i++) {
|
||||
SFileSetCommitInfo *info = *(SFileSetCommitInfo **)taosArrayGet(tsdb->commitInfo->arr, i);
|
||||
TAOS_UNUSED(tsdbBeginTaskOnFileSet(tsdb, info->fid, &fset));
|
||||
tsdbBeginTaskOnFileSet(tsdb, info->fid, &fset);
|
||||
if (fset) {
|
||||
code = tsdbTFileSetInitCopy(tsdb, fset, &info->fset);
|
||||
if (code) {
|
||||
|
@ -710,7 +710,7 @@ int32_t tsdbCommitCommit(STsdb *tsdb) {
|
|||
for (int32_t i = 0; i < taosArrayGetSize(tsdb->commitInfo->arr); i++) {
|
||||
SFileSetCommitInfo *info = *(SFileSetCommitInfo **)taosArrayGet(tsdb->commitInfo->arr, i);
|
||||
if (info->fset) {
|
||||
TAOS_UNUSED(tsdbFinishTaskOnFileSet(tsdb, info->fid));
|
||||
tsdbFinishTaskOnFileSet(tsdb, info->fid);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -741,7 +741,7 @@ int32_t tsdbCommitAbort(STsdb *pTsdb) {
|
|||
for (int32_t i = 0; i < taosArrayGetSize(pTsdb->commitInfo->arr); i++) {
|
||||
SFileSetCommitInfo *info = *(SFileSetCommitInfo **)taosArrayGet(pTsdb->commitInfo->arr, i);
|
||||
if (info->fset) {
|
||||
TAOS_UNUSED(tsdbFinishTaskOnFileSet(pTsdb, info->fid));
|
||||
tsdbFinishTaskOnFileSet(pTsdb, info->fid);
|
||||
}
|
||||
}
|
||||
(void)taosThreadMutexUnlock(&pTsdb->mutex);
|
||||
|
|
|
@ -117,7 +117,7 @@ static int32_t tsdbDataFileRAWWriterCloseAbort(SDataFileRAWWriter *writer) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int32_t tsdbDataFileRAWWriterDoClose(SDataFileRAWWriter *writer) { return 0; }
|
||||
static void tsdbDataFileRAWWriterDoClose(SDataFileRAWWriter *writer) { return; }
|
||||
|
||||
static int32_t tsdbDataFileRAWWriterCloseCommit(SDataFileRAWWriter *writer, TFileOpArray *opArr) {
|
||||
int32_t code = 0;
|
||||
|
@ -200,7 +200,7 @@ int32_t tsdbDataFileRAWWriterClose(SDataFileRAWWriter **writer, bool abort, TFil
|
|||
} else {
|
||||
TAOS_CHECK_GOTO(tsdbDataFileRAWWriterCloseCommit(writer[0], opArr), &lino, _exit);
|
||||
}
|
||||
(void)tsdbDataFileRAWWriterDoClose(writer[0]);
|
||||
tsdbDataFileRAWWriterDoClose(writer[0]);
|
||||
}
|
||||
taosMemoryFree(writer[0]);
|
||||
writer[0] = NULL;
|
||||
|
|
|
@ -847,7 +847,7 @@ int32_t tsdbFileWriteBrinBlock(STsdbFD *fd, SBrinBlock *brinBlock, uint32_t cmpr
|
|||
for (int i = 0; i < brinBlock->numOfRecords; i++) {
|
||||
SBrinRecord record;
|
||||
|
||||
(void)tBrinBlockGet(brinBlock, i, &record);
|
||||
TAOS_CHECK_RETURN(tBrinBlockGet(brinBlock, i, &record));
|
||||
if (i == 0) {
|
||||
brinBlk.minTbid.suid = record.suid;
|
||||
brinBlk.minTbid.uid = record.uid;
|
||||
|
@ -1160,7 +1160,8 @@ static int32_t tsdbDataFileDoWriteTableOldData(SDataFileWriter *writer, const ST
|
|||
|
||||
for (; writer->ctx->brinBlockIdx < writer->ctx->brinBlock->numOfRecords; writer->ctx->brinBlockIdx++) {
|
||||
SBrinRecord record;
|
||||
(void)tBrinBlockGet(writer->ctx->brinBlock, writer->ctx->brinBlockIdx, &record);
|
||||
code = tBrinBlockGet(writer->ctx->brinBlock, writer->ctx->brinBlockIdx, &record);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
if (record.uid != writer->ctx->tbid->uid) {
|
||||
writer->ctx->tbHasOldData = false;
|
||||
goto _exit;
|
||||
|
@ -1170,7 +1171,8 @@ static int32_t tsdbDataFileDoWriteTableOldData(SDataFileWriter *writer, const ST
|
|||
goto _exit;
|
||||
} else {
|
||||
SBrinRecord record[1];
|
||||
(void)tBrinBlockGet(writer->ctx->brinBlock, writer->ctx->brinBlockIdx, record);
|
||||
code = tBrinBlockGet(writer->ctx->brinBlock, writer->ctx->brinBlockIdx, record);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
if (tsdbRowKeyCmprNullAsLargest(key, &record->lastKey) > 0) { // key > record->lastKey
|
||||
if (writer->blockData->nRow > 0) {
|
||||
TAOS_CHECK_GOTO(tsdbDataFileDoWriteBlockData(writer, writer->blockData), &lino, _exit);
|
||||
|
|
|
@ -105,18 +105,20 @@ static int32_t tsdbSaveFSToFile(STsdbFS *pFS, const char *fname) {
|
|||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
(void)tsdbFSToBinary(pData, pFS);
|
||||
(void)taosCalcChecksumAppend(0, pData, size);
|
||||
int32_t tsize = tsdbFSToBinary(pData, pFS);
|
||||
|
||||
code = taosCalcChecksumAppend(0, pData, size);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
// save to file
|
||||
pFD = taosOpenFile(fname, TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC | TD_FILE_WRITE_THROUGH);
|
||||
if (pFD == NULL) {
|
||||
TSDB_CHECK_CODE(code = TAOS_SYSTEM_ERROR(errno), lino, _exit);
|
||||
TSDB_CHECK_CODE(code = terrno, lino, _exit);
|
||||
}
|
||||
|
||||
int64_t n = taosWriteFile(pFD, pData, size);
|
||||
if (n < 0) {
|
||||
TSDB_CHECK_CODE(code = TAOS_SYSTEM_ERROR(errno), lino, _exit);
|
||||
TSDB_CHECK_CODE(code = terrno, lino, _exit);
|
||||
}
|
||||
|
||||
if (taosFsyncFile(pFD) < 0) {
|
||||
|
@ -176,7 +178,7 @@ static int32_t tsdbScanAndTryFixFS(STsdb *pTsdb) {
|
|||
if (pTsdb->fs.pDelFile) {
|
||||
tsdbDelFileName(pTsdb, pTsdb->fs.pDelFile, fname);
|
||||
if (taosStatFile(fname, &size, NULL, NULL)) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
}
|
||||
|
@ -190,7 +192,7 @@ static int32_t tsdbScanAndTryFixFS(STsdb *pTsdb) {
|
|||
// head =========
|
||||
tsdbHeadFileName(pTsdb, pSet->diskId, pSet->fid, pSet->pHeadF, fname);
|
||||
if (taosStatFile(fname, &size, NULL, NULL)) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
// if (size != tsdbLogicToFileSize(pSet->pHeadF->size, pTsdb->pVnode->config.tsdbPageSize)) {
|
||||
|
@ -201,7 +203,7 @@ static int32_t tsdbScanAndTryFixFS(STsdb *pTsdb) {
|
|||
// data =========
|
||||
tsdbDataFileName(pTsdb, pSet->diskId, pSet->fid, pSet->pDataF, fname);
|
||||
if (taosStatFile(fname, &size, NULL, NULL)) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
// if (size < tsdbLogicToFileSize(pSet->pDataF->size, pTsdb->pVnode->config.tsdbPageSize)) {
|
||||
|
@ -216,7 +218,7 @@ static int32_t tsdbScanAndTryFixFS(STsdb *pTsdb) {
|
|||
// sma =============
|
||||
tsdbSmaFileName(pTsdb, pSet->diskId, pSet->fid, pSet->pSmaF, fname);
|
||||
if (taosStatFile(fname, &size, NULL, NULL)) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
// if (size < tsdbLogicToFileSize(pSet->pSmaF->size, pTsdb->pVnode->config.tsdbPageSize)) {
|
||||
|
@ -232,7 +234,7 @@ static int32_t tsdbScanAndTryFixFS(STsdb *pTsdb) {
|
|||
for (int32_t iStt = 0; iStt < pSet->nSttF; iStt++) {
|
||||
tsdbSttFileName(pTsdb, pSet->diskId, pSet->fid, pSet->aSttF[iStt], fname);
|
||||
if (taosStatFile(fname, &size, NULL, NULL)) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
// if (size != tsdbLogicToFileSize(pSet->aSttF[iStt]->size, pTsdb->pVnode->config.tsdbPageSize)) {
|
||||
|
@ -291,13 +293,13 @@ static int32_t load_fs(const char *fname, STsdbFS *pFS) {
|
|||
// load binary
|
||||
TdFilePtr pFD = taosOpenFile(fname, TD_FILE_READ);
|
||||
if (pFD == NULL) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
|
||||
int64_t size;
|
||||
if (taosFStatFile(pFD, &size, NULL) < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = taosFStatFile(pFD, &size, NULL);
|
||||
if (code != 0) {
|
||||
(void)taosCloseFile(&pFD);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
|
@ -310,7 +312,7 @@ static int32_t load_fs(const char *fname, STsdbFS *pFS) {
|
|||
}
|
||||
|
||||
if (taosReadFile(pFD, pData, size) < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
(void)taosCloseFile(&pFD);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
|
@ -711,10 +713,7 @@ static int32_t tsdbFSCommit(STsdb *pTsdb) {
|
|||
if (!taosCheckExistFile(current_t)) goto _exit;
|
||||
|
||||
// rename the file
|
||||
if (taosRenameFile(current_t, current) < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
TSDB_CHECK_CODE(taosRenameFile(current_t, current), lino, _exit);
|
||||
|
||||
// Load the new FS
|
||||
code = tsdbFSCreate(&fs);
|
||||
|
|
|
@ -84,15 +84,15 @@ static int32_t save_json(const cJSON *json, const char *fname) {
|
|||
|
||||
fp = taosOpenFile(fname, TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC | TD_FILE_WRITE_THROUGH);
|
||||
if (fp == NULL) {
|
||||
TSDB_CHECK_CODE(code = TAOS_SYSTEM_ERROR(code), lino, _exit);
|
||||
TSDB_CHECK_CODE(code = terrno, lino, _exit);
|
||||
}
|
||||
|
||||
if (taosWriteFile(fp, data, strlen(data)) < 0) {
|
||||
TSDB_CHECK_CODE(code = TAOS_SYSTEM_ERROR(code), lino, _exit);
|
||||
TSDB_CHECK_CODE(code = terrno, lino, _exit);
|
||||
}
|
||||
|
||||
if (taosFsyncFile(fp) < 0) {
|
||||
TSDB_CHECK_CODE(code = TAOS_SYSTEM_ERROR(code), lino, _exit);
|
||||
TSDB_CHECK_CODE(code = terrno, lino, _exit);
|
||||
}
|
||||
|
||||
_exit:
|
||||
|
@ -111,12 +111,13 @@ static int32_t load_json(const char *fname, cJSON **json) {
|
|||
|
||||
TdFilePtr fp = taosOpenFile(fname, TD_FILE_READ);
|
||||
if (fp == NULL) {
|
||||
TSDB_CHECK_CODE(code = TAOS_SYSTEM_ERROR(errno), lino, _exit);
|
||||
TSDB_CHECK_CODE(code = terrno, lino, _exit);
|
||||
}
|
||||
|
||||
int64_t size;
|
||||
if (taosFStatFile(fp, &size, NULL) < 0) {
|
||||
TSDB_CHECK_CODE(code = TAOS_SYSTEM_ERROR(code), lino, _exit);
|
||||
code = taosFStatFile(fp, &size, NULL);
|
||||
if (code != 0) {
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
|
||||
data = taosMemoryMalloc(size + 1);
|
||||
|
@ -125,7 +126,7 @@ static int32_t load_json(const char *fname, cJSON **json) {
|
|||
}
|
||||
|
||||
if (taosReadFile(fp, data, size) < 0) {
|
||||
TSDB_CHECK_CODE(code = TAOS_SYSTEM_ERROR(code), lino, _exit);
|
||||
TSDB_CHECK_CODE(code = terrno, lino, _exit);
|
||||
}
|
||||
data[size] = '\0';
|
||||
|
||||
|
@ -304,10 +305,7 @@ static int32_t commit_edit(STFileSystem *fs) {
|
|||
|
||||
int32_t code;
|
||||
int32_t lino;
|
||||
if ((code = taosRenameFile(current_t, current))) {
|
||||
code = TAOS_SYSTEM_ERROR(code);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
TSDB_CHECK_CODE(taosRenameFile(current_t, current), lino, _exit);
|
||||
|
||||
code = apply_commit(fs);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
@ -365,7 +363,7 @@ static int32_t tsdbFSDoScanAndFixFile(STFileSystem *fs, const STFileObj *fobj) {
|
|||
|
||||
if (tsS3Enabled && fobj->f->lcn > 1) {
|
||||
char fname1[TSDB_FILENAME_LEN];
|
||||
(void)tsdbTFileLastChunkName(fs->tsdb, fobj->f, fname1);
|
||||
tsdbTFileLastChunkName(fs->tsdb, fobj->f, fname1);
|
||||
if (!taosCheckExistFile(fname1)) {
|
||||
code = TSDB_CODE_FILE_CORRUPTED;
|
||||
tsdbError("vgId:%d %s failed since file:%s does not exist", TD_VID(fs->tsdb->pVnode), __func__, fname1);
|
||||
|
@ -648,10 +646,9 @@ _exit:
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t close_file_system(STFileSystem *fs) {
|
||||
static void close_file_system(STFileSystem *fs) {
|
||||
TARRAY2_CLEAR(fs->fSetArr, tsdbTFileSetClear);
|
||||
TARRAY2_CLEAR(fs->fSetArrTmp, tsdbTFileSetClear);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t fset_cmpr_fn(const struct STFileSet *pSet1, const struct STFileSet *pSet2) {
|
||||
|
@ -748,8 +745,8 @@ _exit:
|
|||
return code;
|
||||
}
|
||||
|
||||
static void tsdbFSSetBlockCommit(STFileSet *fset, bool block);
|
||||
extern int32_t tsdbStopAllCompTask(STsdb *tsdb);
|
||||
static void tsdbFSSetBlockCommit(STFileSet *fset, bool block);
|
||||
extern void tsdbStopAllCompTask(STsdb *tsdb);
|
||||
|
||||
int32_t tsdbDisableAndCancelAllBgTask(STsdb *pTsdb) {
|
||||
STFileSystem *fs = pTsdb->pFS;
|
||||
|
@ -784,12 +781,15 @@ int32_t tsdbDisableAndCancelAllBgTask(STsdb *pTsdb) {
|
|||
// destroy all channels
|
||||
for (int32_t i = 0; i < taosArrayGetSize(channelArray); i++) {
|
||||
SVAChannelID *channel = taosArrayGet(channelArray, i);
|
||||
(void)vnodeAChannelDestroy(channel, true);
|
||||
int32_t code = vnodeAChannelDestroy(channel, true);
|
||||
if (code) {
|
||||
tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__, tstrerror(code));
|
||||
}
|
||||
}
|
||||
taosArrayDestroy(channelArray);
|
||||
|
||||
#ifdef TD_ENTERPRISE
|
||||
(void)tsdbStopAllCompTask(pTsdb);
|
||||
tsdbStopAllCompTask(pTsdb);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
@ -800,13 +800,13 @@ void tsdbEnableBgTask(STsdb *pTsdb) {
|
|||
(void)taosThreadMutexUnlock(&pTsdb->mutex);
|
||||
}
|
||||
|
||||
int32_t tsdbCloseFS(STFileSystem **fs) {
|
||||
if (fs[0] == NULL) return 0;
|
||||
void tsdbCloseFS(STFileSystem **fs) {
|
||||
if (fs[0] == NULL) return;
|
||||
|
||||
(void)tsdbDisableAndCancelAllBgTask((*fs)->tsdb);
|
||||
(void)close_file_system(fs[0]);
|
||||
TAOS_UNUSED(tsdbDisableAndCancelAllBgTask((*fs)->tsdb));
|
||||
close_file_system(fs[0]);
|
||||
destroy_fs(fs);
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
|
||||
int64_t tsdbFSAllocEid(STFileSystem *fs) {
|
||||
|
@ -984,13 +984,12 @@ int32_t tsdbFSCreateCopySnapshot(STFileSystem *fs, TFileSetArray **fsetArr) {
|
|||
return code;
|
||||
}
|
||||
|
||||
int32_t tsdbFSDestroyCopySnapshot(TFileSetArray **fsetArr) {
|
||||
void tsdbFSDestroyCopySnapshot(TFileSetArray **fsetArr) {
|
||||
if (fsetArr[0]) {
|
||||
TARRAY2_DESTROY(fsetArr[0], tsdbTFileSetClear);
|
||||
taosMemoryFree(fsetArr[0]);
|
||||
fsetArr[0] = NULL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t tsdbFSCreateRefSnapshot(STFileSystem *fs, TFileSetArray **fsetArr) {
|
||||
|
@ -1026,13 +1025,12 @@ int32_t tsdbFSCreateRefSnapshotWithoutLock(STFileSystem *fs, TFileSetArray **fse
|
|||
return code;
|
||||
}
|
||||
|
||||
int32_t tsdbFSDestroyRefSnapshot(TFileSetArray **fsetArr) {
|
||||
void tsdbFSDestroyRefSnapshot(TFileSetArray **fsetArr) {
|
||||
if (fsetArr[0]) {
|
||||
TARRAY2_DESTROY(fsetArr[0], tsdbTFileSetClear);
|
||||
taosMemoryFreeClear(fsetArr[0]);
|
||||
fsetArr[0] = NULL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static SHashObj *tsdbFSetRangeArrayToHash(TFileSetRangeArray *pRanges) {
|
||||
|
@ -1103,7 +1101,7 @@ _out:
|
|||
return code;
|
||||
}
|
||||
|
||||
int32_t tsdbFSDestroyCopyRangedSnapshot(TFileSetArray **fsetArr) { return tsdbFSDestroyCopySnapshot(fsetArr); }
|
||||
void tsdbFSDestroyCopyRangedSnapshot(TFileSetArray **fsetArr) { tsdbFSDestroyCopySnapshot(fsetArr); }
|
||||
|
||||
int32_t tsdbFSCreateRefRangedSnapshot(STFileSystem *fs, int64_t sver, int64_t ever, TFileSetRangeArray *pRanges,
|
||||
TFileSetRangeArray **fsrArr) {
|
||||
|
@ -1159,7 +1157,7 @@ int32_t tsdbFSCreateRefRangedSnapshot(STFileSystem *fs, int64_t sver, int64_t ev
|
|||
(void)taosThreadMutexUnlock(&fs->tsdb->mutex);
|
||||
|
||||
if (code) {
|
||||
(void)tsdbTFileSetRangeClear(&fsr1);
|
||||
tsdbTFileSetRangeClear(&fsr1);
|
||||
TARRAY2_DESTROY(fsrArr[0], tsdbTFileSetRangeClear);
|
||||
fsrArr[0] = NULL;
|
||||
}
|
||||
|
@ -1174,7 +1172,7 @@ _out:
|
|||
|
||||
void tsdbFSDestroyRefRangedSnapshot(TFileSetRangeArray **fsrArr) { tsdbTFileSetRangeArrayDestroy(fsrArr); }
|
||||
|
||||
int32_t tsdbBeginTaskOnFileSet(STsdb *tsdb, int32_t fid, STFileSet **fset) {
|
||||
void tsdbBeginTaskOnFileSet(STsdb *tsdb, int32_t fid, STFileSet **fset) {
|
||||
int16_t sttTrigger = tsdb->pVnode->config.sttTrigger;
|
||||
|
||||
tsdbFSGetFSet(tsdb->pFS, fid, fset);
|
||||
|
@ -1195,11 +1193,9 @@ int32_t tsdbBeginTaskOnFileSet(STsdb *tsdb, int32_t fid, STFileSet **fset) {
|
|||
}
|
||||
tsdbInfo("vgId:%d begin task on file set:%d", TD_VID(tsdb->pVnode), fid);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t tsdbFinishTaskOnFileSet(STsdb *tsdb, int32_t fid) {
|
||||
void tsdbFinishTaskOnFileSet(STsdb *tsdb, int32_t fid) {
|
||||
int16_t sttTrigger = tsdb->pVnode->config.sttTrigger;
|
||||
if (sttTrigger == 1) {
|
||||
STFileSet *fset = NULL;
|
||||
|
@ -1212,6 +1208,4 @@ int32_t tsdbFinishTaskOnFileSet(STsdb *tsdb, int32_t fid) {
|
|||
tsdbInfo("vgId:%d finish task on file set:%d", TD_VID(tsdb->pVnode), fid);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -38,17 +38,17 @@ typedef enum {
|
|||
/* Exposed APIs */
|
||||
// open/close
|
||||
int32_t tsdbOpenFS(STsdb *pTsdb, STFileSystem **fs, int8_t rollback);
|
||||
int32_t tsdbCloseFS(STFileSystem **fs);
|
||||
void tsdbCloseFS(STFileSystem **fs);
|
||||
// snapshot
|
||||
int32_t tsdbFSCreateCopySnapshot(STFileSystem *fs, TFileSetArray **fsetArr);
|
||||
int32_t tsdbFSDestroyCopySnapshot(TFileSetArray **fsetArr);
|
||||
void tsdbFSDestroyCopySnapshot(TFileSetArray **fsetArr);
|
||||
int32_t tsdbFSCreateRefSnapshot(STFileSystem *fs, TFileSetArray **fsetArr);
|
||||
int32_t tsdbFSCreateRefSnapshotWithoutLock(STFileSystem *fs, TFileSetArray **fsetArr);
|
||||
int32_t tsdbFSDestroyRefSnapshot(TFileSetArray **fsetArr);
|
||||
void tsdbFSDestroyRefSnapshot(TFileSetArray **fsetArr);
|
||||
|
||||
int32_t tsdbFSCreateCopyRangedSnapshot(STFileSystem *fs, TFileSetRangeArray *pExclude, TFileSetArray **fsetArr,
|
||||
TFileOpArray *fopArr);
|
||||
int32_t tsdbFSDestroyCopyRangedSnapshot(TFileSetArray **fsetArr);
|
||||
void tsdbFSDestroyCopyRangedSnapshot(TFileSetArray **fsetArr);
|
||||
int32_t tsdbFSCreateRefRangedSnapshot(STFileSystem *fs, int64_t sver, int64_t ever, TFileSetRangeArray *pRanges,
|
||||
TFileSetRangeArray **fsrArr);
|
||||
void tsdbFSDestroyRefRangedSnapshot(TFileSetRangeArray **fsrArr);
|
||||
|
@ -61,8 +61,8 @@ int32_t tsdbFSEditAbort(STFileSystem *fs);
|
|||
// other
|
||||
void tsdbFSGetFSet(STFileSystem *fs, int32_t fid, STFileSet **fset);
|
||||
int32_t tsdbFSCheckCommit(STsdb *tsdb, int32_t fid);
|
||||
int32_t tsdbBeginTaskOnFileSet(STsdb *tsdb, int32_t fid, STFileSet **fset);
|
||||
int32_t tsdbFinishTaskOnFileSet(STsdb *tsdb, int32_t fid);
|
||||
void tsdbBeginTaskOnFileSet(STsdb *tsdb, int32_t fid, STFileSet **fset);
|
||||
void tsdbFinishTaskOnFileSet(STsdb *tsdb, int32_t fid);
|
||||
// utils
|
||||
int32_t save_fs(const TFileSetArray *arr, const char *fname);
|
||||
void current_fname(STsdb *pTsdb, char *fname, EFCurrentT ftype);
|
||||
|
|
|
@ -64,9 +64,16 @@ static int32_t tsdbSttLvlInitRef(STsdb *pTsdb, const SSttLvl *lvl1, SSttLvl **lv
|
|||
|
||||
STFileObj *fobj1;
|
||||
TARRAY2_FOREACH(lvl1->fobjArr, fobj1) {
|
||||
(void)tsdbTFileObjRef(fobj1);
|
||||
code = tsdbTFileObjRef(fobj1);
|
||||
if (code) {
|
||||
tsdbSttLvlClear(lvl);
|
||||
return code;
|
||||
}
|
||||
code = TARRAY2_APPEND(lvl[0]->fobjArr, fobj1);
|
||||
if (code) return code;
|
||||
if (code) {
|
||||
tsdbSttLvlClear(lvl);
|
||||
return code;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -99,7 +106,12 @@ static int32_t tsdbSttLvlFilteredInitEx(STsdb *pTsdb, const SSttLvl *lvl1, int64
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void tsdbSttLvlRemoveFObj(void *data) { (void)tsdbTFileObjRemove(*(STFileObj **)data); }
|
||||
static void tsdbSttLvlRemoveFObj(void *data) {
|
||||
int32_t code = tsdbTFileObjRemove(*(STFileObj **)data);
|
||||
if (code) {
|
||||
tsdbError("failed to remove file obj, code:%d, error:%s", code, tstrerror(code));
|
||||
}
|
||||
}
|
||||
static void tsdbSttLvlRemove(SSttLvl **lvl) {
|
||||
TARRAY2_DESTROY(lvl[0]->fobjArr, tsdbSttLvlRemoveFObj);
|
||||
taosMemoryFree(lvl[0]);
|
||||
|
@ -348,7 +360,8 @@ int32_t tsdbTFileSetEdit(STsdb *pTsdb, STFileSet *fset, const STFileOp *op) {
|
|||
int32_t idx = TARRAY2_SEARCH_IDX(lvl->fobjArr, &tfobjp, tsdbTFileObjCmpr, TD_EQ);
|
||||
TARRAY2_REMOVE(lvl->fobjArr, idx, tsdbSttLvlClearFObj);
|
||||
} else {
|
||||
(void)tsdbTFileObjUnref(fset->farr[op->of.type]);
|
||||
code = tsdbTFileObjUnref(fset->farr[op->of.type]);
|
||||
if (code) return code;
|
||||
fset->farr[op->of.type] = NULL;
|
||||
}
|
||||
} else {
|
||||
|
@ -391,9 +404,11 @@ int32_t tsdbTFileSetApplyEdit(STsdb *pTsdb, const STFileSet *fset1, STFileSet *f
|
|||
}
|
||||
} else {
|
||||
if (fobj1->f->cid != fobj2->f->cid) {
|
||||
(void)tsdbTFileObjRemove(fobj2);
|
||||
code = tsdbTFileObjRemove(fobj2);
|
||||
if (code) return code;
|
||||
} else {
|
||||
(void)tsdbTFileObjRemoveUpdateLC(fobj2);
|
||||
code = tsdbTFileObjRemoveUpdateLC(fobj2);
|
||||
if (code) return code;
|
||||
}
|
||||
code = tsdbTFileObjInit(pTsdb, fobj1->f, &fset2->farr[ftype]);
|
||||
if (code) return code;
|
||||
|
@ -404,7 +419,8 @@ int32_t tsdbTFileSetApplyEdit(STsdb *pTsdb, const STFileSet *fset1, STFileSet *f
|
|||
if (code) return code;
|
||||
} else {
|
||||
// remove the file
|
||||
(void)tsdbTFileObjRemove(fobj2);
|
||||
code = tsdbTFileObjRemove(fobj2);
|
||||
if (code) return code;
|
||||
fset2->farr[ftype] = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -570,7 +586,11 @@ int32_t tsdbTFileSetInitRef(STsdb *pTsdb, const STFileSet *fset1, STFileSet **fs
|
|||
for (int32_t ftype = TSDB_FTYPE_MIN; ftype < TSDB_FTYPE_MAX; ++ftype) {
|
||||
if (fset1->farr[ftype] == NULL) continue;
|
||||
|
||||
(void)tsdbTFileObjRef(fset1->farr[ftype]);
|
||||
code = tsdbTFileObjRef(fset1->farr[ftype]);
|
||||
if (code) {
|
||||
tsdbTFileSetClear(fset);
|
||||
return code;
|
||||
}
|
||||
fset[0]->farr[ftype] = fset1->farr[ftype];
|
||||
}
|
||||
|
||||
|
@ -595,13 +615,13 @@ int32_t tsdbTFileSetInitRef(STsdb *pTsdb, const STFileSet *fset1, STFileSet **fs
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32_t tsdbTFileSetRangeClear(STFileSetRange **fsr) {
|
||||
if (!fsr[0]) return 0;
|
||||
void tsdbTFileSetRangeClear(STFileSetRange **fsr) {
|
||||
if (!fsr[0]) return;
|
||||
|
||||
tsdbTFileSetClear(&fsr[0]->fset);
|
||||
taosMemoryFree(fsr[0]);
|
||||
fsr[0] = NULL;
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
|
||||
void tsdbTFileSetRangeArrayDestroy(TFileSetRangeArray **ppArr) {
|
||||
|
@ -616,7 +636,11 @@ void tsdbTFileSetClear(STFileSet **fset) {
|
|||
if (fset && *fset) {
|
||||
for (tsdb_ftype_t ftype = TSDB_FTYPE_MIN; ftype < TSDB_FTYPE_MAX; ++ftype) {
|
||||
if ((*fset)->farr[ftype] == NULL) continue;
|
||||
(void)tsdbTFileObjUnref((*fset)->farr[ftype]);
|
||||
int32_t code = tsdbTFileObjUnref((*fset)->farr[ftype]);
|
||||
if (code) {
|
||||
tsdbError("failed to unref file, fid:%d, ftype:%d", (*fset)->fid, ftype);
|
||||
}
|
||||
(*fset)->farr[ftype] = NULL;
|
||||
}
|
||||
|
||||
TARRAY2_DESTROY((*fset)->lvlArr, tsdbSttLvlClear);
|
||||
|
@ -632,7 +656,10 @@ void tsdbTFileSetRemove(STFileSet *fset) {
|
|||
|
||||
for (tsdb_ftype_t ftype = TSDB_FTYPE_MIN; ftype < TSDB_FTYPE_MAX; ++ftype) {
|
||||
if (fset->farr[ftype] != NULL) {
|
||||
(void)tsdbTFileObjRemove(fset->farr[ftype]);
|
||||
int32_t code = tsdbTFileObjRemove(fset->farr[ftype]);
|
||||
if (code) {
|
||||
tsdbError("failed to remove file, fid:%d, ftype:%d", fset->fid, ftype);
|
||||
}
|
||||
fset->farr[ftype] = NULL;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -249,8 +249,8 @@ int32_t tsdbTFileObjRef(STFileObj *fobj) {
|
|||
(void)taosThreadMutexLock(&fobj->mutex);
|
||||
|
||||
if (fobj->ref <= 0 || fobj->state != TSDB_FSTATE_LIVE) {
|
||||
(void)taosThreadMutexUnlock(&fobj->mutex);
|
||||
tsdbError("file %s, fobj:%p ref %d", fobj->fname, fobj, fobj->ref);
|
||||
(void)taosThreadMutexUnlock(&fobj->mutex);
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
|
@ -335,8 +335,8 @@ static void tsdbTFileObjRemoveLC(STFileObj *fobj, bool remove_all) {
|
|||
int32_t tsdbTFileObjRemove(STFileObj *fobj) {
|
||||
(void)taosThreadMutexLock(&fobj->mutex);
|
||||
if (fobj->state != TSDB_FSTATE_LIVE || fobj->ref <= 0) {
|
||||
(void)taosThreadMutexUnlock(&fobj->mutex);
|
||||
tsdbError("file %s, fobj:%p ref %d", fobj->fname, fobj, fobj->ref);
|
||||
(void)taosThreadMutexUnlock(&fobj->mutex);
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
fobj->state = TSDB_FSTATE_DEAD;
|
||||
|
@ -399,7 +399,7 @@ void tsdbTFileName(STsdb *pTsdb, const STFile *f, char fname[]) {
|
|||
}
|
||||
}
|
||||
|
||||
int32_t tsdbTFileLastChunkName(STsdb *pTsdb, const STFile *f, char fname[]) {
|
||||
void tsdbTFileLastChunkName(STsdb *pTsdb, const STFile *f, char fname[]) {
|
||||
SVnode *pVnode = pTsdb->pVnode;
|
||||
STfs *pTfs = pVnode->pTfs;
|
||||
|
||||
|
@ -428,7 +428,6 @@ int32_t tsdbTFileLastChunkName(STsdb *pTsdb, const STFile *f, char fname[]) {
|
|||
f->lcn, //
|
||||
g_tfile_info[f->type].suffix);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool tsdbIsSameTFile(const STFile *f1, const STFile *f2) {
|
||||
|
|
|
@ -45,7 +45,7 @@ enum {
|
|||
int32_t tsdbTFileToJson(const STFile *f, cJSON *json);
|
||||
int32_t tsdbJsonToTFile(const cJSON *json, tsdb_ftype_t ftype, STFile *f);
|
||||
void tsdbTFileName(STsdb *pTsdb, const STFile *f, char fname[]);
|
||||
int32_t tsdbTFileLastChunkName(STsdb *pTsdb, const STFile *f, char fname[]);
|
||||
void tsdbTFileLastChunkName(STsdb *pTsdb, const STFile *f, char fname[]);
|
||||
bool tsdbIsSameTFile(const STFile *f1, const STFile *f2);
|
||||
bool tsdbIsTFileChanged(const STFile *f1, const STFile *f2);
|
||||
|
||||
|
|
|
@ -153,7 +153,8 @@ static int32_t tsdbDataIterNext(STsdbIter *iter, const TABLEID *tbid) {
|
|||
|
||||
for (; iter->dataData->brinBlockIdx < iter->dataData->brinBlock->numOfRecords; iter->dataData->brinBlockIdx++) {
|
||||
SBrinRecord record[1];
|
||||
(void)tBrinBlockGet(iter->dataData->brinBlock, iter->dataData->brinBlockIdx, record);
|
||||
code = tBrinBlockGet(iter->dataData->brinBlock, iter->dataData->brinBlockIdx, record);
|
||||
if (code) return code;
|
||||
|
||||
if (iter->filterByVersion && (record->maxVer < iter->range[0] || record->minVer > iter->range[1])) {
|
||||
continue;
|
||||
|
@ -224,7 +225,7 @@ static int32_t tsdbMemTableIterNext(STsdbIter *iter, const TABLEID *tbid) {
|
|||
|
||||
iter->row->row = row[0];
|
||||
|
||||
(void)tsdbTbDataIterNext(iter->memtData->tbIter);
|
||||
TAOS_UNUSED(tsdbTbDataIterNext(iter->memtData->tbIter));
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
|
@ -373,7 +374,8 @@ static int32_t tsdbDataIterOpen(STsdbIter *iter) {
|
|||
iter->dataData->brinBlkArrayIdx = 0;
|
||||
|
||||
// SBrinBlock
|
||||
(void)tBrinBlockInit(iter->dataData->brinBlock);
|
||||
code = tBrinBlockInit(iter->dataData->brinBlock);
|
||||
if (code) return code;
|
||||
iter->dataData->brinBlockIdx = 0;
|
||||
|
||||
// SBlockData
|
||||
|
|
|
@ -403,7 +403,11 @@ static int32_t tsdbGetOrCreateTbData(SMemTable *pMemTable, tb_uid_t suid, tb_uid
|
|||
pMemTable->aBucket[idx] = pTbData;
|
||||
pMemTable->nTbData++;
|
||||
|
||||
(void)tRBTreePut(pMemTable->tbDataTree, pTbData->rbtn);
|
||||
if (tRBTreePut(pMemTable->tbDataTree, pTbData->rbtn) == NULL) {
|
||||
taosWUnLockLatch(&pMemTable->latch);
|
||||
code = TSDB_CODE_INTERNAL_ERROR;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
taosWUnLockLatch(&pMemTable->latch);
|
||||
|
||||
|
|
|
@ -77,9 +77,8 @@ static int32_t tsdbMergerClose(SMerger *merger) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int32_t tsdbMergeFileSetEndCloseReader(SMerger *merger) {
|
||||
static void tsdbMergeFileSetEndCloseReader(SMerger *merger) {
|
||||
TARRAY2_CLEAR(merger->sttReaderArr, tsdbSttFileReaderClose);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t tsdbMergeFileSetBeginOpenReader(SMerger *merger) {
|
||||
|
@ -219,7 +218,7 @@ _exit:
|
|||
if (code) {
|
||||
tsdbError("vgId:%d %s failed at %s:%d since %s", TD_VID(merger->tsdb->pVnode), __func__, __FILE__, lino,
|
||||
tstrerror(code));
|
||||
(void)tsdbMergeFileSetEndCloseReader(merger);
|
||||
tsdbMergeFileSetEndCloseReader(merger);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
@ -271,7 +270,9 @@ static int32_t tsdbMergeFileSetBeginOpenWriter(SMerger *merger) {
|
|||
|
||||
TAOS_CHECK_GOTO(tfsAllocDisk(merger->tsdb->pVnode->pTfs, level, &did), &lino, _exit);
|
||||
|
||||
(void)tfsMkdirRecurAt(merger->tsdb->pVnode->pTfs, merger->tsdb->path, did);
|
||||
code = tfsMkdirRecurAt(merger->tsdb->pVnode->pTfs, merger->tsdb->path, did);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
SFSetWriterConfig config = {
|
||||
.tsdb = merger->tsdb,
|
||||
.toSttOnly = true,
|
||||
|
@ -354,7 +355,7 @@ static int32_t tsdbMergeFileSetEnd(SMerger *merger) {
|
|||
|
||||
TAOS_CHECK_GOTO(tsdbMergeFileSetEndCloseIter(merger), &lino, _exit);
|
||||
|
||||
TAOS_CHECK_GOTO(tsdbMergeFileSetEndCloseReader(merger), &lino, _exit);
|
||||
tsdbMergeFileSetEndCloseReader(merger);
|
||||
|
||||
// edit file system
|
||||
TAOS_CHECK_GOTO(tsdbFSEditBegin(merger->tsdb->pFS, merger->fopArr, TSDB_FEDIT_MERGE), &lino, _exit);
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include "tsdbFS2.h"
|
||||
|
||||
extern int32_t tsdbOpenCompMonitor(STsdb *tsdb);
|
||||
extern int32_t tsdbCloseCompMonitor(STsdb *tsdb);
|
||||
extern void tsdbCloseCompMonitor(STsdb *tsdb);
|
||||
|
||||
void tsdbSetKeepCfg(STsdb *pTsdb, STsdbCfg *pCfg) {
|
||||
STsdbKeepCfg *pKeepCfg = &pTsdb->keepCfg;
|
||||
|
@ -65,19 +65,23 @@ int32_t tsdbOpen(SVnode *pVnode, STsdb **ppTsdb, const char *dir, STsdbKeepCfg *
|
|||
|
||||
// create dir
|
||||
if (pVnode->pTfs) {
|
||||
(void)tfsMkdir(pVnode->pTfs, pTsdb->path);
|
||||
code = tfsMkdir(pVnode->pTfs, pTsdb->path);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
} else {
|
||||
(void)taosMkDir(pTsdb->path);
|
||||
code = taosMkDir(pTsdb->path);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
|
||||
// open tsdb
|
||||
TAOS_CHECK_GOTO(tsdbOpenFS(pTsdb, &pTsdb->pFS, rollback), &lino, _exit);
|
||||
code = tsdbOpenFS(pTsdb, &pTsdb->pFS, rollback);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
if (pTsdb->pFS->fsstate == TSDB_FS_STATE_INCOMPLETE && force == false) {
|
||||
TAOS_CHECK_GOTO(TSDB_CODE_NEED_RETRY, &lino, _exit);
|
||||
}
|
||||
|
||||
TAOS_CHECK_GOTO(tsdbOpenCache(pTsdb), &lino, _exit);
|
||||
code = tsdbOpenCache(pTsdb);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
#ifdef TD_ENTERPRISE
|
||||
TAOS_CHECK_GOTO(tsdbOpenCompMonitor(pTsdb), &lino, _exit);
|
||||
|
@ -86,7 +90,7 @@ int32_t tsdbOpen(SVnode *pVnode, STsdb **ppTsdb, const char *dir, STsdbKeepCfg *
|
|||
_exit:
|
||||
if (code) {
|
||||
tsdbError("vgId:%d %s failed at %s:%d since %s", TD_VID(pVnode), __func__, __FILE__, lino, tstrerror(code));
|
||||
(void)tsdbCloseFS(&pTsdb->pFS);
|
||||
tsdbCloseFS(&pTsdb->pFS);
|
||||
(void)taosThreadMutexDestroy(&pTsdb->mutex);
|
||||
taosMemoryFree(pTsdb);
|
||||
} else {
|
||||
|
@ -109,10 +113,10 @@ int32_t tsdbClose(STsdb **pTsdb) {
|
|||
(*pTsdb)->mem = NULL;
|
||||
(void)taosThreadMutexUnlock(&(*pTsdb)->mutex);
|
||||
|
||||
(void)tsdbCloseFS(&(*pTsdb)->pFS);
|
||||
tsdbCloseFS(&(*pTsdb)->pFS);
|
||||
tsdbCloseCache(*pTsdb);
|
||||
#ifdef TD_ENTERPRISE
|
||||
(void)tsdbCloseCompMonitor(*pTsdb);
|
||||
tsdbCloseCompMonitor(*pTsdb);
|
||||
#endif
|
||||
(void)taosThreadMutexDestroy(&(*pTsdb)->mutex);
|
||||
taosMemoryFreeClear(*pTsdb);
|
||||
|
|
|
@ -5016,7 +5016,7 @@ int32_t tsdbReaderResume2(STsdbReader* pReader) {
|
|||
int32_t numOfTables = tSimpleHashGetSize(pReader->status.pTableMap);
|
||||
if (numOfTables > 0) {
|
||||
tsdbTrace("tsdb/reader: %p, take snapshot", pReader);
|
||||
code = tsdbTakeReadSnap2(pReader, tsdbSetQueryReseek, &pReader->pReadSnap);
|
||||
code = tsdbTakeReadSnap2(pReader, tsdbSetQueryReseek, &pReader->pReadSnap, pReader->idStr);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _err;
|
||||
}
|
||||
|
@ -5862,7 +5862,7 @@ int32_t tsdbGetTableSchema(SMeta* pMeta, int64_t uid, STSchema** pSchema, int64_
|
|||
return code;
|
||||
}
|
||||
|
||||
int32_t tsdbTakeReadSnap2(STsdbReader* pReader, _query_reseek_func_t reseek, STsdbReadSnap** ppSnap) {
|
||||
int32_t tsdbTakeReadSnap2(STsdbReader* pReader, _query_reseek_func_t reseek, STsdbReadSnap** ppSnap, const char* id) {
|
||||
int32_t code = 0;
|
||||
STsdb* pTsdb = pReader->pTsdb;
|
||||
SVersionRange* pRange = &pReader->info.verRange;
|
||||
|
@ -5872,7 +5872,7 @@ int32_t tsdbTakeReadSnap2(STsdbReader* pReader, _query_reseek_func_t reseek, STs
|
|||
// lock
|
||||
code = taosThreadMutexLock(&pTsdb->mutex);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
tsdbError("failed to lock tsdb, code:%s", tstrerror(code));
|
||||
tsdbError("%s failed to lock tsdb, code:%s", id, tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -5932,18 +5932,19 @@ int32_t tsdbTakeReadSnap2(STsdbReader* pReader, _query_reseek_func_t reseek, STs
|
|||
}
|
||||
|
||||
(void) taosThreadMutexUnlock(&pTsdb->mutex);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);}
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
|
||||
// unlock
|
||||
(void) taosThreadMutexUnlock(&pTsdb->mutex);
|
||||
*ppSnap = pSnap;
|
||||
|
||||
tsdbTrace("vgId:%d, take read snapshot", TD_VID(pTsdb->pVnode));
|
||||
tsdbTrace("%s vgId:%d, take read snapshot", id, TD_VID(pTsdb->pVnode));
|
||||
return code;
|
||||
|
||||
_exit:
|
||||
tsdbError("%s vgId:%d take read snapshot failed, line:%d code:%s", pReader->idStr, TD_VID(pTsdb->pVnode), lino,
|
||||
tstrerror(code));
|
||||
tsdbError("%s vgId:%d take read snapshot failed, line:%d code:%s", id, TD_VID(pTsdb->pVnode), lino, tstrerror(code));
|
||||
|
||||
if (pSnap) {
|
||||
if (pSnap->pNode) taosMemoryFree(pSnap->pNode);
|
||||
if (pSnap->pINode) taosMemoryFree(pSnap->pINode);
|
||||
|
@ -5967,7 +5968,7 @@ void tsdbUntakeReadSnap2(STsdbReader* pReader, STsdbReadSnap* pSnap, bool proact
|
|||
if (pSnap->pNode) taosMemoryFree(pSnap->pNode);
|
||||
if (pSnap->pINode) taosMemoryFree(pSnap->pINode);
|
||||
|
||||
(void) tsdbFSDestroyRefSnapshot(&pSnap->pfSetArray);
|
||||
tsdbFSDestroyRefSnapshot(&pSnap->pfSetArray);
|
||||
|
||||
taosMemoryFree(pSnap);
|
||||
}
|
||||
|
|
|
@ -46,14 +46,14 @@ static int32_t tsdbOpenFileImpl(STsdbFD *pFD) {
|
|||
|
||||
pFD->pFD = taosOpenFile(lc_path, flag);
|
||||
if (pFD->pFD == NULL) {
|
||||
TSDB_CHECK_CODE(code = TAOS_SYSTEM_ERROR(errno), lino, _exit);
|
||||
TSDB_CHECK_CODE(code = terrno, lino, _exit);
|
||||
}
|
||||
if (taosStatFile(lc_path, &lc_size, NULL, NULL) < 0) {
|
||||
TSDB_CHECK_CODE(code = TAOS_SYSTEM_ERROR(errno), lino, _exit);
|
||||
TSDB_CHECK_CODE(code = terrno, lino, _exit);
|
||||
}
|
||||
} else {
|
||||
tsdbInfo("no file: %s", path);
|
||||
TSDB_CHECK_CODE(code = TAOS_SYSTEM_ERROR(errno), lino, _exit);
|
||||
TSDB_CHECK_CODE(code = terrno, lino, _exit);
|
||||
}
|
||||
pFD->s3File = 1;
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ static int32_t tsdbOpenFileImpl(STsdbFD *pFD) {
|
|||
// not check file size when reading data files.
|
||||
if (flag != TD_FILE_READ /* && !pFD->s3File*/) {
|
||||
if (!lc_size && taosStatFile(path, &pFD->szFile, NULL, NULL) < 0) {
|
||||
TSDB_CHECK_CODE(code = TAOS_SYSTEM_ERROR(errno), lino, _exit);
|
||||
TSDB_CHECK_CODE(code = terrno, lino, _exit);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -157,10 +157,11 @@ static int32_t tsdbWriteFilePage(STsdbFD *pFD, int32_t encryptAlgorithm, char *e
|
|||
|
||||
int64_t n = taosLSeekFile(pFD->pFD, offset, SEEK_SET);
|
||||
if (n < 0) {
|
||||
TSDB_CHECK_CODE(code = TAOS_SYSTEM_ERROR(errno), lino, _exit);
|
||||
TSDB_CHECK_CODE(code = terrno, lino, _exit);
|
||||
}
|
||||
|
||||
(void)taosCalcChecksumAppend(0, pFD->pBuf, pFD->szPage);
|
||||
code = taosCalcChecksumAppend(0, pFD->pBuf, pFD->szPage);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
if (encryptAlgorithm == DND_CA_SM4) {
|
||||
// if(tsiEncryptAlgorithm == DND_CA_SM4 && (tsiEncryptScope & DND_CS_TSDB) == DND_CS_TSDB){
|
||||
|
@ -186,7 +187,7 @@ static int32_t tsdbWriteFilePage(STsdbFD *pFD, int32_t encryptAlgorithm, char *e
|
|||
|
||||
n = taosWriteFile(pFD->pFD, pFD->pBuf, pFD->szPage);
|
||||
if (n < 0) {
|
||||
TSDB_CHECK_CODE(code = TAOS_SYSTEM_ERROR(errno), lino, _exit);
|
||||
TSDB_CHECK_CODE(code = terrno, lino, _exit);
|
||||
}
|
||||
|
||||
if (pFD->szFile < pFD->pgno) {
|
||||
|
@ -223,13 +224,13 @@ static int32_t tsdbReadFilePage(STsdbFD *pFD, int64_t pgno, int32_t encryptAlgor
|
|||
// seek
|
||||
int64_t n = taosLSeekFile(pFD->pFD, offset, SEEK_SET);
|
||||
if (n < 0) {
|
||||
TSDB_CHECK_CODE(code = TAOS_SYSTEM_ERROR(errno), lino, _exit);
|
||||
TSDB_CHECK_CODE(code = terrno, lino, _exit);
|
||||
}
|
||||
|
||||
// read
|
||||
n = taosReadFile(pFD->pFD, pFD->pBuf, pFD->szPage);
|
||||
if (n < 0) {
|
||||
TSDB_CHECK_CODE(code = TAOS_SYSTEM_ERROR(errno), lino, _exit);
|
||||
TSDB_CHECK_CODE(code = terrno, lino, _exit);
|
||||
} else if (n < pFD->szPage) {
|
||||
TSDB_CHECK_CODE(code = TSDB_CODE_FILE_CORRUPTED, lino, _exit);
|
||||
}
|
||||
|
@ -376,12 +377,12 @@ static int32_t tsdbReadFileBlock(STsdbFD *pFD, int64_t offset, int64_t size, boo
|
|||
// read last chunk
|
||||
int64_t ret = taosLSeekFile(pFD->pFD, chunksize * (chunkno - pFD->lcn) + cOffset, SEEK_SET);
|
||||
if (ret < 0) {
|
||||
TSDB_CHECK_CODE(code = TAOS_SYSTEM_ERROR(errno), lino, _exit);
|
||||
TSDB_CHECK_CODE(code = terrno, lino, _exit);
|
||||
}
|
||||
|
||||
ret = taosReadFile(pFD->pFD, buf + n, nRead);
|
||||
if (ret < 0) {
|
||||
TSDB_CHECK_CODE(code = TAOS_SYSTEM_ERROR(errno), lino, _exit);
|
||||
TSDB_CHECK_CODE(code = terrno, lino, _exit);
|
||||
} else if (ret < nRead) {
|
||||
TSDB_CHECK_CODE(code = TSDB_CODE_FILE_CORRUPTED, lino, _exit);
|
||||
}
|
||||
|
@ -635,9 +636,8 @@ _exit:
|
|||
return code;
|
||||
}
|
||||
|
||||
int32_t tsdbDataFReaderClose(SDataFReader **ppReader) {
|
||||
int32_t code = 0;
|
||||
if (*ppReader == NULL) return code;
|
||||
void tsdbDataFReaderClose(SDataFReader **ppReader) {
|
||||
if (*ppReader == NULL) return;
|
||||
|
||||
// head
|
||||
tsdbCloseFile(&(*ppReader)->pHeadFD);
|
||||
|
@ -660,7 +660,6 @@ int32_t tsdbDataFReaderClose(SDataFReader **ppReader) {
|
|||
}
|
||||
taosMemoryFree(*ppReader);
|
||||
*ppReader = NULL;
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t tsdbReadBlockIdx(SDataFReader *pReader, SArray *aBlockIdx) {
|
||||
|
@ -819,7 +818,7 @@ _exit:
|
|||
return code;
|
||||
}
|
||||
|
||||
int32_t tsdbDelFReaderClose(SDelFReader **ppReader) {
|
||||
void tsdbDelFReaderClose(SDelFReader **ppReader) {
|
||||
int32_t code = 0;
|
||||
SDelFReader *pReader = *ppReader;
|
||||
|
||||
|
@ -832,7 +831,6 @@ int32_t tsdbDelFReaderClose(SDelFReader **ppReader) {
|
|||
}
|
||||
|
||||
*ppReader = NULL;
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t tsdbReadDelData(SDelFReader *pReader, SDelIdx *pDelIdx, SArray *aDelData) {
|
||||
|
|
|
@ -48,7 +48,7 @@ static int32_t tsdbCopyFileWithLimitedSpeed(TdFilePtr from, TdFilePtr to, int64_
|
|||
int64_t n;
|
||||
int64_t last = taosGetTimestampMs();
|
||||
if ((n = taosFSendFile(to, from, &offset, TMIN(limit, remain))) < 0) {
|
||||
TAOS_CHECK_RETURN(TAOS_SYSTEM_ERROR(errno));
|
||||
TAOS_CHECK_RETURN(terrno);
|
||||
}
|
||||
|
||||
remain -= n;
|
||||
|
@ -71,19 +71,19 @@ static int32_t tsdbDoCopyFileLC(SRTNer *rtner, const STFileObj *from, const STFi
|
|||
char fname_from[TSDB_FILENAME_LEN];
|
||||
char fname_to[TSDB_FILENAME_LEN];
|
||||
|
||||
(void)tsdbTFileLastChunkName(rtner->tsdb, from->f, fname_from);
|
||||
(void)tsdbTFileLastChunkName(rtner->tsdb, to, fname_to);
|
||||
tsdbTFileLastChunkName(rtner->tsdb, from->f, fname_from);
|
||||
tsdbTFileLastChunkName(rtner->tsdb, to, fname_to);
|
||||
|
||||
fdFrom = taosOpenFile(fname_from, TD_FILE_READ);
|
||||
if (fdFrom == NULL) {
|
||||
TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), &lino, _exit);
|
||||
TAOS_CHECK_GOTO(terrno, &lino, _exit);
|
||||
}
|
||||
|
||||
tsdbInfo("vgId: %d, open tofile: %s size: %" PRId64, TD_VID(rtner->tsdb->pVnode), fname_to, from->f->size);
|
||||
|
||||
fdTo = taosOpenFile(fname_to, TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC);
|
||||
if (fdTo == NULL) {
|
||||
TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), &lino, _exit);
|
||||
TAOS_CHECK_GOTO(terrno, &lino, _exit);
|
||||
}
|
||||
|
||||
SVnodeCfg *pCfg = &rtner->tsdb->pVnode->config;
|
||||
|
@ -91,7 +91,7 @@ static int32_t tsdbDoCopyFileLC(SRTNer *rtner, const STFileObj *from, const STFi
|
|||
int64_t lc_size = tsdbLogicToFileSize(to->size, rtner->szPage) - chunksize * (to->lcn - 1);
|
||||
|
||||
if (taosFSendFile(fdTo, fdFrom, 0, lc_size) < 0) {
|
||||
TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), &lino, _exit);
|
||||
TAOS_CHECK_GOTO(terrno, &lino, _exit);
|
||||
}
|
||||
|
||||
_exit:
|
||||
|
@ -116,14 +116,14 @@ static int32_t tsdbDoCopyFile(SRTNer *rtner, const STFileObj *from, const STFile
|
|||
|
||||
fdFrom = taosOpenFile(from->fname, TD_FILE_READ);
|
||||
if (fdFrom == NULL) {
|
||||
TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), &lino, _exit);
|
||||
TAOS_CHECK_GOTO(terrno, &lino, _exit);
|
||||
}
|
||||
|
||||
tsdbInfo("vgId: %d, open tofile: %s size: %" PRId64, TD_VID(rtner->tsdb->pVnode), fname, from->f->size);
|
||||
|
||||
fdTo = taosOpenFile(fname, TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC);
|
||||
if (fdTo == NULL) {
|
||||
TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), &lino, _exit);
|
||||
TAOS_CHECK_GOTO(terrno, &lino, _exit);
|
||||
}
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
|
@ -255,7 +255,8 @@ static int32_t tsdbDoRetention(SRTNer *rtner) {
|
|||
SDiskID did;
|
||||
|
||||
TAOS_CHECK_GOTO(tfsAllocDisk(rtner->tsdb->pVnode->pTfs, expLevel, &did), &lino, _exit);
|
||||
(void)tfsMkdirRecurAt(rtner->tsdb->pVnode->pTfs, rtner->tsdb->path, did);
|
||||
code = tfsMkdirRecurAt(rtner->tsdb->pVnode->pTfs, rtner->tsdb->path, did);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
// data
|
||||
for (int32_t ftype = 0; ftype < TSDB_FTYPE_MAX && (fobj = fset->farr[ftype], 1); ++ftype) {
|
||||
|
@ -316,7 +317,7 @@ static int32_t tsdbRetention(void *arg) {
|
|||
|
||||
// begin task
|
||||
(void)taosThreadMutexLock(&pTsdb->mutex);
|
||||
(void)tsdbBeginTaskOnFileSet(pTsdb, rtnArg->fid, &fset);
|
||||
tsdbBeginTaskOnFileSet(pTsdb, rtnArg->fid, &fset);
|
||||
if (fset && (code = tsdbTFileSetInitCopy(pTsdb, fset, &rtner.fset))) {
|
||||
(void)taosThreadMutexUnlock(&pTsdb->mutex);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
@ -337,7 +338,7 @@ static int32_t tsdbRetention(void *arg) {
|
|||
_exit:
|
||||
if (rtner.fset) {
|
||||
(void)taosThreadMutexLock(&pTsdb->mutex);
|
||||
(void)tsdbFinishTaskOnFileSet(pTsdb, rtnArg->fid);
|
||||
tsdbFinishTaskOnFileSet(pTsdb, rtnArg->fid);
|
||||
(void)taosThreadMutexUnlock(&pTsdb->mutex);
|
||||
}
|
||||
|
||||
|
@ -429,7 +430,7 @@ static int32_t tsdbCopyFileS3(SRTNer *rtner, const STFileObj *from, const STFile
|
|||
|
||||
fdFrom = taosOpenFile(from->fname, TD_FILE_READ);
|
||||
if (fdFrom == NULL) {
|
||||
TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), &lino, _exit);
|
||||
TAOS_CHECK_GOTO(terrno, &lino, _exit);
|
||||
}
|
||||
|
||||
char *object_name = taosDirEntryBaseName(fname);
|
||||
|
@ -519,7 +520,7 @@ static int32_t tsdbMigrateDataFileLCS3(SRTNer *rtner, const STFileObj *fobj, int
|
|||
|
||||
fdFrom = taosOpenFile(fname, TD_FILE_READ);
|
||||
if (fdFrom == NULL) {
|
||||
TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), &lino, _exit);
|
||||
TAOS_CHECK_GOTO(terrno, &lino, _exit);
|
||||
}
|
||||
|
||||
tsdbInfo("vgId:%d, open lcfile: %s size: %" PRId64, TD_VID(rtner->tsdb->pVnode), fname, lc_size);
|
||||
|
@ -527,12 +528,12 @@ static int32_t tsdbMigrateDataFileLCS3(SRTNer *rtner, const STFileObj *fobj, int
|
|||
snprintf(dot2 + 1, TSDB_FQDN_LEN - (dot2 + 1 - object_name), "%d.data", lcn);
|
||||
fdTo = taosOpenFile(fname, TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC);
|
||||
if (fdTo == NULL) {
|
||||
TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), &lino, _exit);
|
||||
TAOS_CHECK_GOTO(terrno, &lino, _exit);
|
||||
}
|
||||
|
||||
int64_t n = taosFSendFile(fdTo, fdFrom, &lc_offset, lc_size);
|
||||
if (n < 0) {
|
||||
TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), &lino, _exit);
|
||||
TAOS_CHECK_GOTO(terrno, &lino, _exit);
|
||||
}
|
||||
|
||||
_exit:
|
||||
|
@ -618,19 +619,19 @@ static int32_t tsdbMigrateDataFileS3(SRTNer *rtner, const STFileObj *fobj, int64
|
|||
|
||||
fdFrom = taosOpenFile(fobj->fname, TD_FILE_READ);
|
||||
if (fdFrom == NULL) {
|
||||
TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), &lino, _exit);
|
||||
TAOS_CHECK_GOTO(terrno, &lino, _exit);
|
||||
}
|
||||
|
||||
tsdbInfo("vgId: %d, open lcfile: %s size: %" PRId64, TD_VID(rtner->tsdb->pVnode), fname, fobj->f->size);
|
||||
|
||||
fdTo = taosOpenFile(fname, TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC);
|
||||
if (fdTo == NULL) {
|
||||
TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), &lino, _exit);
|
||||
TAOS_CHECK_GOTO(terrno, &lino, _exit);
|
||||
}
|
||||
|
||||
int64_t n = taosFSendFile(fdTo, fdFrom, &lc_offset, lc_size);
|
||||
if (n < 0) {
|
||||
TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), &lino, _exit);
|
||||
TAOS_CHECK_GOTO(terrno, &lino, _exit);
|
||||
}
|
||||
|
||||
_exit:
|
||||
|
@ -693,7 +694,7 @@ static int32_t tsdbDoS3Migrate(SRTNer *rtner) {
|
|||
TAOS_CHECK_GOTO(TSDB_CODE_INVALID_PARA, &lino, _exit);
|
||||
}
|
||||
char fname1[TSDB_FILENAME_LEN];
|
||||
(void)tsdbTFileLastChunkName(rtner->tsdb, fobj->f, fname1);
|
||||
tsdbTFileLastChunkName(rtner->tsdb, fobj->f, fname1);
|
||||
|
||||
if (taosCheckExistFile(fname1)) {
|
||||
int32_t mtime = 0;
|
||||
|
|
|
@ -102,7 +102,11 @@ static int32_t tsdbTFileSetToFSetPartition(STFileSet* fset, STsdbFSetPartition**
|
|||
}
|
||||
count++;
|
||||
SVersionRange vr = {.minVer = f->minVer, .maxVer = f->maxVer};
|
||||
(void)TARRAY2_SORT_INSERT(&p->verRanges[typ], vr, tVersionRangeCmprFn);
|
||||
code = TARRAY2_SORT_INSERT(&p->verRanges[typ], vr, tVersionRangeCmprFn);
|
||||
if (code) {
|
||||
tsdbFSetPartitionClear(&p);
|
||||
return code;
|
||||
}
|
||||
}
|
||||
|
||||
typ = TSDB_FSET_RANGE_TYP_STT;
|
||||
|
@ -120,12 +124,20 @@ static int32_t tsdbTFileSetToFSetPartition(STFileSet* fset, STsdbFSetPartition**
|
|||
}
|
||||
count++;
|
||||
SVersionRange vr = {.minVer = f->minVer, .maxVer = f->maxVer};
|
||||
(void)TARRAY2_SORT_INSERT(&p->verRanges[typ], vr, tVersionRangeCmprFn);
|
||||
code = TARRAY2_SORT_INSERT(&p->verRanges[typ], vr, tVersionRangeCmprFn);
|
||||
if (code) {
|
||||
tsdbFSetPartitionClear(&p);
|
||||
return code;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (corrupt && count == 0) {
|
||||
SVersionRange vr = {.minVer = VERSION_MIN, .maxVer = fset->maxVerValid};
|
||||
(void)TARRAY2_SORT_INSERT(&p->verRanges[typ], vr, tVersionRangeCmprFn);
|
||||
code = TARRAY2_SORT_INSERT(&p->verRanges[typ], vr, tVersionRangeCmprFn);
|
||||
if (code) {
|
||||
tsdbFSetPartitionClear(&p);
|
||||
return code;
|
||||
}
|
||||
}
|
||||
ppSP[0] = p;
|
||||
return 0;
|
||||
|
@ -182,7 +194,11 @@ int32_t tsdbFSetPartListToRangeDiff(STsdbFSetPartList* pList, TFileSetRangeArray
|
|||
r->sver = maxVerValid + 1;
|
||||
r->ever = VERSION_MAX;
|
||||
tsdbDebug("range diff fid:%" PRId64 ", sver:%" PRId64 ", ever:%" PRId64, part->fid, r->sver, r->ever);
|
||||
(void)TARRAY2_SORT_INSERT(pDiff, r, tsdbTFileSetRangeCmprFn);
|
||||
code = TARRAY2_SORT_INSERT(pDiff, r, tsdbTFileSetRangeCmprFn);
|
||||
if (code) {
|
||||
taosMemoryFree(r);
|
||||
goto _err;
|
||||
}
|
||||
}
|
||||
ppRanges[0] = pDiff;
|
||||
|
||||
|
|
|
@ -1127,7 +1127,7 @@ int32_t tsdbSnapWriterClose(STsdbSnapWriter** writer, int8_t rollback) {
|
|||
tsdbDataFileReaderClose(&writer[0]->ctx->dataReader);
|
||||
|
||||
TARRAY2_DESTROY(writer[0]->fopArr, NULL);
|
||||
TAOS_UNUSED(tsdbFSDestroyCopyRangedSnapshot(&writer[0]->fsetArr));
|
||||
tsdbFSDestroyCopyRangedSnapshot(&writer[0]->fsetArr);
|
||||
|
||||
for (int32_t i = 0; i < ARRAY_SIZE(writer[0]->buffers); ++i) {
|
||||
tBufferDestroy(writer[0]->buffers + i);
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#include "tsdbFS2.h"
|
||||
#include "tsdbFSetRAW.h"
|
||||
|
||||
static int32_t tsdbSnapRAWReadFileSetCloseReader(STsdbSnapRAWReader* reader);
|
||||
static void tsdbSnapRAWReadFileSetCloseReader(STsdbSnapRAWReader* reader);
|
||||
|
||||
// reader
|
||||
typedef struct SDataFileRAWReaderIter {
|
||||
|
@ -65,7 +65,7 @@ _exit:
|
|||
if (code) {
|
||||
tsdbError("vgId:%d %s failed at line %d since %s, sver:0, ever:%" PRId64 " type:%d", TD_VID(tsdb->pVnode), __func__,
|
||||
lino, tstrerror(code), ever, type);
|
||||
(void)tsdbFSDestroyRefSnapshot(&reader[0]->fsetArr);
|
||||
tsdbFSDestroyRefSnapshot(&reader[0]->fsetArr);
|
||||
taosMemoryFree(reader[0]);
|
||||
reader[0] = NULL;
|
||||
} else {
|
||||
|
@ -84,7 +84,7 @@ int32_t tsdbSnapRAWReaderClose(STsdbSnapRAWReader** reader) {
|
|||
STsdb* tsdb = reader[0]->tsdb;
|
||||
|
||||
TARRAY2_DESTROY(reader[0]->dataReaderArr, tsdbDataFileRAWReaderClose);
|
||||
(void)tsdbFSDestroyRefSnapshot(&reader[0]->fsetArr);
|
||||
tsdbFSDestroyRefSnapshot(&reader[0]->fsetArr);
|
||||
taosMemoryFree(reader[0]);
|
||||
reader[0] = NULL;
|
||||
|
||||
|
@ -141,15 +141,14 @@ static int32_t tsdbSnapRAWReadFileSetOpenReader(STsdbSnapRAWReader* reader) {
|
|||
|
||||
_exit:
|
||||
if (code) {
|
||||
(void)tsdbSnapRAWReadFileSetCloseReader(reader);
|
||||
tsdbSnapRAWReadFileSetCloseReader(reader);
|
||||
TSDB_ERROR_LOG(TD_VID(reader->tsdb->pVnode), code, lino);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t tsdbSnapRAWReadFileSetCloseReader(STsdbSnapRAWReader* reader) {
|
||||
static void tsdbSnapRAWReadFileSetCloseReader(STsdbSnapRAWReader* reader) {
|
||||
TARRAY2_CLEAR(reader->dataReaderArr, tsdbDataFileRAWReaderClose);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t tsdbSnapRAWReadFileSetOpenIter(STsdbSnapRAWReader* reader) {
|
||||
|
@ -158,10 +157,9 @@ static int32_t tsdbSnapRAWReadFileSetOpenIter(STsdbSnapRAWReader* reader) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int32_t tsdbSnapRAWReadFileSetCloseIter(STsdbSnapRAWReader* reader) {
|
||||
static void tsdbSnapRAWReadFileSetCloseIter(STsdbSnapRAWReader* reader) {
|
||||
reader->dataIter->count = 0;
|
||||
reader->dataIter->idx = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int64_t tsdbSnapRAWReadPeek(SDataFileRAWReader* reader) {
|
||||
|
@ -261,8 +259,8 @@ _exit:
|
|||
}
|
||||
|
||||
static int32_t tsdbSnapRAWReadEnd(STsdbSnapRAWReader* reader) {
|
||||
(void)tsdbSnapRAWReadFileSetCloseIter(reader);
|
||||
(void)tsdbSnapRAWReadFileSetCloseReader(reader);
|
||||
tsdbSnapRAWReadFileSetCloseIter(reader);
|
||||
tsdbSnapRAWReadFileSetCloseReader(reader);
|
||||
reader->ctx->fset = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
@ -411,7 +409,9 @@ static int32_t tsdbSnapRAWWriteFileSetBegin(STsdbSnapRAWWriter* writer, int32_t
|
|||
int32_t level = tsdbFidLevel(fid, &writer->tsdb->keepCfg, taosGetTimestampSec());
|
||||
code = tfsAllocDisk(writer->tsdb->pVnode->pTfs, level, &writer->ctx->did);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
(void)tfsMkdirRecurAt(writer->tsdb->pVnode->pTfs, writer->tsdb->path, writer->ctx->did);
|
||||
|
||||
code = tfsMkdirRecurAt(writer->tsdb->pVnode->pTfs, writer->tsdb->path, writer->ctx->did);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
code = tsdbSnapRAWWriteFileSetOpenWriter(writer);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
@ -490,7 +490,7 @@ int32_t tsdbSnapRAWWriterClose(STsdbSnapRAWWriter** writer, int8_t rollback) {
|
|||
}
|
||||
|
||||
TARRAY2_DESTROY(writer[0]->fopArr, NULL);
|
||||
(void)tsdbFSDestroyCopySnapshot(&writer[0]->fsetArr);
|
||||
tsdbFSDestroyCopySnapshot(&writer[0]->fsetArr);
|
||||
|
||||
taosMemoryFree(writer[0]);
|
||||
writer[0] = NULL;
|
||||
|
|
|
@ -590,11 +590,13 @@ static int32_t tsdbSttFileDoWriteStatisBlock(SSttFileWriter *writer) {
|
|||
statisBlk.cmprAlg = writer->config->cmprAlg;
|
||||
statisBlk.numOfPKs = statisBlock->numOfPKs;
|
||||
|
||||
(void)tStatisBlockGet(statisBlock, 0, &record);
|
||||
code = tStatisBlockGet(statisBlock, 0, &record);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
statisBlk.minTbid.suid = record.suid;
|
||||
statisBlk.minTbid.uid = record.uid;
|
||||
|
||||
(void)tStatisBlockGet(statisBlock, statisBlock->numOfRecords - 1, &record);
|
||||
code = tStatisBlockGet(statisBlock, statisBlock->numOfRecords - 1, &record);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
statisBlk.maxTbid.suid = record.suid;
|
||||
statisBlk.maxTbid.uid = record.uid;
|
||||
|
||||
|
|
|
@ -356,7 +356,7 @@ static int32_t tsdbUpgradeFileSet(STsdb *tsdb, SDFileSet *pDFileSet, TFileSetArr
|
|||
TAOS_CHECK_GOTO(tsdbUpgradeStt(tsdb, pDFileSet, reader, fset), &lino, _exit);
|
||||
}
|
||||
|
||||
(void)tsdbDataFReaderClose(&reader);
|
||||
tsdbDataFReaderClose(&reader);
|
||||
|
||||
TAOS_CHECK_GOTO(TARRAY2_APPEND(fileSetArray, fset), &lino, _exit);
|
||||
|
||||
|
@ -568,7 +568,7 @@ _exit:
|
|||
if (code) {
|
||||
tsdbError("vgId:%d %s failed at %s:%d since %s", TD_VID(tsdb->pVnode), __func__, __FILE__, lino, tstrerror(code));
|
||||
}
|
||||
(void)tsdbDelFReaderClose(&reader);
|
||||
tsdbDelFReaderClose(&reader);
|
||||
taosArrayDestroy(aDelIdx);
|
||||
return code;
|
||||
}
|
||||
|
|
|
@ -106,7 +106,7 @@ _exit:
|
|||
#endif
|
||||
|
||||
void tMapDataGetItemByIdx(SMapData *pMapData, int32_t idx, void *pItem, int32_t (*tGetItemFn)(uint8_t *, void *)) {
|
||||
(void)tGetItemFn(pMapData->pData + pMapData->aOffset[idx], pItem);
|
||||
TAOS_UNUSED(tGetItemFn(pMapData->pData + pMapData->aOffset[idx], pItem));
|
||||
}
|
||||
|
||||
#ifdef BUILD_NO_CALL
|
||||
|
|
|
@ -181,15 +181,15 @@ int vnodeSaveInfo(const char *dir, const SVnodeInfo *pInfo) {
|
|||
// save info to a vnode_tmp.json
|
||||
pFile = taosOpenFile(fname, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC | TD_FILE_WRITE_THROUGH);
|
||||
if (pFile == NULL) {
|
||||
TSDB_CHECK_CODE(code = TAOS_SYSTEM_ERROR(errno), lino, _exit);
|
||||
TSDB_CHECK_CODE(code = terrno, lino, _exit);
|
||||
}
|
||||
|
||||
if (taosWriteFile(pFile, data, strlen(data)) < 0) {
|
||||
TSDB_CHECK_CODE(code = TAOS_SYSTEM_ERROR(errno), lino, _exit);
|
||||
TSDB_CHECK_CODE(code = terrno, lino, _exit);
|
||||
}
|
||||
|
||||
if (taosFsyncFile(pFile) < 0) {
|
||||
TSDB_CHECK_CODE(code = TAOS_SYSTEM_ERROR(errno), lino, _exit);
|
||||
TSDB_CHECK_CODE(code = terrno, lino, _exit);
|
||||
}
|
||||
|
||||
_exit:
|
||||
|
@ -211,8 +211,9 @@ int vnodeCommitInfo(const char *dir) {
|
|||
snprintf(fname, TSDB_FILENAME_LEN, "%s%s%s", dir, TD_DIRSEP, VND_INFO_FNAME);
|
||||
snprintf(tfname, TSDB_FILENAME_LEN, "%s%s%s", dir, TD_DIRSEP, VND_INFO_FNAME_TMP);
|
||||
|
||||
if (taosRenameFile(tfname, fname) < 0) {
|
||||
return terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
int32_t code = taosRenameFile(tfname, fname);
|
||||
if (code < 0) {
|
||||
return code;
|
||||
}
|
||||
|
||||
vInfo("vnode info is committed, dir:%s", dir);
|
||||
|
@ -232,12 +233,11 @@ int vnodeLoadInfo(const char *dir, SVnodeInfo *pInfo) {
|
|||
// read info
|
||||
pFile = taosOpenFile(fname, TD_FILE_READ);
|
||||
if (pFile == NULL) {
|
||||
TSDB_CHECK_CODE(code = TAOS_SYSTEM_ERROR(errno), lino, _exit);
|
||||
TSDB_CHECK_CODE(code = terrno, lino, _exit);
|
||||
}
|
||||
|
||||
if (taosFStatFile(pFile, &size, NULL) < 0) {
|
||||
TSDB_CHECK_CODE(code = TAOS_SYSTEM_ERROR(errno), lino, _exit);
|
||||
}
|
||||
code = taosFStatFile(pFile, &size, NULL);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
pData = taosMemoryMalloc(size + 1);
|
||||
if (pData == NULL) {
|
||||
|
@ -245,7 +245,7 @@ int vnodeLoadInfo(const char *dir, SVnodeInfo *pInfo) {
|
|||
}
|
||||
|
||||
if (taosReadFile(pFile, pData, size) < 0) {
|
||||
TSDB_CHECK_CODE(code = TAOS_SYSTEM_ERROR(errno), lino, _exit);
|
||||
TSDB_CHECK_CODE(code = terrno, lino, _exit);
|
||||
}
|
||||
|
||||
pData[size] = '\0';
|
||||
|
|
|
@ -267,14 +267,15 @@ int32_t vnodeSnapRead(SVSnapReader *pReader, uint8_t **ppData, uint32_t *nData)
|
|||
|
||||
TdFilePtr pFile = taosOpenFile(fName, TD_FILE_READ);
|
||||
if (NULL == pFile) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
|
||||
int64_t size;
|
||||
if (taosFStatFile(pFile, &size, NULL) < 0) {
|
||||
code = taosFStatFile(pFile, &size, NULL);
|
||||
if (code != 0) {
|
||||
(void)taosCloseFile(&pFile);
|
||||
TSDB_CHECK_CODE(code = TAOS_SYSTEM_ERROR(errno), lino, _exit);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
|
||||
*ppData = taosMemoryMalloc(sizeof(SSnapDataHdr) + size + 1);
|
||||
|
@ -289,7 +290,7 @@ int32_t vnodeSnapRead(SVSnapReader *pReader, uint8_t **ppData, uint32_t *nData)
|
|||
if (taosReadFile(pFile, ((SSnapDataHdr *)(*ppData))->data, size) < 0) {
|
||||
taosMemoryFree(*ppData);
|
||||
(void)taosCloseFile(&pFile);
|
||||
TSDB_CHECK_CODE(code = TAOS_SYSTEM_ERROR(errno), lino, _exit);
|
||||
TSDB_CHECK_CODE(code = terrno, lino, _exit);
|
||||
}
|
||||
|
||||
(void)taosCloseFile(&pFile);
|
||||
|
|
|
@ -344,27 +344,18 @@ static const char* encryptAlgorithmStr(int8_t encryptAlgorithm) {
|
|||
return TSDB_CACHE_MODEL_NONE_STR;
|
||||
}
|
||||
|
||||
static int32_t formatDurationOrKeep(char** buffer, int32_t timeInMinutes) {
|
||||
int len = 0;
|
||||
int32_t formatDurationOrKeep(char* buffer, int32_t timeInMinutes) {
|
||||
int32_t len = 0;
|
||||
if (timeInMinutes % 1440 == 0) {
|
||||
int days = timeInMinutes / 1440;
|
||||
len = snprintf(NULL, 0, "%dd", days);
|
||||
*buffer = (char*)taosMemoryCalloc(len + 1, sizeof(char));
|
||||
if(*buffer == NULL) return terrno;
|
||||
sprintf(*buffer, "%dd", days);
|
||||
int32_t days = timeInMinutes / 1440;
|
||||
len = sprintf(buffer, "%dd", days);
|
||||
} else if (timeInMinutes % 60 == 0) {
|
||||
int hours = timeInMinutes / 60;
|
||||
len = snprintf(NULL, 0, "%dh", hours);
|
||||
*buffer = (char*)taosMemoryCalloc(len + 1, sizeof(char));
|
||||
if(*buffer == NULL) return terrno;
|
||||
sprintf(*buffer, "%dh", hours);
|
||||
int32_t hours = timeInMinutes / 60;
|
||||
len = sprintf(buffer, "%dh", hours);
|
||||
} else {
|
||||
len = snprintf(NULL, 0, "%dm", timeInMinutes);
|
||||
*buffer = (char*)taosMemoryCalloc(len + 1, sizeof(char));
|
||||
if(*buffer == NULL) return terrno;
|
||||
sprintf(*buffer, "%dm", timeInMinutes);
|
||||
len = sprintf(buffer, "%dm", timeInMinutes);
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
return len;
|
||||
}
|
||||
|
||||
static int32_t setCreateDBResultIntoDataBlock(SSDataBlock* pBlock, char* dbName, char* dbFName, SDbCfgInfo* pCfg) {
|
||||
|
@ -404,25 +395,16 @@ static int32_t setCreateDBResultIntoDataBlock(SSDataBlock* pBlock, char* dbName,
|
|||
} else if (pCfg->hashPrefix < 0) {
|
||||
hashPrefix = pCfg->hashPrefix + dbFNameLen + 1;
|
||||
}
|
||||
char* durationStr = NULL;
|
||||
char* keep0Str = NULL;
|
||||
char* keep1Str = NULL;
|
||||
char* keep2Str = NULL;
|
||||
int32_t codeDuration = formatDurationOrKeep(&durationStr, pCfg->daysPerFile);
|
||||
int32_t codeKeep0 = formatDurationOrKeep(&keep0Str, pCfg->daysToKeep0);
|
||||
int32_t codeKeep1 = formatDurationOrKeep(&keep1Str, pCfg->daysToKeep1);
|
||||
int32_t codeKeep2 = formatDurationOrKeep(&keep2Str, pCfg->daysToKeep2);
|
||||
if(codeDuration != TSDB_CODE_SUCCESS || codeKeep0 != TSDB_CODE_SUCCESS || codeKeep1 != TSDB_CODE_SUCCESS || codeKeep2 != TSDB_CODE_SUCCESS) {
|
||||
int32_t firstErrorCode = codeDuration != TSDB_CODE_SUCCESS ? codeDuration :
|
||||
codeKeep0 != TSDB_CODE_SUCCESS ? codeKeep0 :
|
||||
codeKeep1 != TSDB_CODE_SUCCESS ? codeKeep1 : codeKeep2;
|
||||
taosMemoryFree(pRetentions);
|
||||
taosMemoryFree(durationStr);
|
||||
taosMemoryFree(keep0Str);
|
||||
taosMemoryFree(keep1Str);
|
||||
taosMemoryFree(keep2Str);
|
||||
return firstErrorCode;
|
||||
}
|
||||
char durationStr[128] = {0};
|
||||
char keep0Str[128] = {0};
|
||||
char keep1Str[128] = {0};
|
||||
char keep2Str[128] = {0};
|
||||
|
||||
int32_t lenDuration = formatDurationOrKeep(durationStr, pCfg->daysPerFile);
|
||||
int32_t lenKeep0 = formatDurationOrKeep(keep0Str, pCfg->daysToKeep0);
|
||||
int32_t lenKeep1 = formatDurationOrKeep(keep1Str, pCfg->daysToKeep1);
|
||||
int32_t lenKeep2 = formatDurationOrKeep(keep2Str, pCfg->daysToKeep2);
|
||||
|
||||
if (IS_SYS_DBNAME(dbName)) {
|
||||
len += sprintf(buf2 + VARSTR_HEADER_SIZE, "CREATE DATABASE `%s`", dbName);
|
||||
} else {
|
||||
|
@ -449,10 +431,6 @@ static int32_t setCreateDBResultIntoDataBlock(SSDataBlock* pBlock, char* dbName,
|
|||
}
|
||||
|
||||
taosMemoryFree(pRetentions);
|
||||
taosMemoryFree(durationStr);
|
||||
taosMemoryFree(keep0Str);
|
||||
taosMemoryFree(keep1Str);
|
||||
taosMemoryFree(keep2Str);
|
||||
|
||||
(varDataLen(buf2)) = len;
|
||||
|
||||
|
|
|
@ -528,6 +528,7 @@ static void seqJoinLaunchNewRetrieveImpl(SOperatorInfo* pOperator, SSDataBlock**
|
|||
qDebug("%s dynamic post task begin", GET_TASKID(pOperator->pTaskInfo));
|
||||
code = pOperator->pDownstream[1]->fpSet.getNextExtFn(pOperator->pDownstream[1], pParam, ppRes);
|
||||
if (*ppRes && (code == 0)) {
|
||||
blockDataCheck(*ppRes, false);
|
||||
pPost->isStarted = true;
|
||||
pStbJoin->execInfo.postBlkNum++;
|
||||
pStbJoin->execInfo.postBlkRows += (*ppRes)->info.rows;
|
||||
|
|
|
@ -692,8 +692,10 @@ int32_t qExecTaskOpt(qTaskInfo_t tinfo, SArray* pResList, uint64_t* useconds, bo
|
|||
if (pTaskInfo->pOpParam && !pTaskInfo->paramSet) {
|
||||
pTaskInfo->paramSet = true;
|
||||
code = pTaskInfo->pRoot->fpSet.getNextExtFn(pTaskInfo->pRoot, pTaskInfo->pOpParam, &pRes);
|
||||
blockDataCheck(pRes, false);
|
||||
} else {
|
||||
code = pTaskInfo->pRoot->fpSet.getNextFn(pTaskInfo->pRoot, &pRes);
|
||||
blockDataCheck(pRes, false);
|
||||
}
|
||||
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
|
@ -740,6 +742,7 @@ int32_t qExecTaskOpt(qTaskInfo_t tinfo, SArray* pResList, uint64_t* useconds, bo
|
|||
}
|
||||
|
||||
code = pTaskInfo->pRoot->fpSet.getNextFn(pTaskInfo->pRoot, &pRes);
|
||||
blockDataCheck(pRes, false);
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
}
|
||||
|
||||
|
@ -839,6 +842,8 @@ int32_t qExecTask(qTaskInfo_t tinfo, SSDataBlock** pRes, uint64_t* useconds) {
|
|||
qError("%s failed at line %d, code:%s %s", __func__, lino, tstrerror(code), GET_TASKID(pTaskInfo));
|
||||
}
|
||||
|
||||
blockDataCheck(*pRes, false);
|
||||
|
||||
uint64_t el = (taosGetTimestampUs() - st);
|
||||
|
||||
pTaskInfo->cost.elapsedTime += el;
|
||||
|
|
|
@ -617,6 +617,8 @@ int32_t doFilter(SSDataBlock* pBlock, SFilterInfo* pFilterInfo, SColMatchInfo* p
|
|||
code = TSDB_CODE_SUCCESS;
|
||||
|
||||
_err:
|
||||
blockDataCheck(pBlock, true);
|
||||
|
||||
colDataDestroy(p);
|
||||
taosMemoryFree(p);
|
||||
return code;
|
||||
|
@ -1010,6 +1012,10 @@ static void destroySqlFunctionCtx(SqlFunctionCtx* pCtx, SExprInfo* pExpr, int32_
|
|||
}
|
||||
|
||||
for (int32_t i = 0; i < numOfOutput; ++i) {
|
||||
if (pCtx[i].fpSet.cleanup != NULL) {
|
||||
pCtx[i].fpSet.cleanup(&pCtx[i]);
|
||||
}
|
||||
|
||||
if (pExpr != NULL) {
|
||||
SExprInfo* pExprInfo = &pExpr[i];
|
||||
for (int32_t j = 0; j < pExprInfo->base.numOfParams; ++j) {
|
||||
|
|
|
@ -204,7 +204,7 @@ static FORCE_INLINE int32_t initOpenCacheFile(SGroupCacheFileFd* pFileFd, char*
|
|||
TdFilePtr newFd = taosOpenFile(filename, TD_FILE_CREATE|TD_FILE_READ|TD_FILE_WRITE|TD_FILE_AUTO_DEL);
|
||||
//TdFilePtr newFd = taosOpenFile(filename, TD_FILE_CREATE|TD_FILE_READ|TD_FILE_WRITE);
|
||||
if (NULL == newFd) {
|
||||
QRY_ERR_RET(TAOS_SYSTEM_ERROR(errno));
|
||||
QRY_ERR_RET(terrno);
|
||||
}
|
||||
pFileFd->fd = newFd;
|
||||
int32_t code = taosThreadMutexInit(&pFileFd->mutex, NULL);
|
||||
|
@ -315,16 +315,16 @@ static int32_t saveBlocksToDisk(SGroupCacheOperatorInfo* pGCache, SGcDownstreamC
|
|||
}
|
||||
|
||||
int32_t ret = taosLSeekFile(pFd->fd, pHead->basic.offset, SEEK_SET);
|
||||
if (ret == -1) {
|
||||
if (ret < 0) {
|
||||
releaseFdToFileCtx(pFd);
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
goto _return;
|
||||
}
|
||||
|
||||
ret = (int32_t)taosWriteFile(pFd->fd, pHead->pBuf, pHead->basic.bufSize);
|
||||
if (ret != pHead->basic.bufSize) {
|
||||
releaseFdToFileCtx(pFd);
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
goto _return;
|
||||
}
|
||||
|
||||
|
@ -548,8 +548,8 @@ static int32_t readBlockFromDisk(SGroupCacheOperatorInfo* pGCache, SGroupCacheDa
|
|||
}
|
||||
|
||||
int32_t ret = taosLSeekFile(pFileFd->fd, pBasic->offset, SEEK_SET);
|
||||
if (ret == -1) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
if (ret < 0) {
|
||||
code = terrno;
|
||||
goto _return;
|
||||
}
|
||||
|
||||
|
@ -562,7 +562,7 @@ static int32_t readBlockFromDisk(SGroupCacheOperatorInfo* pGCache, SGroupCacheDa
|
|||
ret = (int32_t)taosReadFile(pFileFd->fd, *ppBuf, pBasic->bufSize);
|
||||
if (ret != pBasic->bufSize) {
|
||||
taosMemoryFreeClear(*ppBuf);
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
goto _return;
|
||||
}
|
||||
|
||||
|
@ -733,6 +733,8 @@ static FORCE_INLINE int32_t getBlkFromDownstreamOperator(struct SOperatorInfo* p
|
|||
}
|
||||
}
|
||||
|
||||
blockDataCheck(pBlock, false);
|
||||
|
||||
*ppRes = pBlock;
|
||||
return code;
|
||||
}
|
||||
|
|
|
@ -474,8 +474,11 @@ int32_t mJoinCopyMergeMidBlk(SMJoinMergeCtx* pCtx, SSDataBlock** ppMid, SSDataBl
|
|||
pCtx->midRemains = false;
|
||||
} else {
|
||||
int32_t copyRows = pMore->info.capacity - pMore->info.rows;
|
||||
MJ_ERR_RET(blockDataMergeNRows(pMore, pLess, pLess->info.rows - copyRows, copyRows));
|
||||
blockDataShrinkNRows(pLess, copyRows);
|
||||
if (copyRows > 0) {
|
||||
MJ_ERR_RET(blockDataMergeNRows(pMore, pLess, pLess->info.rows - copyRows, copyRows));
|
||||
blockDataShrinkNRows(pLess, copyRows);
|
||||
}
|
||||
|
||||
pCtx->midRemains = true;
|
||||
}
|
||||
|
||||
|
@ -1742,6 +1745,7 @@ int32_t mJoinMainProcess(struct SOperatorInfo* pOperator, SSDataBlock** pResBloc
|
|||
if (pBlock && pBlock->info.rows > 0) {
|
||||
*pResBlock = pBlock;
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
|
|
|
@ -66,6 +66,7 @@ static int32_t sortMergeloadNextDataBlock(void* param, SSDataBlock** ppBlock);
|
|||
int32_t sortMergeloadNextDataBlock(void* param, SSDataBlock** ppBlock) {
|
||||
SOperatorInfo* pOperator = (SOperatorInfo*)param;
|
||||
int32_t code = pOperator->fpSet.getNextFn(pOperator, ppBlock);
|
||||
blockDataCheck(*ppBlock, false);
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -524,6 +525,7 @@ int32_t doMultiwayMerge(SOperatorInfo* pOperator, SSDataBlock** pResBlock) {
|
|||
|
||||
if ((*pResBlock) != NULL) {
|
||||
pOperator->resultInfo.totalRows += (*pResBlock)->info.rows;
|
||||
blockDataCheck(*pResBlock, false);
|
||||
} else {
|
||||
setOperatorCompleted(pOperator);
|
||||
}
|
||||
|
|
|
@ -659,10 +659,6 @@ void destroyOperator(SOperatorInfo* pOperator) {
|
|||
freeResetOperatorParams(pOperator, OP_GET_PARAM, true);
|
||||
freeResetOperatorParams(pOperator, OP_NOTIFY_PARAM, true);
|
||||
|
||||
if (pOperator->fpSet.closeFn != NULL && pOperator->info != NULL) {
|
||||
pOperator->fpSet.closeFn(pOperator->info);
|
||||
}
|
||||
|
||||
if (pOperator->pDownstream != NULL) {
|
||||
for (int32_t i = 0; i < pOperator->numOfRealDownstream; ++i) {
|
||||
destroyOperator(pOperator->pDownstream[i]);
|
||||
|
@ -673,6 +669,12 @@ void destroyOperator(SOperatorInfo* pOperator) {
|
|||
}
|
||||
|
||||
cleanupExprSupp(&pOperator->exprSupp);
|
||||
|
||||
// close operator after cleanup exprSupp, since we need to call cleanup of sqlFunctionCtx first to avoid mem leak.
|
||||
if (pOperator->fpSet.closeFn != NULL && pOperator->info != NULL) {
|
||||
pOperator->fpSet.closeFn(pOperator->info);
|
||||
}
|
||||
|
||||
taosMemoryFreeClear(pOperator);
|
||||
}
|
||||
|
||||
|
@ -868,12 +870,14 @@ int32_t setOperatorParams(struct SOperatorInfo* pOperator, SOperatorParam* pInpu
|
|||
SSDataBlock* getNextBlockFromDownstream(struct SOperatorInfo* pOperator, int32_t idx) {
|
||||
SSDataBlock* p = NULL;
|
||||
int32_t code = getNextBlockFromDownstreamImpl(pOperator, idx, true, &p);
|
||||
blockDataCheck(p, false);
|
||||
return (code == 0)? p:NULL;
|
||||
}
|
||||
|
||||
SSDataBlock* getNextBlockFromDownstreamRemain(struct SOperatorInfo* pOperator, int32_t idx) {
|
||||
SSDataBlock* p = NULL;
|
||||
int32_t code = getNextBlockFromDownstreamImpl(pOperator, idx, false, &p);
|
||||
blockDataCheck(p, false);
|
||||
return (code == 0)? p:NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ static void switchCtxOrder(SqlFunctionCtx* pCtx, int32_t numOfOutput) {
|
|||
}
|
||||
|
||||
static int32_t overlapWithTimeWindow(SInterval* pInterval, SDataBlockInfo* pBlockInfo, int32_t order, bool* overlap) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
STimeWindow w = {0};
|
||||
|
||||
// 0 by default, which means it is not a interval operator of the upstream operator.
|
||||
|
@ -101,7 +101,7 @@ static int32_t overlapWithTimeWindow(SInterval* pInterval, SDataBlockInfo* pBloc
|
|||
|
||||
if (order == TSDB_ORDER_ASC) {
|
||||
w = getAlignQueryTimeWindow(pInterval, pBlockInfo->window.skey);
|
||||
if(w.ekey < pBlockInfo->window.skey) {
|
||||
if (w.ekey < pBlockInfo->window.skey) {
|
||||
qError("w.ekey:%" PRId64 " < pBlockInfo->window.skey:%" PRId64, w.ekey, pBlockInfo->window.skey);
|
||||
return TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR;
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ static int32_t overlapWithTimeWindow(SInterval* pInterval, SDataBlockInfo* pBloc
|
|||
break;
|
||||
}
|
||||
|
||||
if(w.ekey <= pBlockInfo->window.ekey) {
|
||||
if (w.ekey <= pBlockInfo->window.ekey) {
|
||||
qError("w.ekey:%" PRId64 " <= pBlockInfo->window.ekey:%" PRId64, w.ekey, pBlockInfo->window.ekey);
|
||||
return TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR;
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ static int32_t overlapWithTimeWindow(SInterval* pInterval, SDataBlockInfo* pBloc
|
|||
}
|
||||
} else {
|
||||
w = getAlignQueryTimeWindow(pInterval, pBlockInfo->window.ekey);
|
||||
if(w.skey > pBlockInfo->window.ekey) {
|
||||
if (w.skey > pBlockInfo->window.ekey) {
|
||||
qError("w.skey:%" PRId64 " > pBlockInfo->window.skey:%" PRId64, w.skey, pBlockInfo->window.ekey);
|
||||
return TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR;
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ static int32_t overlapWithTimeWindow(SInterval* pInterval, SDataBlockInfo* pBloc
|
|||
break;
|
||||
}
|
||||
|
||||
if(w.skey >= pBlockInfo->window.skey){
|
||||
if (w.skey >= pBlockInfo->window.skey) {
|
||||
qError("w.skey:%" PRId64 " >= pBlockInfo->window.skey:%" PRId64, w.skey, pBlockInfo->window.skey);
|
||||
return TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR;
|
||||
}
|
||||
|
@ -227,7 +227,7 @@ static int32_t doDynamicPruneDataBlock(SOperatorInfo* pOperator, SDataBlockInfo*
|
|||
|
||||
SResultRowEntryInfo* pEntry = getResultEntryInfo(pRow, i, pTableScanInfo->base.pdInfo.pExprSup->rowEntryInfoOffset);
|
||||
|
||||
EFuncDataRequired reqStatus = fmFuncDynDataRequired(functionId, pEntry, pBlockInfo);
|
||||
EFuncDataRequired reqStatus = fmFuncDynDataRequired(functionId, pEntry, pBlockInfo);
|
||||
if (reqStatus != FUNC_DATA_REQUIRED_NOT_LOAD) {
|
||||
notLoadBlock = false;
|
||||
break;
|
||||
|
@ -399,7 +399,7 @@ static int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanBase* pTableSca
|
|||
}
|
||||
}
|
||||
|
||||
if(*status != FUNC_DATA_REQUIRED_DATA_LOAD) {
|
||||
if (*status != FUNC_DATA_REQUIRED_DATA_LOAD) {
|
||||
pAPI->tsdReader.tsdReaderReleaseDataBlock(pTableScanInfo->dataReader);
|
||||
qError("%s loadDataBlock invalid status:%d", GET_TASKID(pTaskInfo), *status);
|
||||
return TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR;
|
||||
|
@ -588,14 +588,14 @@ static void freeTableCachedValObj(STableCachedVal* pVal) {
|
|||
|
||||
int32_t addTagPseudoColumnData(SReadHandle* pHandle, const SExprInfo* pExpr, int32_t numOfExpr, SSDataBlock* pBlock,
|
||||
int32_t rows, SExecTaskInfo* pTask, STableMetaCacheInfo* pCache) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
int32_t lino = 0;
|
||||
bool freeReader = false;
|
||||
LRUHandle* h = NULL;
|
||||
STableCachedVal val = {0};
|
||||
SMetaReader mr = {0};
|
||||
const char* idStr = pTask->id.str;
|
||||
int32_t insertRet = TAOS_LRU_STATUS_OK;
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
int32_t lino = 0;
|
||||
bool freeReader = false;
|
||||
LRUHandle* h = NULL;
|
||||
STableCachedVal val = {0};
|
||||
SMetaReader mr = {0};
|
||||
const char* idStr = pTask->id.str;
|
||||
int32_t insertRet = TAOS_LRU_STATUS_OK;
|
||||
STableCachedVal* pVal = NULL;
|
||||
|
||||
// currently only the tbname pseudo column
|
||||
|
@ -625,8 +625,7 @@ int32_t addTagPseudoColumnData(SReadHandle* pHandle, const SExprInfo* pExpr, int
|
|||
// append null value before return to caller, since the caller will ignore this error code and proceed
|
||||
doSetNullValue(pBlock, pExpr, numOfExpr);
|
||||
} else {
|
||||
qError("failed to get table meta, uid:0x%" PRIx64 ", code:%s, %s", pBlock->info.id.uid, tstrerror(code),
|
||||
idStr);
|
||||
qError("failed to get table meta, uid:0x%" PRIx64 ", code:%s, %s", pBlock->info.id.uid, tstrerror(code), idStr);
|
||||
}
|
||||
pHandle->api.metaReaderFn.clearReader(&mr);
|
||||
return code;
|
||||
|
@ -743,7 +742,7 @@ _end:
|
|||
|
||||
if (NULL != pVal) {
|
||||
insertRet = taosLRUCacheInsert(pCache->pTableMetaEntryCache, &pBlock->info.id.uid, sizeof(uint64_t), pVal,
|
||||
sizeof(STableCachedVal), freeCachedMetaItem, NULL, TAOS_LRU_PRIORITY_LOW, NULL);
|
||||
sizeof(STableCachedVal), freeCachedMetaItem, NULL, TAOS_LRU_PRIORITY_LOW, NULL);
|
||||
if (insertRet != TAOS_LRU_STATUS_OK) {
|
||||
qWarn("failed to put meta into lru cache, code:%d, %s", insertRet, idStr);
|
||||
}
|
||||
|
@ -1241,6 +1240,29 @@ _end:
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t doInitReader(STableScanInfo* pInfo, SExecTaskInfo* pTaskInfo, SStorageAPI* pAPI, int32_t* pNum,
|
||||
STableKeyInfo** pList) {
|
||||
const char* idStr = GET_TASKID(pTaskInfo);
|
||||
int32_t code = initNextGroupScan(pInfo, pList, pNum);
|
||||
if (code) {
|
||||
qError("%s failed to init groupScan Info, code:%s at line:%d", idStr, tstrerror(code), __LINE__);
|
||||
return code;
|
||||
}
|
||||
|
||||
if (pInfo->base.dataReader != NULL) {
|
||||
qError("%s tsdb reader should be null", idStr);
|
||||
return TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
code = pAPI->tsdReader.tsdReaderOpen(pInfo->base.readHandle.vnode, &pInfo->base.cond, *pList, *pNum, pInfo->pResBlock,
|
||||
(void**)&pInfo->base.dataReader, idStr, &pInfo->pIgnoreTables);
|
||||
if (code) {
|
||||
qError("%s failed to open tsdbReader, code:%s at line:%d", idStr, tstrerror(code), __LINE__);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t groupSeqTableScan(SOperatorInfo* pOperator, SSDataBlock** pResBlock) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
int32_t lino = 0;
|
||||
|
@ -1250,6 +1272,7 @@ static int32_t groupSeqTableScan(SOperatorInfo* pOperator, SSDataBlock** pResBlo
|
|||
int32_t num = 0;
|
||||
STableKeyInfo* pList = NULL;
|
||||
SSDataBlock* pResult = NULL;
|
||||
const char* idStr = GET_TASKID(pTaskInfo);
|
||||
|
||||
QRY_PARAM_CHECK(pResBlock);
|
||||
|
||||
|
@ -1260,17 +1283,10 @@ static int32_t groupSeqTableScan(SOperatorInfo* pOperator, SSDataBlock** pResBlo
|
|||
}
|
||||
|
||||
taosRLockLatch(&pTaskInfo->lock);
|
||||
code = initNextGroupScan(pInfo, &pList, &num);
|
||||
|
||||
code = doInitReader(pInfo, pTaskInfo, pAPI, &num, &pList);
|
||||
taosRUnLockLatch(&pTaskInfo->lock);
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
|
||||
QUERY_CHECK_CONDITION((pInfo->base.dataReader == NULL), code, lino, _end, TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR);
|
||||
|
||||
code = pAPI->tsdReader.tsdReaderOpen(pInfo->base.readHandle.vnode, &pInfo->base.cond, pList, num, pInfo->pResBlock,
|
||||
(void**)&pInfo->base.dataReader, GET_TASKID(pTaskInfo), &pInfo->pIgnoreTables);
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
|
||||
if (pInfo->filesetDelimited) {
|
||||
pAPI->tsdReader.tsdSetFilesetDelimited(pInfo->base.dataReader);
|
||||
}
|
||||
|
@ -1280,7 +1296,6 @@ static int32_t groupSeqTableScan(SOperatorInfo* pOperator, SSDataBlock** pResBlo
|
|||
}
|
||||
}
|
||||
|
||||
pResult = NULL;
|
||||
code = doGroupedTableScan(pOperator, &pResult);
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
|
||||
|
@ -1305,7 +1320,7 @@ static int32_t groupSeqTableScan(SOperatorInfo* pOperator, SSDataBlock** pResBlo
|
|||
|
||||
_end:
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
qError("%s failed at line %d since %s", __func__, lino, tstrerror(code));
|
||||
qError("%s %s failed at line %d since %s", idStr, __func__, lino, tstrerror(code));
|
||||
pTaskInfo->code = code;
|
||||
}
|
||||
|
||||
|
@ -1416,7 +1431,7 @@ static int32_t getTableScannerExecInfo(struct SOperatorInfo* pOptr, void** pOptr
|
|||
if (!pRecorder) {
|
||||
return terrno;
|
||||
}
|
||||
STableScanInfo* pTableScanInfo = pOptr->info;
|
||||
STableScanInfo* pTableScanInfo = pOptr->info;
|
||||
*pRecorder = pTableScanInfo->base.readRecorder;
|
||||
*pOptrExplain = pRecorder;
|
||||
*len = sizeof(SFileBlockLoadRecorder);
|
||||
|
@ -1499,7 +1514,7 @@ int32_t createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode, SReadHa
|
|||
initResultSizeInfo(&pOperator->resultInfo, 4096);
|
||||
pInfo->pResBlock = createDataBlockFromDescNode(pDescNode);
|
||||
QUERY_CHECK_NULL(pInfo->pResBlock, code, lino, _error, terrno);
|
||||
|
||||
|
||||
code = prepareDataBlockBuf(pInfo->pResBlock, &pInfo->base.matchInfo);
|
||||
QUERY_CHECK_CODE(code, lino, _error);
|
||||
|
||||
|
@ -1538,7 +1553,7 @@ int32_t createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode, SReadHa
|
|||
|
||||
_error:
|
||||
if (pInfo != NULL) {
|
||||
pInfo->base.pTableListInfo = NULL; // this attribute will be destroy outside of this function
|
||||
pInfo->base.pTableListInfo = NULL; // this attribute will be destroy outside of this function
|
||||
destroyTableScanOperatorInfo(pInfo);
|
||||
}
|
||||
|
||||
|
@ -1660,7 +1675,7 @@ static SSDataBlock* readPreVersionData(SOperatorInfo* pTableScanOp, uint64_t tbU
|
|||
SSDataBlock* pBlock = pTableScanInfo->pResBlock;
|
||||
STsdbReader* pReader = NULL;
|
||||
code = pAPI->tsdReader.tsdReaderOpen(pTableScanInfo->base.readHandle.vnode, &cond, &tblInfo, 1, pBlock,
|
||||
(void**)&pReader, GET_TASKID(pTaskInfo), NULL);
|
||||
(void**)&pReader, GET_TASKID(pTaskInfo), NULL);
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
|
||||
bool hasNext = false;
|
||||
|
@ -1813,7 +1828,7 @@ static void prepareRangeScan(SStreamScanInfo* pInfo, SSDataBlock* pBlock, int32_
|
|||
QUERY_CHECK_NULL(pInfo->pUpdateInfo, code, lino, _end, TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR);
|
||||
|
||||
qDebug("prepare range scan start:%" PRId64 ",end:%" PRId64 ",maxVer:%" PRIu64, win.skey, win.ekey,
|
||||
pInfo->pUpdateInfo->maxDataVersion);
|
||||
pInfo->pUpdateInfo->maxDataVersion);
|
||||
resetTableScanInfo(pInfo->pTableScanOp->info, &win, pInfo->pUpdateInfo->maxDataVersion);
|
||||
pInfo->pTableScanOp->status = OP_OPENED;
|
||||
if (pRes) {
|
||||
|
@ -2236,9 +2251,9 @@ static int32_t generateIntervalScanRange(SStreamScanInfo* pInfo, SSDataBlock* pS
|
|||
}
|
||||
|
||||
uint64_t* srcUidData = (uint64_t*)pSrcUidCol->pData;
|
||||
TSKEY* srcStartTsCol = (TSKEY*)pSrcStartTsCol->pData;
|
||||
TSKEY* srcEndTsCol = (TSKEY*)pSrcEndTsCol->pData;
|
||||
int64_t ver = pSrcBlock->info.version - 1;
|
||||
TSKEY* srcStartTsCol = (TSKEY*)pSrcStartTsCol->pData;
|
||||
TSKEY* srcEndTsCol = (TSKEY*)pSrcEndTsCol->pData;
|
||||
int64_t ver = pSrcBlock->info.version - 1;
|
||||
|
||||
if (pInfo->partitionSup.needCalc &&
|
||||
(srcStartTsCol[0] != srcEndTsCol[0] || (hasPrimaryKeyCol(pInfo) && mode == STREAM_DELETE_DATA))) {
|
||||
|
@ -2804,8 +2819,8 @@ static int32_t setBlockIntoRes(SStreamScanInfo* pInfo, const SSDataBlock* pBlock
|
|||
|
||||
// currently only the tbname pseudo column
|
||||
if (pInfo->numOfPseudoExpr > 0) {
|
||||
code = addTagPseudoColumnData(&pInfo->readHandle, pInfo->pPseudoExpr, pInfo->numOfPseudoExpr,
|
||||
pInfo->pRes, pBlockInfo->rows, pTaskInfo, &pTableScanInfo->base.metaCache);
|
||||
code = addTagPseudoColumnData(&pInfo->readHandle, pInfo->pPseudoExpr, pInfo->numOfPseudoExpr, pInfo->pRes,
|
||||
pBlockInfo->rows, pTaskInfo, &pTableScanInfo->base.metaCache);
|
||||
// ignore the table not exists error, since this table may have been dropped during the scan procedure.
|
||||
if (code == TSDB_CODE_PAR_TABLE_NOT_EXIST) {
|
||||
code = 0;
|
||||
|
@ -3182,7 +3197,7 @@ void streamScanOperatorDecode(void* pBuff, int32_t len, SStreamScanInfo* pInfo)
|
|||
return;
|
||||
}
|
||||
|
||||
void* pUpInfo = taosMemoryCalloc(1, sizeof(SUpdateInfo));
|
||||
void* pUpInfo = taosMemoryCalloc(1, sizeof(SUpdateInfo));
|
||||
if (!pUpInfo) {
|
||||
return;
|
||||
}
|
||||
|
@ -3471,7 +3486,8 @@ FETCH_NEXT_BLOCK:
|
|||
(*ppRes) = pInfo->pDeleteDataRes;
|
||||
return code;
|
||||
}
|
||||
qError("%s===stream=== %s failed at line %d since pInfo->pUpdateRes is empty", GET_TASKID(pTaskInfo), __func__, lino);
|
||||
qError("%s===stream=== %s failed at line %d since pInfo->pUpdateRes is empty", GET_TASKID(pTaskInfo), __func__,
|
||||
lino);
|
||||
blockDataCleanup(pInfo->pUpdateDataRes);
|
||||
pInfo->scanMode = STREAM_SCAN_FROM_READERHANDLE;
|
||||
} break;
|
||||
|
@ -3484,7 +3500,8 @@ FETCH_NEXT_BLOCK:
|
|||
(*ppRes) = pInfo->pUpdateRes;
|
||||
return code;
|
||||
}
|
||||
qError("%s===stream=== %s failed at line %d since pInfo->pUpdateRes is empty", GET_TASKID(pTaskInfo), __func__, lino);
|
||||
qError("%s===stream=== %s failed at line %d since pInfo->pUpdateRes is empty", GET_TASKID(pTaskInfo), __func__,
|
||||
lino);
|
||||
blockDataCleanup(pInfo->pUpdateDataRes);
|
||||
pInfo->scanMode = STREAM_SCAN_FROM_READERHANDLE;
|
||||
} break;
|
||||
|
@ -3671,7 +3688,7 @@ static int32_t extractTableIdList(const STableListInfo* pTableListInfo, SArray**
|
|||
for (int32_t i = 0; i < size; ++i) {
|
||||
STableKeyInfo* pkeyInfo = tableListGetInfo(pTableListInfo, i);
|
||||
QUERY_CHECK_NULL(pkeyInfo, code, lino, _end, terrno);
|
||||
void* tmp = taosArrayPush(tableIdList, &pkeyInfo->uid);
|
||||
void* tmp = taosArrayPush(tableIdList, &pkeyInfo->uid);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, terrno);
|
||||
}
|
||||
|
||||
|
@ -4066,7 +4083,7 @@ int32_t createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhysiNode*
|
|||
int32_t numOfOutput = taosArrayGetSize(pInfo->matchInfo.pList);
|
||||
pColIds = taosArrayInit(numOfOutput, sizeof(int16_t));
|
||||
QUERY_CHECK_NULL(pColIds, code, lino, _error, terrno);
|
||||
|
||||
|
||||
for (int32_t i = 0; i < numOfOutput; ++i) {
|
||||
SColMatchItem* id = taosArrayGet(pInfo->matchInfo.pList, i);
|
||||
QUERY_CHECK_NULL(id, code, lino, _error, terrno);
|
||||
|
@ -4268,7 +4285,7 @@ _error:
|
|||
}
|
||||
|
||||
static int32_t doTagScanOneTable(SOperatorInfo* pOperator, const SSDataBlock* pRes, int32_t count, SMetaReader* mr,
|
||||
SStorageAPI* pAPI) {
|
||||
SStorageAPI* pAPI) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
int32_t lino = 0;
|
||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||
|
@ -4280,7 +4297,6 @@ static int32_t doTagScanOneTable(SOperatorInfo* pOperator, const SSDataBlock* pR
|
|||
qError("failed to get table meta, uid:0x%" PRIx64 ", code:%s, %s", item->uid, tstrerror(terrno),
|
||||
GET_TASKID(pTaskInfo));
|
||||
tDecoderClear(&(*mr).coder);
|
||||
pAPI->metaReaderFn.clearReader(mr);
|
||||
goto _end;
|
||||
}
|
||||
|
||||
|
@ -4289,7 +4305,6 @@ static int32_t doTagScanOneTable(SOperatorInfo* pOperator, const SSDataBlock* pR
|
|||
if (code != TSDB_CODE_SUCCESS) {
|
||||
qError("failed to get table meta, uid:0x%" PRIx64 ", code:%s, %s", item->uid, tstrerror(terrno),
|
||||
GET_TASKID(pTaskInfo));
|
||||
pAPI->metaReaderFn.clearReader(mr);
|
||||
goto _end;
|
||||
}
|
||||
|
||||
|
@ -4697,6 +4712,12 @@ static int32_t doTagScanFromMetaEntryNext(SOperatorInfo* pOperator, SSDataBlock*
|
|||
|
||||
while (pInfo->curPos < size && count < pOperator->resultInfo.capacity) {
|
||||
code = doTagScanOneTable(pOperator, pRes, count, &mr, &pTaskInfo->storageAPI);
|
||||
if (code == TSDB_CODE_OUT_OF_MEMORY) {
|
||||
break;
|
||||
} else {
|
||||
// ignore other error
|
||||
}
|
||||
|
||||
++count;
|
||||
if (++pInfo->curPos >= size) {
|
||||
setOperatorCompleted(pOperator);
|
||||
|
@ -4814,7 +4835,7 @@ int32_t createTagScanOperatorInfo(SReadHandle* pReadHandle, STagScanPhysiNode* p
|
|||
nodesRewriteExprPostOrder(&pTagCond, tagScanRewriteTagColumn, (void*)&pInfo->filterCtx);
|
||||
}
|
||||
}
|
||||
//TODO wjm check pInfo->filterCtx.code
|
||||
// TODO wjm check pInfo->filterCtx.code
|
||||
__optr_fn_t tagScanNextFn = (pTagScanNode->onlyMetaCtbIdx) ? doTagScanFromCtbIdxNext : doTagScanFromMetaEntryNext;
|
||||
pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, tagScanNextFn, NULL, destroyTagScanOperatorInfo,
|
||||
optrDefaultBufFn, NULL, optrDefaultGetNextExtFn, NULL);
|
||||
|
@ -4925,7 +4946,7 @@ static int32_t fetchNextSubTableBlockFromReader(SOperatorInfo* pOperator, STmsSu
|
|||
pInfo->base.dataReader = pInput->pReader;
|
||||
|
||||
while (true) {
|
||||
bool hasNext = false;
|
||||
bool hasNext = false;
|
||||
code = pAPI->tsdReader.tsdNextDataBlock(pInfo->base.dataReader, &hasNext);
|
||||
if (code != 0) {
|
||||
pAPI->tsdReader.tsdReaderReleaseDataBlock(pInfo->base.dataReader);
|
||||
|
@ -5036,7 +5057,7 @@ static int32_t openSubTablesMergeSort(STmsSubTablesMergeInfo* pSubTblsInfo) {
|
|||
static int32_t initSubTablesMergeInfo(STableMergeScanInfo* pInfo) {
|
||||
int32_t code = setGroupStartEndIndex(pInfo);
|
||||
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));
|
||||
return code;
|
||||
}
|
||||
STmsSubTablesMergeInfo* pSubTblsInfo = taosMemoryCalloc(1, sizeof(STmsSubTablesMergeInfo));
|
||||
|
@ -5065,8 +5086,7 @@ static int32_t initSubTablesMergeInfo(STableMergeScanInfo* pInfo) {
|
|||
}
|
||||
int32_t bufPageSize = pInfo->bufPageSize;
|
||||
int32_t inMemSize = (pSubTblsInfo->numSubTables - pSubTblsInfo->numTableBlocksInMem) * bufPageSize;
|
||||
code =
|
||||
createDiskbasedBuf(&pSubTblsInfo->pBlocksBuf, pInfo->bufPageSize, inMemSize, "blocksExternalBuf", tsTempDir);
|
||||
code = createDiskbasedBuf(&pSubTblsInfo->pBlocksBuf, pInfo->bufPageSize, inMemSize, "blocksExternalBuf", tsTempDir);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
taosMemoryFree(pSubTblsInfo->aInputs);
|
||||
taosMemoryFree(pSubTblsInfo);
|
||||
|
@ -5199,7 +5219,7 @@ static int32_t appendChosenRowToDataBlock(STmsSubTablesMergeInfo* pSubTblsInfo,
|
|||
|
||||
SColumnInfoData* pSrcColInfo = taosArrayGet(pInputBlock->pDataBlock, i);
|
||||
QUERY_CHECK_NULL(pSrcColInfo, code, lino, _end, terrno);
|
||||
bool isNull = colDataIsNull(pSrcColInfo, pInputBlock->info.rows, pInput->rowIdx, NULL);
|
||||
bool isNull = colDataIsNull(pSrcColInfo, pInputBlock->info.rows, pInput->rowIdx, NULL);
|
||||
|
||||
if (isNull) {
|
||||
code = colDataSetVal(pColInfo, pBlock->info.rows, NULL, true);
|
||||
|
@ -5223,7 +5243,8 @@ _end:
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t getSubTablesSortedBlock(SOperatorInfo* pOperator, SSDataBlock* pBlock, int32_t capacity, SSDataBlock** pResBlock) {
|
||||
static int32_t getSubTablesSortedBlock(SOperatorInfo* pOperator, SSDataBlock* pBlock, int32_t capacity,
|
||||
SSDataBlock** pResBlock) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
int32_t lino = 0;
|
||||
STableMergeScanInfo* pInfo = pOperator->info;
|
||||
|
@ -5580,9 +5601,9 @@ static int32_t getBlockForTableMergeScan(void* param, SSDataBlock** ppBlock) {
|
|||
}
|
||||
|
||||
int32_t generateSortByTsPkInfo(SArray* colMatchInfo, int32_t order, SArray** ppSortArray) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
int32_t lino = 0;
|
||||
SArray* pSortInfo = taosArrayInit(1, sizeof(SBlockOrderInfo));
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
int32_t lino = 0;
|
||||
SArray* pSortInfo = taosArrayInit(1, sizeof(SBlockOrderInfo));
|
||||
QUERY_CHECK_NULL(pSortInfo, code, lino, _end, terrno);
|
||||
SBlockOrderInfo biTs = {0};
|
||||
SBlockOrderInfo biPk = {0};
|
||||
|
@ -5983,7 +6004,7 @@ int32_t getTableMergeScanExplainExecInfo(SOperatorInfo* pOptr, void** pOptrExpla
|
|||
if (!execInfo) {
|
||||
return terrno;
|
||||
}
|
||||
STableMergeScanInfo* pInfo = pOptr->info;
|
||||
STableMergeScanInfo* pInfo = pOptr->info;
|
||||
execInfo->blockRecorder = pInfo->base.readRecorder;
|
||||
execInfo->sortExecInfo = pInfo->sortExecInfo;
|
||||
|
||||
|
@ -6126,24 +6147,24 @@ _error:
|
|||
|
||||
// ====================================================================================================================
|
||||
// TableCountScanOperator
|
||||
static void destoryTableCountScanOperator(void* param);
|
||||
static int32_t buildVnodeGroupedStbTableCount(STableCountScanOperatorInfo* pInfo, STableCountScanSupp* pSupp,
|
||||
SSDataBlock* pRes, char* dbName, tb_uid_t stbUid, SStorageAPI* pAPI);
|
||||
static int32_t buildVnodeGroupedNtbTableCount(STableCountScanOperatorInfo* pInfo, STableCountScanSupp* pSupp,
|
||||
SSDataBlock* pRes, char* dbName, SStorageAPI* pAPI);
|
||||
static int32_t buildVnodeFilteredTbCount(SOperatorInfo* pOperator, STableCountScanOperatorInfo* pInfo,
|
||||
STableCountScanSupp* pSupp, SSDataBlock* pRes, char* dbName);
|
||||
static int32_t buildVnodeGroupedTableCount(SOperatorInfo* pOperator, STableCountScanOperatorInfo* pInfo,
|
||||
STableCountScanSupp* pSupp, SSDataBlock* pRes, int32_t vgId, char* dbName);
|
||||
static int32_t buildVnodeDbTableCount(SOperatorInfo* pOperator, STableCountScanOperatorInfo* pInfo,
|
||||
STableCountScanSupp* pSupp, SSDataBlock* pRes);
|
||||
static void buildSysDbGroupedTableCount(SOperatorInfo* pOperator, STableCountScanOperatorInfo* pInfo,
|
||||
STableCountScanSupp* pSupp, SSDataBlock* pRes, size_t infodbTableNum,
|
||||
size_t perfdbTableNum);
|
||||
static void buildSysDbFilterTableCount(SOperatorInfo* pOperator, STableCountScanSupp* pSupp, SSDataBlock* pRes,
|
||||
size_t infodbTableNum, size_t perfdbTableNum);
|
||||
static const char* GROUP_TAG_DB_NAME = "db_name";
|
||||
static const char* GROUP_TAG_STABLE_NAME = "stable_name";
|
||||
static void destoryTableCountScanOperator(void* param);
|
||||
static int32_t buildVnodeGroupedStbTableCount(STableCountScanOperatorInfo* pInfo, STableCountScanSupp* pSupp,
|
||||
SSDataBlock* pRes, char* dbName, tb_uid_t stbUid, SStorageAPI* pAPI);
|
||||
static int32_t buildVnodeGroupedNtbTableCount(STableCountScanOperatorInfo* pInfo, STableCountScanSupp* pSupp,
|
||||
SSDataBlock* pRes, char* dbName, SStorageAPI* pAPI);
|
||||
static int32_t buildVnodeFilteredTbCount(SOperatorInfo* pOperator, STableCountScanOperatorInfo* pInfo,
|
||||
STableCountScanSupp* pSupp, SSDataBlock* pRes, char* dbName);
|
||||
static int32_t buildVnodeGroupedTableCount(SOperatorInfo* pOperator, STableCountScanOperatorInfo* pInfo,
|
||||
STableCountScanSupp* pSupp, SSDataBlock* pRes, int32_t vgId, char* dbName);
|
||||
static int32_t buildVnodeDbTableCount(SOperatorInfo* pOperator, STableCountScanOperatorInfo* pInfo,
|
||||
STableCountScanSupp* pSupp, SSDataBlock* pRes);
|
||||
static void buildSysDbGroupedTableCount(SOperatorInfo* pOperator, STableCountScanOperatorInfo* pInfo,
|
||||
STableCountScanSupp* pSupp, SSDataBlock* pRes, size_t infodbTableNum,
|
||||
size_t perfdbTableNum);
|
||||
static void buildSysDbFilterTableCount(SOperatorInfo* pOperator, STableCountScanSupp* pSupp, SSDataBlock* pRes,
|
||||
size_t infodbTableNum, size_t perfdbTableNum);
|
||||
static const char* GROUP_TAG_DB_NAME = "db_name";
|
||||
static const char* GROUP_TAG_STABLE_NAME = "stable_name";
|
||||
|
||||
int32_t tblCountScanGetGroupTagsSlotId(const SNodeList* scanCols, STableCountScanSupp* supp) {
|
||||
if (scanCols != NULL) {
|
||||
|
@ -6478,7 +6499,7 @@ _end:
|
|||
}
|
||||
|
||||
static int32_t buildVnodeGroupedTableCount(SOperatorInfo* pOperator, STableCountScanOperatorInfo* pInfo,
|
||||
STableCountScanSupp* pSupp, SSDataBlock* pRes, int32_t vgId, char* dbName) {
|
||||
STableCountScanSupp* pSupp, SSDataBlock* pRes, int32_t vgId, char* dbName) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
int32_t lino = 0;
|
||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||
|
@ -6526,7 +6547,7 @@ _end:
|
|||
}
|
||||
|
||||
static int32_t buildVnodeFilteredTbCount(SOperatorInfo* pOperator, STableCountScanOperatorInfo* pInfo,
|
||||
STableCountScanSupp* pSupp, SSDataBlock* pRes, char* dbName) {
|
||||
STableCountScanSupp* pSupp, SSDataBlock* pRes, char* dbName) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
int32_t lino = 0;
|
||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||
|
|
|
@ -328,7 +328,9 @@ static int32_t getSortedBlockData(SSortHandle* pHandle, SSDataBlock* pDataBlock,
|
|||
|
||||
int32_t loadNextDataBlock(void* param, SSDataBlock** ppBlock) {
|
||||
SOperatorInfo* pOperator = (SOperatorInfo*)param;
|
||||
return pOperator->fpSet.getNextFn(pOperator, ppBlock);
|
||||
int32_t code = pOperator->fpSet.getNextFn(pOperator, ppBlock);
|
||||
blockDataCheck(*ppBlock, false);
|
||||
return code;
|
||||
}
|
||||
|
||||
// todo refactor: merged with fetch fp
|
||||
|
@ -611,6 +613,7 @@ int32_t fetchNextGroupSortDataBlock(void* param, SSDataBlock** ppBlock) {
|
|||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
|
||||
if (block != NULL) {
|
||||
blockDataCheck(block, false);
|
||||
if (block->info.id.groupId == grpSortOpInfo->currGroupId) {
|
||||
grpSortOpInfo->childOpStatus = CHILD_OP_SAME_GROUP;
|
||||
*ppBlock = block;
|
||||
|
|
|
@ -894,13 +894,7 @@ int64_t* extractTsCol(SSDataBlock* pBlock, const SIntervalAggOperatorInfo* pInfo
|
|||
|
||||
tsCols = (int64_t*)pColDataInfo->pData;
|
||||
if(tsCols[0] == 0) {
|
||||
pTaskInfo->code = TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR;
|
||||
T_LONG_JMP(pTaskInfo->env, terrno);
|
||||
}
|
||||
|
||||
// no data in primary ts
|
||||
if (tsCols[0] == 0 && tsCols[pBlock->info.rows - 1] == 0) {
|
||||
return NULL;
|
||||
qWarn("%s at line %d.block start ts:%" PRId64 ",end ts:%" PRId64, __func__, __LINE__, tsCols[0], tsCols[pBlock->info.rows - 1]);
|
||||
}
|
||||
|
||||
if (tsCols[0] != 0 && (pBlock->info.window.skey == 0 && pBlock->info.window.ekey == 0)) {
|
||||
|
@ -1082,7 +1076,7 @@ static int32_t openStateWindowAggOptr(SOperatorInfo* pOperator) {
|
|||
}
|
||||
|
||||
pInfo->binfo.pRes->info.scanFlag = pBlock->info.scanFlag;
|
||||
code = setInputDataBlock(pSup, pBlock, order, MAIN_SCAN, true);
|
||||
code = setInputDataBlock(pSup, pBlock, order, pBlock->info.scanFlag, true);
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
|
||||
code = blockDataUpdateTsWindow(pBlock, pInfo->tsSlotId);
|
||||
|
@ -1567,7 +1561,7 @@ static int32_t doSessionWindowAggNext(SOperatorInfo* pOperator, SSDataBlock** pp
|
|||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
}
|
||||
// the pDataBlock are always the same one, no need to call this again
|
||||
code = setInputDataBlock(pSup, pBlock, order, MAIN_SCAN, true);
|
||||
code = setInputDataBlock(pSup, pBlock, order, pBlock->info.scanFlag, true);
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
|
||||
code = blockDataUpdateTsWindow(pBlock, pInfo->tsSlotId);
|
||||
|
|
|
@ -152,6 +152,7 @@ int32_t getIrateInfoSize(int32_t pkBytes);
|
|||
int32_t cachedLastRowFunction(SqlFunctionCtx* pCtx);
|
||||
|
||||
bool getFirstLastFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
||||
int32_t firstLastFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo);
|
||||
int32_t firstFunction(SqlFunctionCtx* pCtx);
|
||||
int32_t firstFunctionMerge(SqlFunctionCtx* pCtx);
|
||||
int32_t lastFunction(SqlFunctionCtx* pCtx);
|
||||
|
|
|
@ -3469,7 +3469,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.translateFunc = translateFirstLast,
|
||||
.dynDataRequiredFunc = lastDynDataReq,
|
||||
.getEnvFunc = getFirstLastFuncEnv,
|
||||
.initFunc = functionSetup,
|
||||
.initFunc = firstLastFunctionSetup,
|
||||
.processFunc = lastFunction,
|
||||
.sprocessFunc = firstLastScalarFunction,
|
||||
.finalizeFunc = firstLastFinalize,
|
||||
|
|
|
@ -2617,6 +2617,22 @@ static FORCE_INLINE TSKEY getRowPTs(SColumnInfoData* pTsColInfo, int32_t rowInde
|
|||
return *(TSKEY*)colDataGetData(pTsColInfo, rowIndex);
|
||||
}
|
||||
|
||||
int32_t firstLastFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResInfo) {
|
||||
if (pResInfo->initialized) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS != functionSetup(pCtx, pResInfo)) {
|
||||
return TSDB_CODE_FUNC_SETUP_ERROR;
|
||||
}
|
||||
|
||||
SFirstLastRes * pRes = GET_ROWCELL_INTERBUF(pResInfo);
|
||||
SInputColumnInfoData* pInput = &pCtx->input;
|
||||
|
||||
pRes->nullTupleSaved = false;
|
||||
pRes->nullTuplePos.pageId = -1;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t prepareBuf(SqlFunctionCtx* pCtx) {
|
||||
if (pCtx->subsidiaries.rowLen == 0) {
|
||||
int32_t rowLen = 0;
|
||||
|
@ -2635,7 +2651,7 @@ static int32_t prepareBuf(SqlFunctionCtx* pCtx) {
|
|||
}
|
||||
|
||||
static int32_t firstlastSaveTupleData(const SSDataBlock* pSrcBlock, int32_t rowIndex, SqlFunctionCtx* pCtx,
|
||||
SFirstLastRes* pInfo) {
|
||||
SFirstLastRes* pInfo, bool noElements) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
|
||||
if (pCtx->subsidiaries.num <= 0) {
|
||||
|
@ -2643,7 +2659,7 @@ static int32_t firstlastSaveTupleData(const SSDataBlock* pSrcBlock, int32_t rowI
|
|||
}
|
||||
|
||||
if (!pInfo->hasResult) {
|
||||
code = saveTupleData(pCtx, rowIndex, pSrcBlock, &pInfo->pos);
|
||||
code = saveTupleData(pCtx, rowIndex, pSrcBlock, noElements ? &pInfo->nullTuplePos : &pInfo->pos);
|
||||
} else {
|
||||
code = updateTupleData(pCtx, rowIndex, pSrcBlock, &pInfo->pos);
|
||||
}
|
||||
|
@ -2669,7 +2685,7 @@ static int32_t doSaveCurrentVal(SqlFunctionCtx* pCtx, int32_t rowIndex, int64_t
|
|||
}
|
||||
|
||||
pInfo->ts = currentTs;
|
||||
int32_t code = firstlastSaveTupleData(pCtx->pSrcBlock, rowIndex, pCtx, pInfo);
|
||||
int32_t code = firstlastSaveTupleData(pCtx->pSrcBlock, rowIndex, pCtx, pInfo, false);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
|
@ -2708,10 +2724,11 @@ int32_t firstFunction(SqlFunctionCtx* pCtx) {
|
|||
if (pInput->colDataSMAIsSet && (pInput->pColumnDataAgg[0]->numOfNull == pInput->totalRows) &&
|
||||
pInputCol->hasNull == true) {
|
||||
// save selectivity value for column consisted of all null values
|
||||
int32_t code = firstlastSaveTupleData(pCtx->pSrcBlock, pInput->startRowIndex, pCtx, pInfo);
|
||||
int32_t code = firstlastSaveTupleData(pCtx->pSrcBlock, pInput->startRowIndex, pCtx, pInfo, !pInfo->nullTupleSaved);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
pInfo->nullTupleSaved = true;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -2802,10 +2819,11 @@ int32_t firstFunction(SqlFunctionCtx* pCtx) {
|
|||
|
||||
if (numOfElems == 0) {
|
||||
// save selectivity value for column consisted of all null values
|
||||
int32_t code = firstlastSaveTupleData(pCtx->pSrcBlock, pInput->startRowIndex, pCtx, pInfo);
|
||||
int32_t code = firstlastSaveTupleData(pCtx->pSrcBlock, pInput->startRowIndex, pCtx, pInfo, !pInfo->nullTupleSaved);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
pInfo->nullTupleSaved = true;
|
||||
}
|
||||
SET_VAL(pResInfo, numOfElems, 1);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -2841,10 +2859,11 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) {
|
|||
if (pInput->colDataSMAIsSet && (pInput->pColumnDataAgg[0]->numOfNull == pInput->totalRows) &&
|
||||
pInputCol->hasNull == true) {
|
||||
// save selectivity value for column consisted of all null values
|
||||
int32_t code = firstlastSaveTupleData(pCtx->pSrcBlock, pInput->startRowIndex, pCtx, pInfo);
|
||||
int32_t code = firstlastSaveTupleData(pCtx->pSrcBlock, pInput->startRowIndex, pCtx, pInfo, !pInfo->nullTupleSaved);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
pInfo->nullTupleSaved = true;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -2983,10 +3002,11 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) {
|
|||
|
||||
// save selectivity value for column consisted of all null values
|
||||
if (numOfElems == 0) {
|
||||
int32_t code = firstlastSaveTupleData(pCtx->pSrcBlock, pInput->startRowIndex, pCtx, pInfo);
|
||||
int32_t code = firstlastSaveTupleData(pCtx->pSrcBlock, pInput->startRowIndex, pCtx, pInfo, !pInfo->nullTupleSaved);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
pInfo->nullTupleSaved = true;
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -3031,7 +3051,7 @@ static bool firstLastTransferInfoImpl(SFirstLastRes* pInput, SFirstLastRes* pOut
|
|||
static int32_t firstLastTransferInfo(SqlFunctionCtx* pCtx, SFirstLastRes* pInput, SFirstLastRes* pOutput, bool isFirst,
|
||||
int32_t rowIndex) {
|
||||
if (firstLastTransferInfoImpl(pInput, pOutput, isFirst)) {
|
||||
int32_t code = firstlastSaveTupleData(pCtx->pSrcBlock, rowIndex, pCtx, pOutput);
|
||||
int32_t code = firstlastSaveTupleData(pCtx->pSrcBlock, rowIndex, pCtx, pOutput, pOutput->nullTupleSaved);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
}
|
||||
|
@ -3079,6 +3099,14 @@ static int32_t firstLastFunctionMergeImpl(SqlFunctionCtx* pCtx, bool isFirstQuer
|
|||
}
|
||||
}
|
||||
|
||||
if (numOfElems == 0) {
|
||||
int32_t code = firstlastSaveTupleData(pCtx->pSrcBlock, pInput->startRowIndex, pCtx, pInfo, !pInfo->nullTupleSaved);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
pInfo->nullTupleSaved = true;
|
||||
}
|
||||
|
||||
SET_VAL(GET_RES_INFO(pCtx), numOfElems, 1);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -3099,6 +3127,11 @@ int32_t firstLastFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
|||
pResInfo->isNullRes = (pResInfo->numOfRes == 0) ? 1 : 0;
|
||||
|
||||
SFirstLastRes* pRes = GET_ROWCELL_INTERBUF(pResInfo);
|
||||
|
||||
if (pResInfo->isNullRes) {
|
||||
colDataSetNULL(pCol, pBlock->info.rows);
|
||||
return setSelectivityValue(pCtx, pBlock, &pRes->nullTuplePos, pBlock->info.rows);
|
||||
}
|
||||
code = colDataSetVal(pCol, pBlock->info.rows, pRes->buf, pRes->isNull || pResInfo->isNullRes);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
|
@ -3134,12 +3167,16 @@ int32_t firstLastPartialFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
|||
return TSDB_CODE_OUT_OF_RANGE;
|
||||
}
|
||||
|
||||
code = colDataSetVal(pCol, pBlock->info.rows, res, false);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
if (pEntryInfo->numOfRes == 0) {
|
||||
colDataSetNULL(pCol, pBlock->info.rows);
|
||||
code = setSelectivityValue(pCtx, pBlock, &pRes->nullTuplePos, pBlock->info.rows);
|
||||
} else {
|
||||
code = colDataSetVal(pCol, pBlock->info.rows, res, false);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
code = setSelectivityValue(pCtx, pBlock, &pRes->pos, pBlock->info.rows);
|
||||
}
|
||||
code = setSelectivityValue(pCtx, pBlock, &pRes->pos, pBlock->info.rows);
|
||||
|
||||
taosMemoryFree(res);
|
||||
return code;
|
||||
}
|
||||
|
@ -3185,7 +3222,7 @@ static int32_t doSaveLastrow(SqlFunctionCtx* pCtx, char* pData, int32_t rowIndex
|
|||
pInfo->pkData = pInfo->buf + pInfo->bytes;
|
||||
}
|
||||
pInfo->ts = cts;
|
||||
int32_t code = firstlastSaveTupleData(pCtx->pSrcBlock, rowIndex, pCtx, pInfo);
|
||||
int32_t code = firstlastSaveTupleData(pCtx->pSrcBlock, rowIndex, pCtx, pInfo, false);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
|
@ -6036,9 +6073,10 @@ static void modeFunctionCleanup(SModeInfo * pInfo) {
|
|||
}
|
||||
|
||||
void modeFunctionCleanupExt(SqlFunctionCtx* pCtx) {
|
||||
SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx);
|
||||
SModeInfo* pInfo = GET_ROWCELL_INTERBUF(pResInfo);
|
||||
modeFunctionCleanup(pInfo);
|
||||
if (pCtx == NULL || GET_RES_INFO(pCtx) == NULL || GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)) == NULL) {
|
||||
return;
|
||||
}
|
||||
modeFunctionCleanup(GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)));
|
||||
}
|
||||
|
||||
static int32_t saveModeTupleData(SqlFunctionCtx* pCtx, char* data, SModeInfo *pInfo, STuplePos* pPos) {
|
||||
|
|
|
@ -994,7 +994,7 @@ int32_t udfdSaveFuncBodyToFile(SFuncInfo *pFuncInfo, SUdf *udf) {
|
|||
|
||||
TdFilePtr file = taosOpenFile(path, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_READ | TD_FILE_TRUNC);
|
||||
if (file == NULL) {
|
||||
fnError("udfd write udf shared library: %s failed, error: %d %s", path, errno, strerror(errno));
|
||||
fnError("udfd write udf shared library: %s failed, error: %d %s", path, errno, strerror(terrno));
|
||||
return TSDB_CODE_FILE_CORRUPTED;
|
||||
}
|
||||
int64_t count = taosWriteFile(file, pFuncInfo->pCode, pFuncInfo->codeSize);
|
||||
|
|
|
@ -1125,7 +1125,7 @@ static int32_t tfileGetFileList(const char* path, SArray** ppResult) {
|
|||
|
||||
TdDirPtr pDir = taosOpenDir(path);
|
||||
if (NULL == pDir) {
|
||||
TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), NULL, _exception);
|
||||
TAOS_CHECK_GOTO(terrno, NULL, _exception);
|
||||
}
|
||||
TdDirEntryPtr pDirEntry;
|
||||
while ((pDirEntry = taosReadDir(pDir)) != NULL) {
|
||||
|
|
|
@ -235,7 +235,10 @@ void nodesDestroyAllocatorSet() {
|
|||
int64_t refId = 0;
|
||||
while (NULL != pAllocator) {
|
||||
refId = pAllocator->self;
|
||||
(void)taosRemoveRef(g_allocatorReqRefPool, refId);
|
||||
int32_t code = taosRemoveRef(g_allocatorReqRefPool, refId);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
nodesError("failed to remove ref at: %s:%d, rsetId:%d, refId:%"PRId64, __func__, __LINE__, g_allocatorReqRefPool, refId);
|
||||
}
|
||||
pAllocator = taosIterateRef(g_allocatorReqRefPool, refId);
|
||||
}
|
||||
taosCloseRef(g_allocatorReqRefPool);
|
||||
|
@ -328,7 +331,10 @@ void nodesDestroyAllocator(int64_t allocatorId) {
|
|||
return;
|
||||
}
|
||||
|
||||
(void)taosRemoveRef(g_allocatorReqRefPool, allocatorId);
|
||||
int32_t code = taosRemoveRef(g_allocatorReqRefPool, allocatorId);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
nodesError("failed to remove ref at: %s:%d, rsetId:%d, refId:%"PRId64, __func__, __LINE__, g_allocatorReqRefPool, allocatorId);
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t makeNode(ENodeType type, int32_t size, SNode** ppNode) {
|
||||
|
@ -1090,7 +1096,10 @@ void nodesDestroyNode(SNode* pNode) {
|
|||
pStmt->destroyParseFileCxt(&pStmt->pParFileCxt);
|
||||
}
|
||||
|
||||
(void)taosCloseFile(&pStmt->fp);
|
||||
int32_t code = taosCloseFile(&pStmt->fp);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
nodesError("failed to close file: %s:%d", __func__, __LINE__);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case QUERY_NODE_CREATE_DATABASE_STMT:
|
||||
|
|
|
@ -172,6 +172,7 @@ static EDealRes authSelectImpl(SNode* pNode, void* pContext) {
|
|||
SName name = {0};
|
||||
toName(pAuthCxt->pParseCxt->acctId, pTable->dbName, pTable->tableName, &name);
|
||||
STableMeta* pTableMeta = NULL;
|
||||
toName(pAuthCxt->pParseCxt->acctId, pTable->dbName, pTable->tableName, &name);
|
||||
int32_t code = getTargetMetaImpl(
|
||||
pAuthCxt->pParseCxt, pAuthCxt->pMetaCache, &name, &pTableMeta, true);
|
||||
if (TSDB_CODE_SUCCESS == code && TSDB_VIEW_TABLE == pTableMeta->tableType) {
|
||||
|
|
|
@ -2268,7 +2268,7 @@ static int32_t parseDataFromFile(SInsertParseContext* pCxt, SVnodeModifyOpStmt*
|
|||
}
|
||||
pStmt->fp = taosOpenFile(filePathStr, TD_FILE_READ | TD_FILE_STREAM);
|
||||
if (NULL == pStmt->fp) {
|
||||
return TAOS_SYSTEM_ERROR(errno);
|
||||
return terrno;
|
||||
}
|
||||
|
||||
return parseDataFromFileImpl(pCxt, pStmt, rowsDataCxt);
|
||||
|
|
|
@ -2562,6 +2562,13 @@ static int32_t translateRepeatScanFunc(STranslateContext* pCxt, SFunctionNode* p
|
|||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_ALLOWED_FUNC,
|
||||
"%s function is not supported in partition query", pFunc->functionName);
|
||||
}
|
||||
|
||||
if (NULL != pSelect->pWindow) {
|
||||
if (QUERY_NODE_EVENT_WINDOW == nodeType(pSelect->pWindow) || QUERY_NODE_COUNT_WINDOW == nodeType(pSelect->pWindow)) {
|
||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_ALLOWED_FUNC,
|
||||
"%s function is not supported in count/event window", pFunc->functionName);
|
||||
}
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -9591,7 +9598,6 @@ static int32_t translateCreateNormalIndex(STranslateContext* pCxt, SCreateIndexS
|
|||
int32_t code = 0;
|
||||
SName name = {0};
|
||||
STableMeta* pMeta = NULL;
|
||||
|
||||
toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &name);
|
||||
code = getTargetMeta(pCxt, &name, &pMeta, false);
|
||||
if (code) {
|
||||
|
@ -9714,8 +9720,8 @@ static int32_t buildCreateTopicReq(STranslateContext* pCxt, SCreateTopicStmt* pS
|
|||
toName(pCxt->pParseCxt->acctId, pStmt->subDbName, pStmt->subSTbName, &name);
|
||||
(void)tNameGetFullDbName(&name, pReq->subDbName);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
(void)tNameExtractFullName(&name, pReq->subStbName);
|
||||
if (pStmt->pQuery != NULL) {
|
||||
code = tNameExtractFullName(&name, pReq->subStbName);
|
||||
if (TSDB_CODE_SUCCESS == code && pStmt->pQuery != NULL) {
|
||||
code = nodesNodeToString(pStmt->pQuery, false, &pReq->ast, NULL);
|
||||
}
|
||||
}
|
||||
|
@ -9839,7 +9845,7 @@ static int32_t buildQueryForTableTopic(STranslateContext* pCxt, SCreateTopicStmt
|
|||
SName name = {0};
|
||||
STableMeta* pMeta = NULL;
|
||||
toName(pParCxt->acctId, pStmt->subDbName, pStmt->subSTbName, &name);
|
||||
int32_t code = getTargetMeta(pCxt, &name, &pMeta, false);
|
||||
int32_t code = getTargetMeta(pCxt, &name, &pMeta, false);
|
||||
if (code) {
|
||||
taosMemoryFree(pMeta);
|
||||
return code;
|
||||
|
@ -10082,7 +10088,7 @@ static int32_t checkCreateStream(STranslateContext* pCxt, SCreateStreamStmt* pSt
|
|||
STableMeta* pMeta = NULL;
|
||||
int8_t tableType = 0;
|
||||
toName(pCxt->pParseCxt->acctId, pRealTable->table.dbName, pRealTable->table.tableName, &name);
|
||||
int32_t code = getTargetMeta(pCxt, &name, &pMeta, true);
|
||||
int32_t code = getTargetMeta(pCxt, &name, &pMeta, true);
|
||||
if (NULL != pMeta) {
|
||||
tableType = pMeta->tableType;
|
||||
taosMemoryFree(pMeta);
|
||||
|
@ -11111,10 +11117,11 @@ static int32_t buildCreateStreamReq(STranslateContext* pCxt, SCreateStreamStmt*
|
|||
if ('\0' != pStmt->targetTabName[0]) {
|
||||
strcpy(name.dbname, pStmt->targetDbName);
|
||||
strcpy(name.tname, pStmt->targetTabName);
|
||||
(void)tNameExtractFullName(&name, pReq->targetStbFullName);
|
||||
code = tNameExtractFullName(&name, pReq->targetStbFullName);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = buildCreateStreamQuery(pCxt, pStmt, pReq);
|
||||
}
|
||||
|
||||
code = buildCreateStreamQuery(pCxt, pStmt, pReq);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
pReq->sql = taosStrdup(pCxt->pParseCxt->pSql);
|
||||
if (NULL == pReq->sql) {
|
||||
|
@ -11385,7 +11392,7 @@ static int32_t translateDropView(STranslateContext* pCxt, SDropViewStmt* pStmt)
|
|||
static int32_t readFromFile(char* pName, int32_t* len, char** buf) {
|
||||
int64_t filesize = 0;
|
||||
if (taosStatFile(pName, &filesize, NULL, NULL) < 0) {
|
||||
return TAOS_SYSTEM_ERROR(errno);
|
||||
return terrno;
|
||||
}
|
||||
|
||||
*len = filesize;
|
||||
|
@ -11402,12 +11409,13 @@ static int32_t readFromFile(char* pName, int32_t* len, char** buf) {
|
|||
TdFilePtr tfile = taosOpenFile(pName, O_RDONLY | O_BINARY);
|
||||
if (NULL == tfile) {
|
||||
taosMemoryFreeClear(*buf);
|
||||
return TAOS_SYSTEM_ERROR(errno);
|
||||
return terrno;
|
||||
}
|
||||
|
||||
int64_t s = taosReadFile(tfile, *buf, *len);
|
||||
if (s != *len) {
|
||||
(void)taosCloseFile(&tfile);
|
||||
int32_t code = taosCloseFile(&tfile);
|
||||
qError("failed to close file: %s in %s:%d, err: %s", pName, __func__, __LINE__, tstrerror(code));
|
||||
taosMemoryFreeClear(*buf);
|
||||
return TSDB_CODE_APP_ERROR;
|
||||
}
|
||||
|
@ -13082,8 +13090,7 @@ static int32_t checkShowTags(STranslateContext* pCxt, const SShowStmt* pShow) {
|
|||
int32_t code = 0;
|
||||
SName name = {0};
|
||||
STableMeta* pTableMeta = NULL;
|
||||
toName(pCxt->pParseCxt->acctId, ((SValueNode*)pShow->pDbName)->literal,
|
||||
((SValueNode*)pShow->pTbName)->literal, &name);
|
||||
toName(pCxt->pParseCxt->acctId, ((SValueNode*)pShow->pDbName)->literal, ((SValueNode*)pShow->pTbName)->literal, &name);
|
||||
code = getTargetMeta(pCxt, &name, &pTableMeta, true);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
code = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_GET_META_ERROR, tstrerror(code));
|
||||
|
@ -13291,7 +13298,7 @@ static int32_t buildNormalTableBatchReq(int32_t acctId, const SCreateTableStmt*
|
|||
req.ntb.schemaRow.pSchema = taosMemoryCalloc(req.ntb.schemaRow.nCols, sizeof(SSchema));
|
||||
if (NULL == req.name || NULL == req.ntb.schemaRow.pSchema) {
|
||||
tdDestroySVCreateTbReq(&req);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
if (pStmt->ignoreExists) {
|
||||
req.flags |= TD_CREATE_IF_NOT_EXISTS;
|
||||
|
@ -14083,7 +14090,7 @@ static int32_t prepareReadCsvFile(STranslateContext* pCxt, SCreateSubTableFromFi
|
|||
if (NULL == pModifyStmt->fp) {
|
||||
fp = taosOpenFile(pCreateStmt->filePath, TD_FILE_READ | TD_FILE_STREAM);
|
||||
if (NULL == fp) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
goto _ERR;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -202,7 +202,7 @@ static int32_t rewriteExprsForSelect(SNodeList* pExprs, SSelectStmt* pSelect, ES
|
|||
if (NULL != pRewriteExprs) {
|
||||
cxt.pOutputs = taosMemoryCalloc(LIST_LENGTH(pExprs), sizeof(bool));
|
||||
if (NULL == cxt.pOutputs) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
}
|
||||
nodesRewriteSelectStmt(pSelect, clause, doRewriteExpr, &cxt);
|
||||
|
|
|
@ -2883,7 +2883,7 @@ static int32_t smaIndexOptCreateSmaScan(SScanLogicNode* pScan, STableIndexInfo*
|
|||
pSmaScan->pVgroupList = taosMemoryCalloc(1, sizeof(SVgroupsInfo) + sizeof(SVgroupInfo));
|
||||
if (!pSmaScan->pVgroupList) {
|
||||
nodesDestroyNode((SNode*)pSmaScan);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
code = nodesCloneList(pCols, &pSmaScan->node.pTargets);
|
||||
if (NULL == pSmaScan->node.pTargets) {
|
||||
|
@ -4297,7 +4297,7 @@ static void lastRowScanOptRemoveUslessTargets(SNodeList* pTargets, SNodeList* pL
|
|||
static int32_t lastRowScanBuildFuncTypes(SScanLogicNode* pScan, SColumnNode* pColNode, int32_t funcType) {
|
||||
SFunctParam* pFuncTypeParam = taosMemoryCalloc(1, sizeof(SFunctParam));
|
||||
if (NULL == pFuncTypeParam) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
pFuncTypeParam->type = funcType;
|
||||
if (NULL == pScan->pFuncTypes) {
|
||||
|
@ -4311,7 +4311,7 @@ static int32_t lastRowScanBuildFuncTypes(SScanLogicNode* pScan, SColumnNode* pCo
|
|||
pFuncTypeParam->pCol = taosMemoryCalloc(1, sizeof(SColumn));
|
||||
if (NULL == pFuncTypeParam->pCol) {
|
||||
taosMemoryFree(pFuncTypeParam);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
pFuncTypeParam->pCol->colId = pColNode->colId;
|
||||
strcpy(pFuncTypeParam->pCol->name, pColNode->colName);
|
||||
|
@ -6671,7 +6671,7 @@ static int32_t fillTSMAOptCtx(STSMAOptCtx* pTsmaOptCtx, SScanLogicNode* pScan) {
|
|||
|
||||
if (nodeType(pTsmaOptCtx->pParent) == QUERY_NODE_LOGIC_PLAN_WINDOW) {
|
||||
pTsmaOptCtx->queryInterval = taosMemoryCalloc(1, sizeof(SInterval));
|
||||
if (!pTsmaOptCtx->queryInterval) return TSDB_CODE_OUT_OF_MEMORY;
|
||||
if (!pTsmaOptCtx->queryInterval) return terrno;
|
||||
|
||||
SWindowLogicNode* pWindow = (SWindowLogicNode*)pTsmaOptCtx->pParent;
|
||||
pTsmaOptCtx->queryInterval->interval = pWindow->interval;
|
||||
|
@ -7076,7 +7076,7 @@ static int32_t tsmaOptRewriteTbname(const STSMAOptCtx* pTsmaOptCtx, SNode** pTbN
|
|||
pValue->node.resType = ((SExprNode*)(*pTbNameNode))->resType;
|
||||
pValue->literal = taosMemoryCalloc(1, TSDB_TABLE_FNAME_LEN + 1);
|
||||
pValue->datum.p = taosMemoryCalloc(1, TSDB_TABLE_FNAME_LEN + 1 + VARSTR_HEADER_SIZE);
|
||||
if (!pValue->literal || !pValue->datum.p) code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
if (!pValue->literal || !pValue->datum.p) code = terrno;
|
||||
}
|
||||
|
||||
if (code == TSDB_CODE_SUCCESS) {
|
||||
|
@ -7204,7 +7204,7 @@ static int32_t tsmaOptRewriteScan(STSMAOptCtx* pTsmaOptCtx, SScanLogicNode* pNew
|
|||
int32_t len = sizeof(int32_t) + sizeof(SVgroupInfo) * pVgpsInfo->numOfVgroups;
|
||||
pNewScan->pVgroupList = taosMemoryCalloc(1, len);
|
||||
if (!pNewScan->pVgroupList) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
break;
|
||||
}
|
||||
memcpy(pNewScan->pVgroupList, pVgpsInfo, len);
|
||||
|
|
|
@ -47,7 +47,7 @@ static int32_t doSetScanVgroup(SLogicNode* pNode, const SVgroupInfo* pVgroup, bo
|
|||
SScanLogicNode* pScan = (SScanLogicNode*)pNode;
|
||||
pScan->pVgroupList = taosMemoryCalloc(1, sizeof(SVgroupsInfo) + sizeof(SVgroupInfo));
|
||||
if (NULL == pScan->pVgroupList) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
memcpy(pScan->pVgroupList->vgroups, pVgroup, sizeof(SVgroupInfo));
|
||||
*pFound = true;
|
||||
|
|
|
@ -623,7 +623,7 @@ int32_t cloneSVreateTbReq(SVCreateTbReq* pSrc, SVCreateTbReq** pDst) {
|
|||
|
||||
*pDst = taosMemoryCalloc(1, sizeof(SVCreateTbReq));
|
||||
if (NULL == *pDst) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
(*pDst)->flags = pSrc->flags;
|
||||
|
|
|
@ -436,7 +436,7 @@ int32_t qwGetDeleteResFromSink(QW_FPARAMS_DEF, SQWTaskCtx *ctx, SDeleteRes *pRes
|
|||
|
||||
output.pData = taosMemoryCalloc(1, len);
|
||||
if (NULL == output.pData) {
|
||||
QW_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
QW_ERR_RET(terrno);
|
||||
}
|
||||
|
||||
code = dsGetDataBlock(ctx->sinkHandle, &output);
|
||||
|
@ -1324,7 +1324,7 @@ int32_t qWorkerInit(int8_t nodeType, int32_t nodeId, void **qWorkerMgmt, const S
|
|||
if (NULL == mgmt) {
|
||||
qError("calloc %d failed", (int32_t)sizeof(SQWorker));
|
||||
(void)atomic_sub_fetch_32(&gQwMgmt.qwNum, 1);
|
||||
QW_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
QW_RET(terrno);
|
||||
}
|
||||
|
||||
mgmt->cfg.maxSchedulerNum = QW_DEFAULT_SCHEDULER_NUMBER;
|
||||
|
|
|
@ -468,20 +468,20 @@ int32_t filterInitUnitsFields(SFilterInfo *info) {
|
|||
info->unitSize = FILTER_DEFAULT_UNIT_SIZE;
|
||||
info->units = taosMemoryCalloc(info->unitSize, sizeof(SFilterUnit));
|
||||
if (info->units == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
info->fields[FLD_TYPE_COLUMN].num = 0;
|
||||
info->fields[FLD_TYPE_COLUMN].size = FILTER_DEFAULT_FIELD_SIZE;
|
||||
info->fields[FLD_TYPE_COLUMN].fields = taosMemoryCalloc(info->fields[FLD_TYPE_COLUMN].size, sizeof(SFilterField));
|
||||
if (info->fields[FLD_TYPE_COLUMN].fields == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
info->fields[FLD_TYPE_VALUE].num = 0;
|
||||
info->fields[FLD_TYPE_VALUE].size = FILTER_DEFAULT_FIELD_SIZE;
|
||||
info->fields[FLD_TYPE_VALUE].fields = taosMemoryCalloc(info->fields[FLD_TYPE_VALUE].size, sizeof(SFilterField));
|
||||
if (info->fields[FLD_TYPE_VALUE].fields == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -497,7 +497,7 @@ static FORCE_INLINE int32_t filterNewRange(SFilterRangeCtx *ctx, SFilterRange *r
|
|||
} else {
|
||||
*r = taosMemoryCalloc(1, sizeof(SFilterRangeNode));
|
||||
if (*r == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -516,7 +516,7 @@ int32_t filterInitRangeCtx(int32_t type, int32_t options, SFilterRangeCtx **ctx)
|
|||
|
||||
*ctx = taosMemoryCalloc(1, sizeof(SFilterRangeCtx));
|
||||
if (*ctx == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
(*ctx)->type = type;
|
||||
(*ctx)->options = options;
|
||||
|
@ -961,7 +961,7 @@ int32_t filterDetachCnfGroup(SFilterGroup *gp1, SFilterGroup *gp2, SArray *group
|
|||
gp.unitNum = gp1->unitNum + gp2->unitNum;
|
||||
gp.unitIdxs = taosMemoryCalloc(gp.unitNum, sizeof(*gp.unitIdxs));
|
||||
if (NULL == gp.unitIdxs) {
|
||||
FLT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
FLT_ERR_RET(terrno);
|
||||
}
|
||||
(void)memcpy(gp.unitIdxs, gp1->unitIdxs, gp1->unitNum * sizeof(*gp.unitIdxs));
|
||||
(void)memcpy(gp.unitIdxs + gp1->unitNum, gp2->unitIdxs, gp2->unitNum * sizeof(*gp.unitIdxs));
|
||||
|
@ -1300,7 +1300,7 @@ int32_t fltAddGroupUnitFromNode(SFilterInfo *info, SNode *tree, SArray *group) {
|
|||
|
||||
SScalarParam out = {.columnData = taosMemoryCalloc(1, sizeof(SColumnInfoData))};
|
||||
if (out.columnData == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
out.columnData->info.type = type;
|
||||
out.columnData->info.bytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes; // reserved space for simple_copy
|
||||
|
@ -1330,7 +1330,7 @@ int32_t fltAddGroupUnitFromNode(SFilterInfo *info, SNode *tree, SArray *group) {
|
|||
} else {
|
||||
void *data = taosMemoryCalloc(1, tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes); // reserved space for simple_copy
|
||||
if (NULL == data) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
break;
|
||||
}
|
||||
(void)memcpy(data, nodesGetValueFromNode(valueNode), tDataTypes[type].bytes);
|
||||
|
@ -1729,11 +1729,9 @@ EDealRes fltTreeToGroup(SNode *pNode, void *pContext) {
|
|||
return DEAL_RES_IGNORE_CHILD;
|
||||
}
|
||||
|
||||
ctx->code = TSDB_CODE_APP_ERROR;
|
||||
|
||||
fltError("invalid condition type, type:%d", node->condType);
|
||||
|
||||
return DEAL_RES_ERROR;
|
||||
FLT_ERR_JRET(TSDB_CODE_APP_ERROR);
|
||||
}
|
||||
|
||||
if (QUERY_NODE_OPERATOR == nType) {
|
||||
|
@ -2203,13 +2201,13 @@ int32_t fltInitValFieldData(SFilterInfo *info) {
|
|||
size_t bufBytes = TMAX(dType->bytes, sizeof(int64_t));
|
||||
fi->data = taosMemoryCalloc(1, bufBytes);
|
||||
if (fi->data == NULL) {
|
||||
FLT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
FLT_ERR_RET(terrno);
|
||||
}
|
||||
assignVal(fi->data, nodesGetValueFromNode(var), dType->bytes, type);
|
||||
} else {
|
||||
SScalarParam out = {.columnData = taosMemoryCalloc(1, sizeof(SColumnInfoData))};
|
||||
if (out.columnData == NULL) {
|
||||
FLT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
FLT_ERR_RET(terrno);
|
||||
}
|
||||
out.columnData->info.type = type;
|
||||
out.columnData->info.precision = precision;
|
||||
|
@ -2230,7 +2228,7 @@ int32_t fltInitValFieldData(SFilterInfo *info) {
|
|||
: TMAX(out.columnData->info.bytes, sizeof(int64_t));
|
||||
fi->data = taosMemoryCalloc(1, bufBytes);
|
||||
if (fi->data== NULL) {
|
||||
FLT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
FLT_ERR_RET(terrno);
|
||||
}
|
||||
|
||||
size_t valBytes = IS_VAR_DATA_TYPE(type) ? varDataTLen(out.columnData->pData) : out.columnData->info.bytes;
|
||||
|
@ -2446,7 +2444,7 @@ int32_t filterMergeGroupUnits(SFilterInfo *info, SFilterGroupCtx **gRes, int32_t
|
|||
|
||||
gRes[gResIdx] = taosMemoryCalloc(1, sizeof(SFilterGroupCtx));
|
||||
if (gRes[gResIdx] == NULL) {
|
||||
FLT_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
FLT_ERR_JRET(terrno);
|
||||
}
|
||||
gRes[gResIdx]->colInfo = taosMemoryCalloc(info->fields[FLD_TYPE_COLUMN].num, sizeof(SFilterColInfo));
|
||||
if (gRes[gResIdx]->colInfo == NULL) {
|
||||
|
@ -2876,7 +2874,7 @@ int32_t filterConvertGroupFromArray(SFilterInfo *info, SArray *group) {
|
|||
info->groups = taosMemoryCalloc(info->groupNum, sizeof(*info->groups));
|
||||
if (info->groups == NULL) {
|
||||
info->groupNum = 0;
|
||||
FLT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
FLT_ERR_RET(terrno);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2888,7 +2886,7 @@ int32_t filterConvertGroupFromArray(SFilterInfo *info, SArray *group) {
|
|||
pg->unitFlags = taosMemoryCalloc(pg->unitNum, sizeof(*pg->unitFlags));
|
||||
if (pg->unitFlags == NULL) {
|
||||
pg->unitNum = 0;
|
||||
FLT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
FLT_ERR_RET(terrno);
|
||||
}
|
||||
info->groups[i] = *pg;
|
||||
}
|
||||
|
@ -3005,7 +3003,7 @@ int32_t filterGenerateColRange(SFilterInfo *info, SFilterGroupCtx **gRes, int32_
|
|||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
uint32_t *idxNum = taosMemoryCalloc(info->fields[FLD_TYPE_COLUMN].num, sizeof(*idxNum));
|
||||
if (idxNum == NULL) {
|
||||
FLT_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
FLT_ERR_JRET(terrno);
|
||||
}
|
||||
for (int32_t i = 0; i < gResNum; ++i) {
|
||||
for (uint32_t m = 0; m < gRes[i]->colNum; ++m) {
|
||||
|
@ -3031,7 +3029,7 @@ int32_t filterGenerateColRange(SFilterInfo *info, SFilterGroupCtx **gRes, int32_
|
|||
if (idxs == NULL) {
|
||||
idxs = taosMemoryCalloc(info->fields[FLD_TYPE_COLUMN].num, sizeof(*idxs));
|
||||
if (idxs == NULL) {
|
||||
FLT_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
FLT_ERR_JRET(terrno);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3044,7 +3042,7 @@ int32_t filterGenerateColRange(SFilterInfo *info, SFilterGroupCtx **gRes, int32_
|
|||
info->colRange = taosMemoryCalloc(colNum, POINTER_BYTES);
|
||||
if (info->colRange == NULL) {
|
||||
info->colRangeNum = 0;
|
||||
FLT_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
FLT_ERR_JRET(terrno);
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < gResNum; ++i) {
|
||||
|
@ -3584,7 +3582,7 @@ int32_t filterExecuteImplMisc(void *pinfo, int32_t numOfRows, SColumnInfoData *p
|
|||
(info->cunits[uidx].optr == OP_TYPE_MATCH || info->cunits[uidx].optr == OP_TYPE_NMATCH)) {
|
||||
char *newColData = taosMemoryCalloc(info->cunits[uidx].dataSize * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE, 1);
|
||||
if (newColData == NULL) {
|
||||
FLT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
FLT_ERR_RET(terrno);
|
||||
}
|
||||
int32_t len = taosUcs4ToMbs((TdUcs4 *)varDataVal(colData), varDataLen(colData), varDataVal(newColData));
|
||||
if (len < 0) {
|
||||
|
@ -3659,7 +3657,7 @@ int32_t filterExecuteImpl(void *pinfo, int32_t numOfRows, SColumnInfoData *pRes,
|
|||
(cunit->optr == OP_TYPE_MATCH || cunit->optr == OP_TYPE_NMATCH)) {
|
||||
char *newColData = taosMemoryCalloc(cunit->dataSize * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE, 1);
|
||||
if (newColData == NULL) {
|
||||
FLT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
FLT_ERR_RET(terrno);
|
||||
}
|
||||
int32_t len = taosUcs4ToMbs((TdUcs4 *)varDataVal(colData), varDataLen(colData), varDataVal(newColData));
|
||||
if (len < 0) {
|
||||
|
@ -3740,7 +3738,7 @@ int32_t filterPreprocess(SFilterInfo *info) {
|
|||
int32_t gResNum = 0;
|
||||
SFilterGroupCtx **gRes = taosMemoryCalloc(info->groupNum, sizeof(SFilterGroupCtx *));
|
||||
if (gRes == NULL) {
|
||||
FLT_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
FLT_ERR_JRET(terrno);
|
||||
}
|
||||
|
||||
FLT_ERR_JRET(filterMergeGroupUnits(info, gRes, &gResNum));
|
||||
|
@ -5218,7 +5216,7 @@ int32_t filterInitFromNode(SNode *pNode, SFilterInfo **pInfo, uint32_t options)
|
|||
*pInfo = taosMemoryCalloc(1, sizeof(SFilterInfo));
|
||||
if (NULL == *pInfo) {
|
||||
fltError("taosMemoryCalloc %d failed", (int32_t)sizeof(SFilterInfo));
|
||||
FLT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
FLT_ERR_RET(terrno);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,6 @@ int32_t sclConvertToTsValueNode(int8_t precision, SValueNode *valueNode) {
|
|||
int32_t sclCreateColumnInfoData(SDataType *pType, int32_t numOfRows, SScalarParam *pParam) {
|
||||
SColumnInfoData *pColumnData = taosMemoryCalloc(1, sizeof(SColumnInfoData));
|
||||
if (pColumnData == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
|
@ -99,7 +98,7 @@ int32_t sclExtendResRows(SScalarParam *pDst, SScalarParam *pSrc, SArray *pBlockL
|
|||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
if (NULL == pLeft) {
|
||||
sclError("calloc %d failed", (int32_t)sizeof(SScalarParam));
|
||||
SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
SCL_ERR_RET(terrno);
|
||||
}
|
||||
|
||||
pLeft->numOfRows = pb->info.rows;
|
||||
|
@ -131,7 +130,7 @@ int32_t scalarGenerateSetFromList(void **data, void *pNode, uint32_t type) {
|
|||
SListCell *cell = nodeList->pNodeList->pHead;
|
||||
SScalarParam out = {.columnData = taosMemoryCalloc(1, sizeof(SColumnInfoData))};
|
||||
if (out.columnData == NULL) {
|
||||
SCL_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
SCL_ERR_JRET(terrno);
|
||||
}
|
||||
int32_t len = 0;
|
||||
void *buf = NULL;
|
||||
|
@ -485,7 +484,7 @@ int32_t sclInitParamList(SScalarParam **pParams, SNodeList *pParamList, SScalarC
|
|||
SScalarParam *paramList = taosMemoryCalloc(*paramNum, sizeof(SScalarParam));
|
||||
if (NULL == paramList) {
|
||||
sclError("calloc %d failed", (int32_t)((*paramNum) * sizeof(SScalarParam)));
|
||||
SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
SCL_ERR_RET(terrno);
|
||||
}
|
||||
|
||||
if (pParamList) {
|
||||
|
@ -581,7 +580,7 @@ int32_t sclInitOperatorParams(SScalarParam **pParams, SOperatorNode *node, SScal
|
|||
SScalarParam *paramList = taosMemoryCalloc(paramNum, sizeof(SScalarParam));
|
||||
if (NULL == paramList) {
|
||||
sclError("calloc %d failed", (int32_t)(paramNum * sizeof(SScalarParam)));
|
||||
SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
SCL_ERR_RET(terrno);
|
||||
}
|
||||
|
||||
SCL_ERR_JRET(sclSetOperatorValueType(node, ctx));
|
||||
|
@ -608,7 +607,7 @@ int32_t sclGetNodeRes(SNode *node, SScalarCtx *ctx, SScalarParam **res) {
|
|||
int32_t rowNum = 0;
|
||||
*res = taosMemoryCalloc(1, sizeof(**res));
|
||||
if (NULL == *res) {
|
||||
SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
SCL_ERR_RET(terrno);
|
||||
}
|
||||
|
||||
SCL_ERR_RET(sclInitParam(node, *res, ctx, &rowNum));
|
||||
|
|
|
@ -618,7 +618,7 @@ static int32_t trimHelper(char *orgStr, char* remStr, int32_t orgLen, int32_t re
|
|||
static int32_t convVarcharToNchar(char *input, char **output, int32_t inputLen, int32_t *outputLen) {
|
||||
*output = taosMemoryCalloc(inputLen * TSDB_NCHAR_SIZE, 1);
|
||||
if (NULL == *output) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
bool ret = taosMbsToUcs4(input, inputLen, (TdUcs4 *)*output, inputLen * TSDB_NCHAR_SIZE, outputLen);
|
||||
if (!ret) {
|
||||
|
@ -631,7 +631,7 @@ static int32_t convVarcharToNchar(char *input, char **output, int32_t inputLen,
|
|||
static int32_t convNcharToVarchar(char *input, char **output, int32_t inputLen, int32_t *outputLen) {
|
||||
*output = taosMemoryCalloc(inputLen, 1);
|
||||
if (NULL == *output) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
*outputLen = taosUcs4ToMbs((TdUcs4 *)input, inputLen, *output);
|
||||
if (*outputLen < 0) {
|
||||
|
@ -814,7 +814,7 @@ static int32_t concatCopyHelper(const char *input, char *output, bool hasNchar,
|
|||
if (hasNchar && type == TSDB_DATA_TYPE_VARCHAR) {
|
||||
TdUcs4 *newBuf = taosMemoryCalloc((varDataLen(input) + 1) * TSDB_NCHAR_SIZE, 1);
|
||||
if (NULL == newBuf) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
int32_t len = varDataLen(input);
|
||||
bool ret = taosMbsToUcs4(varDataVal(input), len, newBuf, (varDataLen(input) + 1) * TSDB_NCHAR_SIZE, &len);
|
||||
|
@ -853,10 +853,10 @@ int32_t concatFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu
|
|||
char *outputBuf = NULL;
|
||||
|
||||
if (NULL == pInputData) {
|
||||
SCL_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
SCL_ERR_JRET(terrno);
|
||||
}
|
||||
if (NULL == input) {
|
||||
SCL_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
SCL_ERR_JRET(terrno);
|
||||
}
|
||||
|
||||
int32_t inputLen = 0;
|
||||
|
@ -882,7 +882,7 @@ int32_t concatFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu
|
|||
|
||||
outputBuf = taosMemoryCalloc(outputLen, 1);
|
||||
if (NULL == outputBuf) {
|
||||
SCL_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
SCL_ERR_JRET(terrno);
|
||||
}
|
||||
|
||||
for (int32_t k = 0; k < numOfRows; ++k) {
|
||||
|
@ -928,7 +928,7 @@ int32_t concatWsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p
|
|||
char *outputBuf = NULL;
|
||||
|
||||
if (NULL == pInputData) {
|
||||
SCL_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
SCL_ERR_JRET(terrno);
|
||||
}
|
||||
|
||||
int32_t inputLen = 0;
|
||||
|
@ -960,7 +960,7 @@ int32_t concatWsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p
|
|||
|
||||
outputBuf = taosMemoryCalloc(outputLen, 1);
|
||||
if (NULL == outputBuf) {
|
||||
SCL_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
SCL_ERR_JRET(terrno);
|
||||
}
|
||||
|
||||
for (int32_t k = 0; k < numOfRows; ++k) {
|
||||
|
@ -1016,7 +1016,7 @@ static int32_t doCaseConvFunction(SScalarParam *pInput, int32_t inputNum, SScala
|
|||
int32_t outputLen = pInputData->varmeta.length;
|
||||
char *outputBuf = taosMemoryCalloc(outputLen, 1);
|
||||
if (outputBuf == NULL) {
|
||||
SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
SCL_ERR_RET(terrno);
|
||||
}
|
||||
|
||||
char *output = outputBuf;
|
||||
|
@ -1070,7 +1070,7 @@ static int32_t doTrimFunction(SScalarParam *pInput, int32_t inputNum, SScalarPar
|
|||
}
|
||||
char *outputBuf = taosMemoryCalloc(outputLen, 1);
|
||||
if (outputBuf == NULL) {
|
||||
SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
SCL_ERR_RET(terrno);
|
||||
}
|
||||
|
||||
char *output = outputBuf;
|
||||
|
@ -1528,7 +1528,7 @@ int32_t replaceFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pO
|
|||
|
||||
char *outputBuf = taosMemoryCalloc(outputLen + VARSTR_HEADER_SIZE, 1);
|
||||
if (NULL == outputBuf) {
|
||||
SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
SCL_ERR_RET(terrno);
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < numOfRows; ++i) {
|
||||
|
@ -1643,7 +1643,7 @@ int32_t substrIdxFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *
|
|||
}
|
||||
char *outputBuf = taosMemoryCalloc(outputLen + VARSTR_HEADER_SIZE, 1);
|
||||
if (NULL == outputBuf) {
|
||||
SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
SCL_ERR_RET(terrno);
|
||||
}
|
||||
|
||||
for (int32_t k = 0; k < numOfRows; ++k) {
|
||||
|
@ -1741,7 +1741,7 @@ int32_t repeatFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu
|
|||
numOfRows = TMAX(pInput[0].numOfRows, pInput[1].numOfRows);
|
||||
char *outputBuf = taosMemoryCalloc(outputLen, 1);
|
||||
if (outputBuf == NULL) {
|
||||
SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
SCL_ERR_RET(terrno);
|
||||
}
|
||||
|
||||
char *output = outputBuf;
|
||||
|
@ -1834,7 +1834,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp
|
|||
char *buf = taosMemoryMalloc(bufSize);
|
||||
|
||||
if (convBuf == NULL || output == NULL || buf == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto _end;
|
||||
}
|
||||
|
||||
|
@ -2403,7 +2403,7 @@ int32_t toCharFunction(SScalarParam* pInput, int32_t inputNum, SScalarParam* pOu
|
|||
int32_t code = 0;
|
||||
|
||||
if (format == NULL || out == NULL) {
|
||||
SCL_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
SCL_ERR_JRET(terrno);
|
||||
}
|
||||
for (int32_t i = 0; i < pInput[0].numOfRows; ++i) {
|
||||
if (colDataIsNull_s(pInput[1].columnData, i) || colDataIsNull_s(pInput[0].columnData, i)) {
|
||||
|
@ -2888,13 +2888,16 @@ int32_t floorFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOut
|
|||
}
|
||||
|
||||
int32_t randFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) {
|
||||
if (!IS_NULL_TYPE(GET_PARAM_TYPE(&pInput[0]))) {
|
||||
int32_t seed;
|
||||
GET_TYPED_DATA(seed, int32_t, GET_PARAM_TYPE(&pInput[0]), pInput[0].columnData->pData);
|
||||
taosSeedRand(seed);
|
||||
}
|
||||
int32_t seed;
|
||||
int32_t numOfRows = inputNum == 1 ? pInput[0].numOfRows : TMAX(pInput[0].numOfRows, pInput[1].numOfRows);
|
||||
for (int32_t i = 0; i < numOfRows; ++i) {
|
||||
// for constant seed, only set seed once
|
||||
if ((pInput[0].numOfRows == 1 && i == 0) || (pInput[0].numOfRows != 1)) {
|
||||
if (!IS_NULL_TYPE(GET_PARAM_TYPE(&pInput[0])) && !colDataIsNull_s(pInput[0].columnData, i)) {
|
||||
GET_TYPED_DATA(seed, int32_t, GET_PARAM_TYPE(&pInput[0]), colDataGetData(pInput[0].columnData, i));
|
||||
taosSeedRand(seed);
|
||||
}
|
||||
}
|
||||
double random_value = (double)(taosRand() % RAND_MAX) / RAND_MAX;
|
||||
colDataSetDouble(pOutput->columnData, i, &random_value);
|
||||
}
|
||||
|
@ -4230,7 +4233,7 @@ static int32_t getHistogramBinDesc(SHistoFuncBin **bins, int32_t *binNum, char *
|
|||
intervals = taosMemoryCalloc(numOfBins, sizeof(double));
|
||||
if (NULL == intervals) {
|
||||
cJSON_Delete(binDesc);
|
||||
SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
SCL_ERR_RET(terrno);
|
||||
}
|
||||
if (cJSON_IsNumber(width) && factor == NULL && binType == LINEAR_BIN) {
|
||||
// linear bin process
|
||||
|
@ -4295,7 +4298,7 @@ static int32_t getHistogramBinDesc(SHistoFuncBin **bins, int32_t *binNum, char *
|
|||
intervals = taosMemoryCalloc(numOfBins, sizeof(double));
|
||||
if (NULL == intervals) {
|
||||
cJSON_Delete(binDesc);
|
||||
SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
SCL_ERR_RET(terrno);
|
||||
}
|
||||
cJSON *bin = binDesc->child;
|
||||
if (bin == NULL) {
|
||||
|
@ -4327,7 +4330,7 @@ static int32_t getHistogramBinDesc(SHistoFuncBin **bins, int32_t *binNum, char *
|
|||
*binNum = numOfBins - 1;
|
||||
*bins = taosMemoryCalloc(numOfBins, sizeof(SHistoFuncBin));
|
||||
if (NULL == bins) {
|
||||
SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
SCL_ERR_RET(terrno);
|
||||
}
|
||||
for (int32_t i = 0; i < *binNum; ++i) {
|
||||
(*bins)[i].lower = intervals[i] < intervals[i + 1] ? intervals[i] : intervals[i + 1];
|
||||
|
|
|
@ -124,7 +124,7 @@ int32_t convertBinaryToDouble(const void *inData, void *outData) {
|
|||
char *tmp = taosMemoryCalloc(1, varDataTLen(inData));
|
||||
if (tmp == NULL) {
|
||||
*((double *)outData) = 0.;
|
||||
SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
SCL_ERR_RET(terrno);
|
||||
}
|
||||
(void)memcpy(tmp, varDataVal(inData), varDataLen(inData));
|
||||
double ret = taosStr2Double(tmp, NULL);
|
||||
|
@ -370,7 +370,7 @@ static FORCE_INLINE int32_t varToVarbinary(char *buf, SScalarParam *pOut, int32_
|
|||
if (t == NULL) {
|
||||
sclError("Out of memory");
|
||||
taosMemoryFree(data);
|
||||
SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
SCL_ERR_RET(terrno);
|
||||
}
|
||||
varDataSetLen(t, size);
|
||||
(void)memcpy(varDataVal(t), data, size);
|
||||
|
@ -383,7 +383,7 @@ static FORCE_INLINE int32_t varToVarbinary(char *buf, SScalarParam *pOut, int32_
|
|||
char *t = taosMemoryCalloc(1, inputLen);
|
||||
if (t == NULL) {
|
||||
sclError("Out of memory");
|
||||
SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
SCL_ERR_RET(terrno);
|
||||
}
|
||||
(void)memcpy(t, buf, inputLen);
|
||||
int32_t code = colDataSetVal(pOut->columnData, rowIndex, t, false);
|
||||
|
@ -401,7 +401,7 @@ static FORCE_INLINE int32_t varToNchar(char *buf, SScalarParam *pOut, int32_t ro
|
|||
|
||||
char *t = taosMemoryCalloc(1, outputMaxLen);
|
||||
if (NULL == t) {
|
||||
SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
SCL_ERR_RET(terrno);
|
||||
}
|
||||
int32_t ret =
|
||||
taosMbsToUcs4(varDataVal(buf), inputLen, (TdUcs4 *)varDataVal(t), outputMaxLen - VARSTR_HEADER_SIZE, &len);
|
||||
|
@ -424,7 +424,7 @@ static FORCE_INLINE int32_t ncharToVar(char *buf, SScalarParam *pOut, int32_t ro
|
|||
|
||||
char *t = taosMemoryCalloc(1, inputLen + VARSTR_HEADER_SIZE);
|
||||
if (NULL == t) {
|
||||
SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
SCL_ERR_RET(terrno);
|
||||
}
|
||||
int32_t len = taosUcs4ToMbs((TdUcs4 *)varDataVal(buf), varDataLen(buf), varDataVal(t));
|
||||
if (len < 0) {
|
||||
|
@ -457,7 +457,7 @@ static FORCE_INLINE int32_t varToGeometry(char *buf, SScalarParam *pOut, int32_t
|
|||
|
||||
output = taosMemoryCalloc(1, len + VARSTR_HEADER_SIZE);
|
||||
if (NULL == output) {
|
||||
SCL_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
SCL_ERR_JRET(terrno);
|
||||
}
|
||||
(void)memcpy(output + VARSTR_HEADER_SIZE, t, len);
|
||||
varDataSetLen(output, len);
|
||||
|
@ -2155,7 +2155,7 @@ int32_t vectorJsonContains(SScalarParam *pLeft, SScalarParam *pRight, SScalarPar
|
|||
char *pRightData = colDataGetVarData(pRight->columnData, 0);
|
||||
char *jsonKey = taosMemoryCalloc(1, varDataLen(pRightData) + 1);
|
||||
if (NULL == jsonKey) {
|
||||
SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
SCL_ERR_RET(terrno);
|
||||
}
|
||||
(void)memcpy(jsonKey, varDataVal(pRightData), varDataLen(pRightData));
|
||||
for (; i >= 0 && i < pLeft->numOfRows; i += step) {
|
||||
|
@ -2189,7 +2189,7 @@ int32_t vectorJsonArrow(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam
|
|||
char *pRightData = colDataGetVarData(pRight->columnData, 0);
|
||||
char *jsonKey = taosMemoryCalloc(1, varDataLen(pRightData) + 1);
|
||||
if (NULL == jsonKey) {
|
||||
SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
SCL_ERR_RET(terrno);
|
||||
}
|
||||
(void)memcpy(jsonKey, varDataVal(pRightData), varDataLen(pRightData));
|
||||
for (; i >= 0 && i < pLeft->numOfRows; i += step) {
|
||||
|
|
|
@ -810,7 +810,7 @@ int32_t schInitJob(int64_t *pJobId, SSchedulerReq *pReq) {
|
|||
SSchJob *pJob = taosMemoryCalloc(1, sizeof(SSchJob));
|
||||
if (NULL == pJob) {
|
||||
qError("qid:0x%" PRIx64 " calloc %d failed", pReq->pDag->queryId, (int32_t)sizeof(SSchJob));
|
||||
SCH_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
SCH_ERR_JRET(terrno);
|
||||
}
|
||||
|
||||
pJob->attr.explainMode = pReq->pDag->explainInfo.mode;
|
||||
|
|
|
@ -583,7 +583,7 @@ int32_t schMakeCallbackParam(SSchJob *pJob, SSchTask *pTask, int32_t msgType, bo
|
|||
SSchTaskCallbackParam *param = taosMemoryCalloc(1, sizeof(SSchTaskCallbackParam));
|
||||
if (NULL == param) {
|
||||
SCH_TASK_ELOG("calloc %d failed", (int32_t)sizeof(SSchTaskCallbackParam));
|
||||
SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
SCH_ERR_RET(terrno);
|
||||
}
|
||||
|
||||
param->queryId = pJob->queryId;
|
||||
|
@ -600,7 +600,7 @@ int32_t schMakeCallbackParam(SSchJob *pJob, SSchTask *pTask, int32_t msgType, bo
|
|||
SSchHbCallbackParam *param = taosMemoryCalloc(1, sizeof(SSchHbCallbackParam));
|
||||
if (NULL == param) {
|
||||
SCH_TASK_ELOG("calloc %d failed", (int32_t)sizeof(SSchHbCallbackParam));
|
||||
SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
SCH_ERR_RET(terrno);
|
||||
}
|
||||
|
||||
param->head.isHbParam = true;
|
||||
|
@ -625,7 +625,7 @@ int32_t schMakeCallbackParam(SSchJob *pJob, SSchTask *pTask, int32_t msgType, bo
|
|||
SSchTaskCallbackParam *param = taosMemoryCalloc(1, sizeof(SSchTaskCallbackParam));
|
||||
if (NULL == param) {
|
||||
qError("calloc SSchTaskCallbackParam failed");
|
||||
SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
SCH_ERR_RET(terrno);
|
||||
}
|
||||
|
||||
param->pTrans = trans->pTrans;
|
||||
|
@ -640,7 +640,7 @@ int32_t schGenerateCallBackInfo(SSchJob *pJob, SSchTask *pTask, void *msg, uint3
|
|||
SMsgSendInfo *msgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo));
|
||||
if (NULL == msgSendInfo) {
|
||||
SCH_TASK_ELOG("calloc %d failed", (int32_t)sizeof(SMsgSendInfo));
|
||||
SCH_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
SCH_ERR_JRET(terrno);
|
||||
}
|
||||
|
||||
msgSendInfo->paramFreeFp = taosMemoryFree;
|
||||
|
@ -797,13 +797,13 @@ int32_t schMakeHbRpcCtx(SSchJob *pJob, SSchTask *pTask, SRpcCtx *pCtx) {
|
|||
pMsgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo));
|
||||
if (NULL == pMsgSendInfo) {
|
||||
SCH_TASK_ELOG("calloc %d failed", (int32_t)sizeof(SMsgSendInfo));
|
||||
SCH_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
SCH_ERR_JRET(terrno);
|
||||
}
|
||||
|
||||
param = taosMemoryCalloc(1, sizeof(SSchHbCallbackParam));
|
||||
if (NULL == param) {
|
||||
SCH_TASK_ELOG("calloc %d failed", (int32_t)sizeof(SSchHbCallbackParam));
|
||||
SCH_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
SCH_ERR_JRET(terrno);
|
||||
}
|
||||
|
||||
int32_t msgType = TDMT_SCH_QUERY_HEARTBEAT_RSP;
|
||||
|
@ -927,7 +927,7 @@ int32_t schCloneSMsgSendInfo(void *src, void **dst) {
|
|||
SMsgSendInfo *pDst = taosMemoryCalloc(1, sizeof(*pSrc));
|
||||
if (NULL == pDst) {
|
||||
qError("malloc SMsgSendInfo for rpcCtx failed, len:%d", (int32_t)sizeof(*pSrc));
|
||||
SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
SCH_ERR_RET(terrno);
|
||||
}
|
||||
|
||||
TAOS_MEMCPY(pDst, pSrc, sizeof(*pSrc));
|
||||
|
@ -1059,7 +1059,7 @@ int32_t schBuildAndSendHbMsg(SQueryNodeEpId *nodeEpId, SArray *taskAction) {
|
|||
void *msg = taosMemoryCalloc(1, msgSize);
|
||||
if (NULL == msg) {
|
||||
qError("calloc hb req %d failed", msgSize);
|
||||
SCH_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
SCH_ERR_JRET(terrno);
|
||||
}
|
||||
|
||||
if (tSerializeSSchedulerHbReq(msg, msgSize, &req) < 0) {
|
||||
|
@ -1116,7 +1116,7 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr,
|
|||
msg = taosMemoryCalloc(1, msgSize);
|
||||
if (NULL == msg) {
|
||||
SCH_TASK_ELOG("calloc %d failed", msgSize);
|
||||
SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
SCH_ERR_RET(terrno);
|
||||
}
|
||||
|
||||
TAOS_MEMCPY(msg, pTask->msg, msgSize);
|
||||
|
@ -1142,7 +1142,7 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr,
|
|||
msg = taosMemoryCalloc(1, msgSize);
|
||||
if (NULL == msg) {
|
||||
SCH_TASK_ELOG("calloc %d failed", msgSize);
|
||||
SCH_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
SCH_ERR_JRET(terrno);
|
||||
}
|
||||
|
||||
msgSize = tSerializeSVDeleteReq(msg, msgSize, &req);
|
||||
|
@ -1190,7 +1190,7 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr,
|
|||
msg = taosMemoryCalloc(1, msgSize);
|
||||
if (NULL == msg) {
|
||||
SCH_TASK_ELOG("calloc %d failed", msgSize);
|
||||
SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
SCH_ERR_RET(terrno);
|
||||
}
|
||||
|
||||
if (tSerializeSSubQueryMsg(msg, msgSize, &qMsg) < 0) {
|
||||
|
@ -1228,7 +1228,7 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr,
|
|||
msg = taosMemoryCalloc(1, msgSize);
|
||||
if (NULL == msg) {
|
||||
SCH_TASK_ELOG("calloc %d failed", msgSize);
|
||||
SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
SCH_ERR_RET(terrno);
|
||||
}
|
||||
|
||||
if (tSerializeSResFetchReq(msg, msgSize, &req) < 0) {
|
||||
|
@ -1256,7 +1256,7 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr,
|
|||
msg = taosMemoryCalloc(1, msgSize);
|
||||
if (NULL == msg) {
|
||||
SCH_TASK_ELOG("calloc %d failed", msgSize);
|
||||
SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
SCH_ERR_RET(terrno);
|
||||
}
|
||||
|
||||
if (tSerializeSTaskDropReq(msg, msgSize, &qMsg) < 0) {
|
||||
|
@ -1283,7 +1283,7 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr,
|
|||
msg = taosMemoryCalloc(1, msgSize);
|
||||
if (NULL == msg) {
|
||||
SCH_JOB_ELOG("calloc %d failed", msgSize);
|
||||
SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
SCH_ERR_RET(terrno);
|
||||
}
|
||||
if (tSerializeSSchedulerHbReq(msg, msgSize, &req) < 0) {
|
||||
SCH_JOB_ELOG("tSerializeSSchedulerHbReq hbReq failed, size:%d", msgSize);
|
||||
|
@ -1314,7 +1314,7 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr,
|
|||
msg = taosMemoryCalloc(1, msgSize);
|
||||
if (NULL == msg) {
|
||||
SCH_TASK_ELOG("calloc %d failed", msgSize);
|
||||
SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
SCH_ERR_RET(terrno);
|
||||
}
|
||||
|
||||
if (tSerializeSTaskNotifyReq(msg, msgSize, &qMsg) < 0) {
|
||||
|
|
|
@ -1237,7 +1237,7 @@ _return:
|
|||
int32_t schAsyncLaunchTaskImpl(SSchJob *pJob, SSchTask *pTask) {
|
||||
SSchTaskCtx *param = taosMemoryCalloc(1, sizeof(SSchTaskCtx));
|
||||
if (NULL == param) {
|
||||
SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
SCH_ERR_RET(terrno);
|
||||
}
|
||||
|
||||
param->jobRid = pJob->refId;
|
||||
|
|
|
@ -213,7 +213,7 @@ int32_t rebuildDirFromCheckpoint(const char* path, int64_t chkpId, char** dst) {
|
|||
|
||||
char* state = taosMemoryCalloc(1, cap);
|
||||
if (state == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
nBytes = snprintf(state, cap, "%s%s%s", path, TD_DIRSEP, "state");
|
||||
|
@ -226,7 +226,7 @@ int32_t rebuildDirFromCheckpoint(const char* path, int64_t chkpId, char** dst) {
|
|||
char* chkp = taosMemoryCalloc(1, cap);
|
||||
if (chkp == NULL) {
|
||||
taosMemoryFree(state);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
nBytes = snprintf(chkp, cap, "%s%s%s%scheckpoint%" PRId64 "", path, TD_DIRSEP, "checkpoints", TD_DIRSEP, chkpId);
|
||||
|
@ -279,7 +279,7 @@ int32_t remoteChkp_readMetaData(char* path, SSChkpMetaOnS3** pMeta) {
|
|||
|
||||
char* metaPath = taosMemoryCalloc(1, cap);
|
||||
if (metaPath == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
int32_t n = snprintf(metaPath, cap, "%s%s%s", path, TD_DIRSEP, "META");
|
||||
|
@ -290,19 +290,19 @@ int32_t remoteChkp_readMetaData(char* path, SSChkpMetaOnS3** pMeta) {
|
|||
|
||||
pFile = taosOpenFile(path, TD_FILE_READ);
|
||||
if (pFile == NULL) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
goto _EXIT;
|
||||
}
|
||||
|
||||
char buf[256] = {0};
|
||||
if (taosReadFile(pFile, buf, sizeof(buf)) <= 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
goto _EXIT;
|
||||
}
|
||||
|
||||
SSChkpMetaOnS3* p = taosMemoryCalloc(1, sizeof(SSChkpMetaOnS3));
|
||||
if (p == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto _EXIT;
|
||||
}
|
||||
n = sscanf(buf, META_ON_S3_FORMATE, p->pCurrName, &p->currChkptId, p->pManifestName, &p->manifestChkptId,
|
||||
|
@ -334,7 +334,7 @@ int32_t remoteChkp_validAndCvtMeta(char* path, SSChkpMetaOnS3* pMeta, int64_t ch
|
|||
char* src = taosMemoryCalloc(1, cap);
|
||||
char* dst = taosMemoryCalloc(1, cap);
|
||||
if (src == NULL || dst == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto _EXIT;
|
||||
}
|
||||
|
||||
|
@ -357,7 +357,7 @@ int32_t remoteChkp_validAndCvtMeta(char* path, SSChkpMetaOnS3* pMeta, int64_t ch
|
|||
}
|
||||
|
||||
if (taosStatFile(src, NULL, NULL, NULL) != 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
goto _EXIT;
|
||||
}
|
||||
|
||||
|
@ -367,8 +367,8 @@ int32_t remoteChkp_validAndCvtMeta(char* path, SSChkpMetaOnS3* pMeta, int64_t ch
|
|||
goto _EXIT;
|
||||
}
|
||||
|
||||
if (taosRenameFile(src, dst) != 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = taosRenameFile(src, dst);
|
||||
if (code != 0) {
|
||||
goto _EXIT;
|
||||
}
|
||||
|
||||
|
@ -400,7 +400,7 @@ int32_t remoteChkpGetDelFile(char* path, SArray* toDel) {
|
|||
char* p = taosMemoryCalloc(1, cap);
|
||||
if (p == NULL) {
|
||||
taosMemoryFree(pMeta);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
nBytes = snprintf(p, cap, "%s_%" PRId64 "", key, pMeta->currChkptId);
|
||||
|
@ -494,7 +494,7 @@ int32_t rebuildFromRemoteChkp_s3(const char* key, char* chkpPath, int64_t chkpId
|
|||
|
||||
char* defaultTmp = taosMemoryCalloc(1, cap);
|
||||
if (defaultTmp == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
int32_t nBytes = snprintf(defaultPath, cap, "%s%s", defaultPath, "_tmp");
|
||||
|
@ -507,7 +507,6 @@ int32_t rebuildFromRemoteChkp_s3(const char* key, char* chkpPath, int64_t chkpId
|
|||
if (taosIsDir(defaultPath)) {
|
||||
code = taosRenameFile(defaultPath, defaultTmp);
|
||||
if (code != 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
goto _EXIT;
|
||||
} else {
|
||||
rename = 1;
|
||||
|
@ -592,14 +591,13 @@ int32_t backendFileCopyFilesImpl(const char* src, const char* dst) {
|
|||
if (srcName == NULL || dstName == NULL) {
|
||||
taosMemoryFree(srcName);
|
||||
taosMemoryFree(dstName);
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return code;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
// copy file to dst
|
||||
TdDirPtr pDir = taosOpenDir(src);
|
||||
if (pDir == NULL) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
goto _ERROR;
|
||||
}
|
||||
|
||||
|
@ -711,7 +709,7 @@ int32_t restoreCheckpointData(const char* path, const char* key, int64_t chkptId
|
|||
checkpointPath = taosMemoryCalloc(1, cap);
|
||||
checkpointRoot = taosMemoryCalloc(1, cap);
|
||||
if (prefixPath == NULL || defaultPath == NULL || checkpointPath == NULL || checkpointRoot == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto _EXIT;
|
||||
}
|
||||
|
||||
|
@ -904,7 +902,7 @@ _EXIT:
|
|||
streamMutexDestroy(&pHandle->mutex);
|
||||
streamMutexDestroy(&pHandle->cfMutex);
|
||||
taosHashCleanup(pHandle->cfInst);
|
||||
(void)tdListFree(pHandle->list);
|
||||
pHandle->list = tdListFree(pHandle->list);
|
||||
taosMemoryFree(pHandle);
|
||||
stDebug("failed to init stream backend at %s", backendPath);
|
||||
taosMemoryFree(backendPath);
|
||||
|
@ -937,7 +935,7 @@ void streamBackendCleanup(void* arg) {
|
|||
head = tdListPopHead(pHandle->list);
|
||||
}
|
||||
|
||||
(void)tdListFree(pHandle->list);
|
||||
pHandle->list = tdListFree(pHandle->list);
|
||||
streamMutexDestroy(&pHandle->mutex);
|
||||
|
||||
streamMutexDestroy(&pHandle->cfMutex);
|
||||
|
@ -1343,7 +1341,7 @@ int32_t chkpGetAllDbCfHandle2(STaskDbWrapper* pBackend, rocksdb_column_family_ha
|
|||
|
||||
rocksdb_column_family_handle_t** ppCf = taosMemoryCalloc(nCf, sizeof(rocksdb_column_family_handle_t*));
|
||||
if (ppCf == NULL) {
|
||||
TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _exception);
|
||||
TAOS_CHECK_GOTO(terrno, NULL, _exception);
|
||||
}
|
||||
for (int i = 0; i < nCf; i++) {
|
||||
ppCf[i] = taosArrayGetP(pHandle, i);
|
||||
|
@ -1410,7 +1408,7 @@ int32_t chkpPreBuildDir(char* path, int64_t chkpId, char** chkpDir, char** chkpI
|
|||
char* pChkpDir = taosMemoryCalloc(1, cap);
|
||||
char* pChkpIdDir = taosMemoryCalloc(1, cap);
|
||||
if (pChkpDir == NULL || pChkpIdDir == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto _EXIT;
|
||||
}
|
||||
|
||||
|
@ -1428,7 +1426,7 @@ int32_t chkpPreBuildDir(char* path, int64_t chkpId, char** chkpDir, char** chkpI
|
|||
|
||||
code = taosMulModeMkDir(pChkpDir, 0755, true);
|
||||
if (code != 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
stError("failed to prepare checkpoint dir, path:%s, reason:%s", path, tstrerror(code));
|
||||
goto _EXIT;
|
||||
}
|
||||
|
@ -1587,7 +1585,7 @@ int32_t chkpLoadExtraInfo(char* pChkpIdDir, int64_t* chkpId, int64_t* processId)
|
|||
int32_t cap = len + 64;
|
||||
char* pDst = taosMemoryCalloc(1, cap);
|
||||
if (pDst == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
stError("failed to alloc memory to load extra info, dir:%s", pChkpIdDir);
|
||||
goto _EXIT;
|
||||
}
|
||||
|
@ -1604,12 +1602,12 @@ int32_t chkpLoadExtraInfo(char* pChkpIdDir, int64_t* chkpId, int64_t* processId)
|
|||
// compatible with previous version
|
||||
*processId = -1;
|
||||
code = 0;
|
||||
stWarn("failed to open file to load extra info, file:%s, reason:%s", pDst, tstrerror(TAOS_SYSTEM_ERROR(errno)));
|
||||
stWarn("failed to open file to load extra info, file:%s, reason:%s", pDst, tstrerror(terrno));
|
||||
goto _EXIT;
|
||||
}
|
||||
|
||||
if (taosReadFile(pFile, buf, sizeof(buf)) <= 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
stError("failed to read file to load extra info, file:%s, reason:%s", pDst, tstrerror(code));
|
||||
goto _EXIT;
|
||||
}
|
||||
|
@ -1643,7 +1641,7 @@ int32_t chkpAddExtraInfo(char* pChkpIdDir, int64_t chkpId, int64_t processId) {
|
|||
int32_t cap = len + 64;
|
||||
char* pDst = taosMemoryCalloc(1, cap);
|
||||
if (pDst == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
stError("failed to alloc memory to add extra info, dir:%s", pChkpIdDir);
|
||||
goto _EXIT;
|
||||
}
|
||||
|
@ -1657,7 +1655,7 @@ int32_t chkpAddExtraInfo(char* pChkpIdDir, int64_t chkpId, int64_t processId) {
|
|||
|
||||
pFile = taosOpenFile(pDst, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC);
|
||||
if (pFile == NULL) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
stError("failed to open file to add extra info, file:%s, reason:%s", pDst, tstrerror(code));
|
||||
goto _EXIT;
|
||||
}
|
||||
|
@ -1670,7 +1668,7 @@ int32_t chkpAddExtraInfo(char* pChkpIdDir, int64_t chkpId, int64_t processId) {
|
|||
}
|
||||
|
||||
if (nBytes != taosWriteFile(pFile, buf, nBytes)) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
stError("failed to write file to add extra info, file:%s, reason:%s", pDst, tstrerror(code));
|
||||
goto _EXIT;
|
||||
}
|
||||
|
@ -2119,7 +2117,7 @@ int32_t valueEncode(void* value, int32_t vlen, int64_t ttl, char** dest) {
|
|||
if (vlen > 512) {
|
||||
dst = taosMemoryCalloc(1, vlen + 128);
|
||||
if (dst == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
int32_t dstCap = vlen + 128;
|
||||
int32_t compressedSize = LZ4_compress_default((char*)value, dst, vlen, dstCap);
|
||||
|
@ -2134,7 +2132,7 @@ int32_t valueEncode(void* value, int32_t vlen, int64_t ttl, char** dest) {
|
|||
size_t size = sizeof(key.unixTimestamp) + sizeof(key.len) + sizeof(key.rawLen) + sizeof(key.compress) + key.len;
|
||||
char* p = taosMemoryCalloc(1, size);
|
||||
if (p == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto _exception;
|
||||
}
|
||||
char* buf = p;
|
||||
|
@ -2210,7 +2208,7 @@ int32_t valueDecode(void* value, int32_t vlen, int64_t* ttl, char** dest) {
|
|||
}
|
||||
pOutput = taosMemoryCalloc(1, key.rawLen);
|
||||
if (pOutput == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto _EXCEPT;
|
||||
}
|
||||
|
||||
|
@ -2530,7 +2528,7 @@ int32_t taskDbBuildFullPath(char* path, char* key, char** dbFullPath, char** sta
|
|||
int32_t code = 0;
|
||||
char* statePath = taosMemoryCalloc(1, strlen(path) + 128);
|
||||
if (statePath == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
sprintf(statePath, "%s%s%s", path, TD_DIRSEP, key);
|
||||
|
@ -2547,7 +2545,7 @@ int32_t taskDbBuildFullPath(char* path, char* key, char** dbFullPath, char** sta
|
|||
char* dbPath = taosMemoryCalloc(1, strlen(statePath) + 128);
|
||||
if (dbPath == NULL) {
|
||||
taosMemoryFree(statePath);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
sprintf(dbPath, "%s%s%s", statePath, TD_DIRSEP, "state");
|
||||
|
@ -2765,7 +2763,7 @@ int32_t taskDbGenChkpUploadData__rsync(STaskDbWrapper* pDb, int64_t chkpId, char
|
|||
char* buf = taosMemoryCalloc(1, cap);
|
||||
if (buf == NULL) {
|
||||
(void)taosReleaseRef(taskDbWrapperId, refId);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
nBytes =
|
||||
|
@ -2795,7 +2793,7 @@ int32_t taskDbGenChkpUploadData__s3(STaskDbWrapper* pDb, void* bkdChkpMgt, int64
|
|||
|
||||
char* temp = taosMemoryCalloc(1, cap);
|
||||
if (temp == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
int32_t nBytes = snprintf(temp, cap, "%s%s%s%" PRId64, pDb->path, TD_DIRSEP, "tmp", chkpId);
|
||||
|
@ -4555,7 +4553,7 @@ int32_t compareHashTableImpl(SHashObj* p1, SHashObj* p2, SArray* diff) {
|
|||
if (!isBkdDataMeta(name, len) && !taosHashGet(p1, name, len)) {
|
||||
char* fname = taosMemoryCalloc(1, len + 1);
|
||||
if (fname == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
(void)strncpy(fname, name, len);
|
||||
if (taosArrayPush(diff, &fname) == NULL) {
|
||||
|
@ -4666,7 +4664,7 @@ int32_t dbChkpGetDelta(SDbChkp* p, int64_t chkpId, SArray* list) {
|
|||
TdDirPtr pDir = taosOpenDir(p->buf);
|
||||
if (pDir == NULL) {
|
||||
(void)taosThreadRwlockUnlock(&p->rwLock);
|
||||
return TAOS_SYSTEM_ERROR(errno);
|
||||
return terrno;
|
||||
}
|
||||
|
||||
TdDirEntryPtr de = NULL;
|
||||
|
@ -4716,7 +4714,7 @@ int32_t dbChkpGetDelta(SDbChkp* p, int64_t chkpId, SArray* list) {
|
|||
char* fname = taosMemoryCalloc(1, len + 1);
|
||||
if (fname == NULL) {
|
||||
(void)taosThreadRwlockUnlock(&p->rwLock);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
(void)strncpy(fname, name, len);
|
||||
|
@ -4767,7 +4765,7 @@ int32_t dbChkpCreate(char* path, int64_t initChkpId, SDbChkp** ppChkp) {
|
|||
int32_t code = 0;
|
||||
SDbChkp* p = taosMemoryCalloc(1, sizeof(SDbChkp));
|
||||
if (p == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto _EXIT;
|
||||
}
|
||||
|
||||
|
@ -4784,7 +4782,7 @@ int32_t dbChkpCreate(char* path, int64_t initChkpId, SDbChkp** ppChkp) {
|
|||
p->len = strlen(path) + 128;
|
||||
p->buf = taosMemoryCalloc(1, p->len);
|
||||
if (p->buf == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto _EXIT;
|
||||
}
|
||||
|
||||
|
@ -4861,7 +4859,7 @@ int32_t dbChkpDumpTo(SDbChkp* p, char* dname, SArray* list) {
|
|||
|
||||
char* buffer = taosMemoryCalloc(4, cap);
|
||||
if (buffer == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto _ERROR;
|
||||
}
|
||||
|
||||
|
@ -4974,7 +4972,7 @@ int32_t dbChkpDumpTo(SDbChkp* p, char* dname, SArray* list) {
|
|||
}
|
||||
|
||||
if (taosCopyFile(srcBuf, dstBuf) < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
stError("failed to copy file from %s to %s, reason:%s", srcBuf, dstBuf, tstrerror(code));
|
||||
goto _ERROR;
|
||||
}
|
||||
|
@ -4987,7 +4985,7 @@ int32_t dbChkpDumpTo(SDbChkp* p, char* dname, SArray* list) {
|
|||
|
||||
TdFilePtr pFile = taosOpenFile(dstDir, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC);
|
||||
if (pFile == NULL) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
stError("chkp failed to create meta file: %s, reason:%s", dstDir, tstrerror(code));
|
||||
goto _ERROR;
|
||||
}
|
||||
|
@ -5004,7 +5002,7 @@ int32_t dbChkpDumpTo(SDbChkp* p, char* dname, SArray* list) {
|
|||
|
||||
nBytes = taosWriteFile(pFile, content, strlen(content));
|
||||
if (nBytes != strlen(content)) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
code = terrno;
|
||||
stError("chkp failed to write meta file: %s,reason:%s", dstDir, tstrerror(code));
|
||||
(void)taosCloseFile(&pFile);
|
||||
goto _ERROR;
|
||||
|
@ -5026,8 +5024,7 @@ int32_t bkdMgtCreate(char* path, SBkdMgt** mgt) {
|
|||
int32_t code = 0;
|
||||
SBkdMgt* p = taosMemoryCalloc(1, sizeof(SBkdMgt));
|
||||
if (p == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return code;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
p->pDbChkpTbl = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK);
|
||||
|
@ -5081,7 +5078,7 @@ int32_t bkdMgtGetDelta(SBkdMgt* bm, char* taskId, int64_t chkpId, SArray* list,
|
|||
char* path = taosMemoryCalloc(1, cap);
|
||||
if (path == NULL) {
|
||||
(void)taosThreadRwlockUnlock(&bm->rwLock);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
int32_t nBytes = snprintf(path, cap, "%s%s%s", bm->path, TD_DIRSEP, taskId);
|
||||
|
|
|
@ -49,7 +49,7 @@ int32_t createChkptTriggerBlock(SStreamTask* pTask, int32_t checkpointType, int6
|
|||
SSDataBlock* pBlock = taosMemoryCalloc(1, sizeof(SSDataBlock));
|
||||
if (pBlock == NULL) {
|
||||
taosFreeQitem(pChkpoint);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
pBlock->info.type = STREAM_CHECKPOINT;
|
||||
|
@ -704,7 +704,7 @@ static int32_t getCheckpointDataMeta(const char* id, const char* path, SArray* l
|
|||
|
||||
char* filePath = taosMemoryCalloc(1, cap);
|
||||
if (filePath == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
int32_t nBytes = snprintf(filePath, cap, "%s%s%s", path, TD_DIRSEP, "META_TMP");
|
||||
|
@ -1244,7 +1244,7 @@ static int32_t uploadCheckpointToS3(const char* id, const char* path) {
|
|||
|
||||
TdDirPtr pDir = taosOpenDir(path);
|
||||
if (pDir == NULL) {
|
||||
return TAOS_SYSTEM_ERROR(errno);
|
||||
return terrno;
|
||||
}
|
||||
|
||||
TdDirEntryPtr de = NULL;
|
||||
|
@ -1296,7 +1296,7 @@ int32_t downloadCheckpointByNameS3(const char* id, const char* fname, const char
|
|||
|
||||
char* buf = taosMemoryCalloc(1, cap);
|
||||
if (buf == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
nBytes = snprintf(buf, cap, "%s/%s", id, fname);
|
||||
|
|
|
@ -143,7 +143,7 @@ static int32_t buildStreamRetrieveReq(SStreamTask* pTask, const SSDataBlock* pBl
|
|||
int32_t len = sizeof(SRetrieveTableRsp) + blockGetEncodeSize(pBlock) + PAYLOAD_PREFIX_LEN;
|
||||
|
||||
pRetrieve = taosMemoryCalloc(1, len);
|
||||
if (pRetrieve == NULL) return TSDB_CODE_OUT_OF_MEMORY;
|
||||
if (pRetrieve == NULL) return terrno;
|
||||
|
||||
int32_t numOfCols = taosArrayGetSize(pBlock->pDataBlock);
|
||||
pRetrieve->useconds = 0;
|
||||
|
@ -1486,8 +1486,6 @@ int32_t streamProcessDispatchRsp(SStreamTask* pTask, SStreamDispatchRsp* pRsp, i
|
|||
int32_t numOfFailed = 0;
|
||||
bool triggerDispatchRsp = false;
|
||||
|
||||
taosMsleep(500);
|
||||
|
||||
// we only set the dispatch msg info for current checkpoint trans
|
||||
streamMutexLock(&pTask->lock);
|
||||
triggerDispatchRsp = (streamTaskGetStatus(pTask).state == TASK_STATUS__CK) &&
|
||||
|
|
|
@ -314,7 +314,7 @@ int32_t createMetaHbInfo(int64_t* pRid, SMetaHbInfo** pRes) {
|
|||
*pRes = NULL;
|
||||
SMetaHbInfo* pInfo = taosMemoryCalloc(1, sizeof(SMetaHbInfo));
|
||||
if (pInfo == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
pInfo->hbTmr = taosTmrStart(streamMetaHbToMnode, META_HB_CHECK_INTERVAL, pRid, streamTimer);
|
||||
|
|
|
@ -357,13 +357,13 @@ int32_t streamMetaOpen(const char* path, void* ahandle, FTaskBuild buildTaskFn,
|
|||
SStreamMeta* pMeta = taosMemoryCalloc(1, sizeof(SStreamMeta));
|
||||
if (pMeta == NULL) {
|
||||
stError("vgId:%d failed to prepare stream meta, alloc size:%" PRIzu ", out of memory", vgId, sizeof(SStreamMeta));
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
int32_t len = strlen(path) + 64;
|
||||
char* tpath = taosMemoryCalloc(1, len);
|
||||
if (tpath == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto _err;
|
||||
}
|
||||
|
||||
|
@ -630,7 +630,7 @@ int32_t streamMetaSaveTask(SStreamMeta* pMeta, SStreamTask* pTask) {
|
|||
|
||||
buf = taosMemoryCalloc(1, len);
|
||||
if (buf == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
if (pTask->ver < SSTREAM_TASK_SUBTABLE_CHANGED_VER) {
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue