Merge branch '3.0' of https://github.com/taosdata/TDengine into fix/TD-30837
This commit is contained in:
commit
7c32cc7796
|
@ -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 及以上版本。
|
||||
|
||||
## 安装
|
||||
|
||||
|
|
|
@ -195,14 +195,14 @@ DLL_EXPORT int taos_stmt_affected_rows_once(TAOS_STMT *stmt);
|
|||
|
||||
typedef void TAOS_STMT2;
|
||||
|
||||
typedef enum {
|
||||
typedef enum TAOS_FIELD_T {
|
||||
TAOS_FIELD_COL = 1,
|
||||
TAOS_FIELD_TAG,
|
||||
TAOS_FIELD_QUERY,
|
||||
TAOS_FIELD_TBNAME,
|
||||
} TAOS_FIELD_T;
|
||||
|
||||
typedef struct {
|
||||
typedef struct TAOS_STMT2_OPTION {
|
||||
int64_t reqid;
|
||||
bool singleStbInsert;
|
||||
bool singleTableBindOnce;
|
||||
|
@ -210,7 +210,7 @@ typedef struct {
|
|||
void *userdata;
|
||||
} TAOS_STMT2_OPTION;
|
||||
|
||||
typedef struct {
|
||||
typedef struct TAOS_STMT2_BIND {
|
||||
int buffer_type;
|
||||
void *buffer;
|
||||
int32_t *length;
|
||||
|
@ -218,7 +218,7 @@ typedef struct {
|
|||
int num;
|
||||
} TAOS_STMT2_BIND;
|
||||
|
||||
typedef struct {
|
||||
typedef struct TAOS_STMT2_BINDV {
|
||||
int count;
|
||||
char **tbnames;
|
||||
TAOS_STMT2_BIND **tags;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -348,6 +348,8 @@ extern int32_t (*queryBuildMsg[TDMT_MAX])(void* input, char** msg, int32_t msgSi
|
|||
void* (*mallocFp)(int64_t));
|
||||
extern int32_t (*queryProcessMsgRsp[TDMT_MAX])(void* output, char* msg, int32_t msgSize);
|
||||
|
||||
void* getTaskPoolWorkerCb();
|
||||
|
||||
#define SET_META_TYPE_NULL(t) (t) = META_TYPE_NULL_TABLE
|
||||
#define SET_META_TYPE_CTABLE(t) (t) = META_TYPE_CTABLE
|
||||
#define SET_META_TYPE_TABLE(t) (t) = META_TYPE_TABLE
|
||||
|
|
|
@ -72,6 +72,7 @@ typedef struct SQWMsg {
|
|||
int32_t msgLen;
|
||||
SQWMsgInfo msgInfo;
|
||||
SRpcHandleInfo connInfo;
|
||||
void *pWorkerCb;
|
||||
} SQWMsg;
|
||||
|
||||
int32_t qWorkerInit(int8_t nodeType, int32_t nodeId, void **qWorkerMgmt, const SMsgCb *pMsgCb);
|
||||
|
|
|
@ -67,6 +67,7 @@ typedef struct SSchedulerReq {
|
|||
SExecResult* pExecRes;
|
||||
void** pFetchRes;
|
||||
int8_t source;
|
||||
void* pWorkerCb;
|
||||
} SSchedulerReq;
|
||||
|
||||
int32_t schedulerInit(void);
|
||||
|
|
|
@ -636,7 +636,7 @@ typedef struct SCheckpointConsensusInfo {
|
|||
int64_t streamId;
|
||||
} SCheckpointConsensusInfo;
|
||||
|
||||
int32_t streamSetupScheduleTrigger(SStreamTask* pTask);
|
||||
void streamSetupScheduleTrigger(SStreamTask* pTask);
|
||||
|
||||
// dispatch related
|
||||
int32_t streamProcessDispatchMsg(SStreamTask* pTask, SStreamDispatchReq* pReq, SRpcMsg* pMsg);
|
||||
|
@ -793,6 +793,7 @@ void streamTaskSetReqConsenChkptId(SStreamTask* pTask, int64_t ts);
|
|||
int32_t streamTimerGetInstance(tmr_h* pTmr);
|
||||
void streamTmrReset(TAOS_TMR_CALLBACK fp, int32_t mseconds, void* param, void* handle, tmr_h* pTmrId, int32_t vgId,
|
||||
const char* pMsg);
|
||||
void streamTmrStop(tmr_h tmrId);
|
||||
|
||||
// checkpoint
|
||||
int32_t streamProcessCheckpointSourceReq(SStreamTask* pTask, SStreamCheckpointSourceReq* pReq);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -841,6 +841,7 @@ int32_t scheduleQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList
|
|||
.chkKillParam = (void*)pRequest->self,
|
||||
.pExecRes = &res,
|
||||
.source = pRequest->source,
|
||||
.pWorkerCb = getTaskPoolWorkerCb(),
|
||||
};
|
||||
|
||||
int32_t code = schedulerExecJob(&req, &pRequest->body.queryJob);
|
||||
|
@ -1067,6 +1068,7 @@ static int32_t createResultBlock(TAOS_RES* pRes, int32_t numOfRows, SSDataBlock*
|
|||
TAOS_ROW pRow = taos_fetch_row(pRes);
|
||||
if (NULL == pRow[0] || NULL == pRow[1] || NULL == pRow[2]) {
|
||||
tscError("invalid data from vnode");
|
||||
blockDataDestroy(*pBlock);
|
||||
return TSDB_CODE_TSC_INTERNAL_ERROR;
|
||||
}
|
||||
int64_t ts = *(int64_t*)pRow[0];
|
||||
|
@ -1101,8 +1103,11 @@ void postSubQueryFetchCb(void* param, TAOS_RES* res, int32_t rowNum) {
|
|||
}
|
||||
|
||||
SSDataBlock* pBlock = NULL;
|
||||
if (TSDB_CODE_SUCCESS != createResultBlock(res, rowNum, &pBlock)) {
|
||||
tscError("0x%" PRIx64 ", create result block failed,QID:0x%" PRIx64, pRequest->self, pRequest->requestId);
|
||||
pRequest->code = createResultBlock(res, rowNum, &pBlock);
|
||||
if (TSDB_CODE_SUCCESS != pRequest->code) {
|
||||
tscError("0x%" PRIx64 ", create result block failed,QID:0x%" PRIx64 " %s", pRequest->self, pRequest->requestId,
|
||||
tstrerror(pRequest->code));
|
||||
returnToUser(pRequest);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1358,6 +1363,7 @@ static int32_t asyncExecSchQuery(SRequestObj* pRequest, SQuery* pQuery, SMetaDat
|
|||
.chkKillParam = (void*)pRequest->self,
|
||||
.pExecRes = NULL,
|
||||
.source = pRequest->source,
|
||||
.pWorkerCb = getTaskPoolWorkerCb(),
|
||||
};
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = schedulerExecJob(&req, &pRequest->body.queryJob);
|
||||
|
|
|
@ -1363,6 +1363,19 @@ void restartAsyncQuery(SRequestObj *pRequest, int32_t code) {
|
|||
doAsyncQuery(pUserReq, true);
|
||||
}
|
||||
|
||||
typedef struct SAsyncFetchParam {
|
||||
SRequestObj *pReq;
|
||||
__taos_async_fn_t fp;
|
||||
void *param;
|
||||
} SAsyncFetchParam;
|
||||
|
||||
static int32_t doAsyncFetch(void* pParam) {
|
||||
SAsyncFetchParam *param = pParam;
|
||||
taosAsyncFetchImpl(param->pReq, param->fp, param->param);
|
||||
taosMemoryFree(param);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
void taos_fetch_rows_a(TAOS_RES *res, __taos_async_fn_t fp, void *param) {
|
||||
if (res == NULL || fp == NULL) {
|
||||
tscError("taos_fetch_rows_a invalid paras");
|
||||
|
@ -1370,6 +1383,7 @@ void taos_fetch_rows_a(TAOS_RES *res, __taos_async_fn_t fp, void *param) {
|
|||
}
|
||||
if (!TD_RES_QUERY(res)) {
|
||||
tscError("taos_fetch_rows_a res is NULL");
|
||||
fp(param, res, TSDB_CODE_APP_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1379,7 +1393,20 @@ void taos_fetch_rows_a(TAOS_RES *res, __taos_async_fn_t fp, void *param) {
|
|||
return;
|
||||
}
|
||||
|
||||
taosAsyncFetchImpl(pRequest, fp, param);
|
||||
SAsyncFetchParam* pParam = taosMemoryCalloc(1, sizeof(SAsyncFetchParam));
|
||||
if (!pParam) {
|
||||
fp(param, res, terrno);
|
||||
return;
|
||||
}
|
||||
pParam->pReq = pRequest;
|
||||
pParam->fp = fp;
|
||||
pParam->param = param;
|
||||
int32_t code = taosAsyncExec(doAsyncFetch, pParam, NULL);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
taosMemoryFree(pParam);
|
||||
fp(param, res, code);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void taos_fetch_raw_block_a(TAOS_RES *res, __taos_async_fn_t fp, void *param) {
|
||||
|
|
|
@ -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) {
|
||||
|
@ -367,7 +367,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;
|
||||
}
|
||||
|
||||
|
@ -397,7 +397,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) {
|
||||
|
@ -409,7 +409,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;
|
||||
}
|
||||
|
||||
|
@ -549,7 +549,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;
|
||||
|
@ -606,7 +606,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;
|
||||
}
|
||||
(void)taosCloseFile(&(pClient->pFile));
|
||||
|
@ -614,7 +614,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;
|
||||
}
|
||||
|
@ -821,9 +821,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) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -171,8 +171,9 @@ int32_t epsetToStr(const SEpSet* pEpSet, char* pBuf, int32_t cap) {
|
|||
ret = snprintf(pBuf + nwrite, cap, "}, inUse:%d", pEpSet->inUse);
|
||||
if (ret <= 0 || ret >= cap) {
|
||||
return TSDB_CODE_OUT_OF_BUFFER;
|
||||
} else {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t taosGenCrashJsonMsg(int signum, char** pMsg, int64_t clusterId, int64_t startTime) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -114,7 +114,7 @@ int32_t mndDropStreamByDb(SMnode *pMnode, STrans *pTrans, SDbObj *pDb);
|
|||
int32_t mndPersistStream(STrans *pTrans, SStreamObj *pStream);
|
||||
int32_t mndStreamRegisterTrans(STrans *pTrans, const char *pTransName, int64_t streamId);
|
||||
int32_t mndStreamClearFinishedTrans(SMnode *pMnode, int32_t *pNumOfActiveChkpt);
|
||||
bool mndStreamTransConflictCheck(SMnode *pMnode, int64_t streamId, const char *pTransName, bool lock);
|
||||
int32_t mndStreamTransConflictCheck(SMnode *pMnode, int64_t streamId, const char *pTransName, bool lock);
|
||||
int32_t mndStreamGetRelTrans(SMnode *pMnode, int64_t streamId);
|
||||
|
||||
int32_t mndGetNumOfStreams(SMnode *pMnode, char *dbName, int32_t *pNumOfStreams);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -19,8 +19,8 @@
|
|||
#include "systable.h"
|
||||
#include "mndUser.h"
|
||||
|
||||
#define SHOW_STEP_SIZE 100
|
||||
#define SHOW_COLS_STEP_SIZE 4096
|
||||
#define SHOW_STEP_SIZE 100
|
||||
#define SHOW_COLS_STEP_SIZE 4096
|
||||
#define SHOW_PRIVILEGES_STEP_SIZE 2048
|
||||
|
||||
static SShowObj *mndCreateShowObj(SMnode *pMnode, SRetrieveTableReq *pReq);
|
||||
|
|
|
@ -63,8 +63,8 @@ static int32_t mndProcessCheckpointReport(SRpcMsg *pReq);
|
|||
static int32_t mndProcessConsensusInTmr(SRpcMsg *pMsg);
|
||||
static void doSendQuickRsp(SRpcHandleInfo *pInfo, int32_t msgSize, int32_t vgId, int32_t code);
|
||||
static int32_t mndProcessDropOrphanTaskReq(SRpcMsg* pReq);
|
||||
|
||||
static SVgroupChangeInfo mndFindChangedNodeInfo(SMnode *pMnode, const SArray *pPrevNodeList, const SArray *pNodeList);
|
||||
static int32_t mndFindChangedNodeInfo(SMnode *pMnode, const SArray *pPrevNodeList, const SArray *pNodeList, SVgroupChangeInfo* pInfo);
|
||||
static void mndDestroyVgroupChangeInfo(SVgroupChangeInfo *pInfo);
|
||||
|
||||
static void addAllStreamTasksIntoBuf(SMnode *pMnode, SStreamExecInfo *pExecInfo);
|
||||
static void removeExpiredNodeInfo(const SArray *pNodeSnapshot);
|
||||
|
@ -220,7 +220,7 @@ STREAM_DECODE_OVER:
|
|||
taosMemoryFreeClear(buf);
|
||||
if (terrno != TSDB_CODE_SUCCESS) {
|
||||
char *p = (pStream == NULL) ? "null" : pStream->name;
|
||||
mError("stream:%s, failed to decode from raw:%p since %s", p, pRaw, terrstr());
|
||||
mError("stream:%s, failed to decode from raw:%p since %s", p, pRaw, tstrerror(terrno));
|
||||
taosMemoryFreeClear(pRow);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -282,9 +282,9 @@ int32_t mndStreamSeqActionUpdate(SSdb *pSdb, SStreamSeq *pOldStream, SStreamSeq
|
|||
static int32_t mndCheckCreateStreamReq(SCMCreateStreamReq *pCreate) {
|
||||
if (pCreate->name[0] == 0 || pCreate->sql == NULL || pCreate->sql[0] == 0 || pCreate->sourceDB[0] == 0 ||
|
||||
pCreate->targetStbFullName[0] == 0) {
|
||||
return terrno = TSDB_CODE_MND_INVALID_STREAM_OPTION;
|
||||
return TSDB_CODE_MND_INVALID_STREAM_OPTION;
|
||||
}
|
||||
return 0;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t createSchemaByFields(const SArray *pFields, SSchemaWrapper *pWrapper) {
|
||||
|
@ -366,8 +366,8 @@ static int32_t mndBuildStreamObjFromCreateReq(SMnode *pMnode, SStreamObj *pObj,
|
|||
memcpy(pObj->sourceDb, pCreate->sourceDB, TSDB_DB_FNAME_LEN);
|
||||
SDbObj *pSourceDb = mndAcquireDb(pMnode, pCreate->sourceDB);
|
||||
if (pSourceDb == NULL) {
|
||||
mInfo("stream:%s failed to create, source db %s not exist since %s", pCreate->name, pObj->sourceDb, terrstr());
|
||||
code = terrno;
|
||||
mInfo("stream:%s failed to create, source db %s not exist since %s", pCreate->name, pObj->sourceDb, tstrerror(code));
|
||||
goto FAIL;
|
||||
}
|
||||
|
||||
|
@ -378,8 +378,8 @@ static int32_t mndBuildStreamObjFromCreateReq(SMnode *pMnode, SStreamObj *pObj,
|
|||
|
||||
SDbObj *pTargetDb = mndAcquireDbByStb(pMnode, pObj->targetSTbName);
|
||||
if (pTargetDb == NULL) {
|
||||
mError("stream:%s failed to create, target db %s not exist since %s", pCreate->name, pObj->targetDb, terrstr());
|
||||
code = terrno;
|
||||
mError("stream:%s failed to create, target db %s not exist since %s", pCreate->name, pObj->targetDb, tstrerror(code));
|
||||
goto FAIL;
|
||||
}
|
||||
|
||||
|
@ -543,8 +543,7 @@ int32_t mndPersistTaskDeployReq(STrans *pTrans, SStreamTask *pTask) {
|
|||
code = tEncodeStreamTask(&encoder, pTask);
|
||||
tEncoderClear(&encoder);
|
||||
|
||||
if (code == -1) {
|
||||
code = TSDB_CODE_INVALID_PARA;
|
||||
if (code != 0) {
|
||||
mError("failed to encode stream task, code:%s", tstrerror(code));
|
||||
taosMemoryFree(buf);
|
||||
return code;
|
||||
|
@ -616,8 +615,8 @@ int32_t mndPersistStream(STrans *pTrans, SStreamObj *pStream) {
|
|||
static int32_t mndCreateStbForStream(SMnode *pMnode, STrans *pTrans, const SStreamObj *pStream, const char *user) {
|
||||
SStbObj *pStb = NULL;
|
||||
SDbObj *pDb = NULL;
|
||||
int32_t code = 0;
|
||||
int32_t lino = 0;
|
||||
int32_t code = 0;
|
||||
int32_t lino = 0;
|
||||
|
||||
SMCreateStbReq createReq = {0};
|
||||
tstrncpy(createReq.name, pStream->targetSTbName, TSDB_TABLE_FNAME_LEN);
|
||||
|
@ -669,19 +668,19 @@ static int32_t mndCreateStbForStream(SMnode *pMnode, STrans *pTrans, const SStre
|
|||
}
|
||||
}
|
||||
|
||||
if (mndCheckCreateStbReq(&createReq) != 0) {
|
||||
if ((code = mndCheckCreateStbReq(&createReq)) != 0) {
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
pStb = mndAcquireStb(pMnode, createReq.name);
|
||||
if (pStb != NULL) {
|
||||
terrno = TSDB_CODE_MND_STB_ALREADY_EXIST;
|
||||
code = TSDB_CODE_MND_STB_ALREADY_EXIST;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
pDb = mndAcquireDbByStb(pMnode, createReq.name);
|
||||
if (pDb == NULL) {
|
||||
terrno = TSDB_CODE_MND_DB_NOT_SELECTED;
|
||||
code = TSDB_CODE_MND_DB_NOT_SELECTED;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
|
@ -691,7 +690,7 @@ static int32_t mndCreateStbForStream(SMnode *pMnode, STrans *pTrans, const SStre
|
|||
}
|
||||
|
||||
if (pDb->cfg.numOfStables == 1 && numOfStbs != 0) {
|
||||
terrno = TSDB_CODE_MND_SINGLE_STB_MODE_DB;
|
||||
code = TSDB_CODE_MND_SINGLE_STB_MODE_DB;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
|
@ -720,7 +719,8 @@ _OVER:
|
|||
mndReleaseStb(pMnode, pStb);
|
||||
mndReleaseDb(pMnode, pDb);
|
||||
|
||||
mDebug("stream:%s failed to create dst stable:%s, code:%s", pStream->name, pStream->targetSTbName, tstrerror(terrno));
|
||||
mDebug("stream:%s failed to create dst stable:%s, line:%d code:%s", pStream->name, pStream->targetSTbName, lino,
|
||||
tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -742,16 +742,14 @@ static int32_t doStreamCheck(SMnode *pMnode, SStreamObj *pStreamObj) {
|
|||
mError("too many streams, no more than %d for each database, failed to create stream:%s", MND_STREAM_MAX_NUM,
|
||||
pStreamObj->name);
|
||||
sdbCancelFetch(pMnode->pSdb, pIter);
|
||||
terrno = TSDB_CODE_MND_TOO_MANY_STREAMS;
|
||||
return terrno;
|
||||
return TSDB_CODE_MND_TOO_MANY_STREAMS;
|
||||
}
|
||||
|
||||
if (pStream->targetStbUid == pStreamObj->targetStbUid) {
|
||||
mError("Cannot write the same stable as other stream:%s, failed to create stream:%s", pStream->name,
|
||||
pStreamObj->name);
|
||||
sdbCancelFetch(pMnode->pSdb, pIter);
|
||||
terrno = TSDB_CODE_MND_INVALID_TARGET_TABLE;
|
||||
return terrno;
|
||||
return TSDB_CODE_MND_INVALID_TARGET_TABLE;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -767,13 +765,11 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
|
|||
const char *pMsg = "create stream tasks on dnodes";
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
int32_t lino = 0;
|
||||
STrans *pTrans = NULL;
|
||||
|
||||
terrno = TSDB_CODE_SUCCESS;
|
||||
SCMCreateStreamReq createReq = {0};
|
||||
if (tDeserializeSCMCreateStreamReq(pReq->pCont, pReq->contLen, &createReq) != 0) {
|
||||
code = TSDB_CODE_INVALID_MSG;
|
||||
goto _OVER;
|
||||
}
|
||||
code = tDeserializeSCMCreateStreamReq(pReq->pCont, pReq->contLen, &createReq);
|
||||
TSDB_CHECK_CODE(code, lino, _OVER);
|
||||
|
||||
#ifdef WINDOWS
|
||||
code = TSDB_CODE_MND_INVALID_PLATFORM;
|
||||
|
@ -782,7 +778,7 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
|
|||
|
||||
mInfo("stream:%s, start to create stream, sql:%s", createReq.name, createReq.sql);
|
||||
if ((code = mndCheckCreateStreamReq(&createReq)) != 0) {
|
||||
mError("stream:%s, failed to create since %s", createReq.name, terrstr());
|
||||
mError("stream:%s, failed to create since %s", createReq.name, tstrerror(code));
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
|
@ -790,7 +786,9 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
|
|||
if (pStream != NULL && code == 0) {
|
||||
if (createReq.igExists) {
|
||||
mInfo("stream:%s, already exist, ignore exist is set", createReq.name);
|
||||
goto _OVER;
|
||||
mndReleaseStream(pMnode, pStream);
|
||||
tFreeSCMCreateStreamReq(&createReq);
|
||||
return code;
|
||||
} else {
|
||||
code = TSDB_CODE_MND_STREAM_ALREADY_EXIST;
|
||||
goto _OVER;
|
||||
|
@ -807,21 +805,20 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
|
|||
sqlLen = strlen(createReq.sql);
|
||||
sql = taosMemoryMalloc(sqlLen + 1);
|
||||
TSDB_CHECK_NULL(sql, code, lino, _OVER, terrno);
|
||||
|
||||
memset(sql, 0, sqlLen + 1);
|
||||
memcpy(sql, createReq.sql, sqlLen);
|
||||
}
|
||||
|
||||
// build stream obj from request
|
||||
if ((code = mndBuildStreamObjFromCreateReq(pMnode, &streamObj, &createReq)) < 0) {
|
||||
mError("stream:%s, failed to create since %s", createReq.name, terrstr());
|
||||
mError("stream:%s, failed to create since %s", createReq.name, tstrerror(code));
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
if ((code = doStreamCheck(pMnode, &streamObj)) < 0) {
|
||||
goto _OVER;
|
||||
}
|
||||
code = doStreamCheck(pMnode, &streamObj);
|
||||
TSDB_CHECK_CODE(code, lino, _OVER);
|
||||
|
||||
STrans *pTrans = NULL;
|
||||
code = doCreateTrans(pMnode, &streamObj, pReq, TRN_CONFLICT_DB, MND_STREAM_CREATE_NAME, pMsg, &pTrans);
|
||||
if (pTrans == NULL || code) {
|
||||
goto _OVER;
|
||||
|
@ -830,7 +827,7 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
|
|||
// create stb for stream
|
||||
if (createReq.createStb == STREAM_CREATE_STABLE_TRUE) {
|
||||
if ((code = mndCreateStbForStream(pMnode, pTrans, &streamObj, pReq->info.conn.user)) < 0) {
|
||||
mError("trans:%d, failed to create stb for stream %s since %s", pTrans->id, createReq.name, terrstr());
|
||||
mError("trans:%d, failed to create stb for stream %s since %s", pTrans->id, createReq.name, tstrerror(code));
|
||||
mndTransDrop(pTrans);
|
||||
goto _OVER;
|
||||
}
|
||||
|
@ -841,7 +838,7 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
|
|||
// schedule stream task for stream obj
|
||||
code = mndScheduleStream(pMnode, &streamObj, createReq.lastTs, createReq.pVgroupVerList);
|
||||
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||
mError("stream:%s, failed to schedule since %s", createReq.name, terrstr());
|
||||
mError("stream:%s, failed to schedule since %s", createReq.name, tstrerror(code));
|
||||
mndTransDrop(pTrans);
|
||||
goto _OVER;
|
||||
}
|
||||
|
@ -849,7 +846,7 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
|
|||
// add stream to trans
|
||||
code = mndPersistStream(pTrans, &streamObj);
|
||||
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||
mError("stream:%s, failed to persist since %s", createReq.name, terrstr());
|
||||
mError("stream:%s, failed to persist since %s", createReq.name, tstrerror(code));
|
||||
mndTransDrop(pTrans);
|
||||
goto _OVER;
|
||||
}
|
||||
|
@ -874,17 +871,13 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
|
|||
// execute creation
|
||||
code = mndTransPrepare(pMnode, pTrans);
|
||||
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||
mError("trans:%d, failed to prepare since %s", pTrans->id, terrstr());
|
||||
mError("trans:%d, failed to prepare since %s", pTrans->id, tstrerror(code));
|
||||
mndTransDrop(pTrans);
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
mndTransDrop(pTrans);
|
||||
|
||||
if (code == 0) {
|
||||
code = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||
}
|
||||
|
||||
SName dbname = {0};
|
||||
code = tNameFromString(&dbname, createReq.sourceDB, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
if (code) {
|
||||
|
@ -910,9 +903,10 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
|
|||
|
||||
_OVER:
|
||||
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||
mError("stream:%s, failed to create since %s", createReq.name, terrstr());
|
||||
mError("stream:%s, failed to create at line:%d since %s", createReq.name, lino, tstrerror(code));
|
||||
} else {
|
||||
mDebug("stream:%s create stream completed", createReq.name);
|
||||
code = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||
}
|
||||
|
||||
mndReleaseStream(pMnode, pStream);
|
||||
|
@ -1058,23 +1052,24 @@ static int32_t doSetCheckpointAction(SMnode *pMnode, STrans *pTrans, SStreamTask
|
|||
static int32_t mndProcessStreamCheckpointTrans(SMnode *pMnode, SStreamObj *pStream, int64_t checkpointId,
|
||||
int8_t mndTrigger, bool lock) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
bool conflict = false;
|
||||
int64_t ts = taosGetTimestampMs();
|
||||
STrans *pTrans = NULL;
|
||||
|
||||
if (mndTrigger == 1 && (ts - pStream->checkpointFreq < tsStreamCheckpointInterval * 1000)) {
|
||||
return code;
|
||||
}
|
||||
|
||||
bool conflict = mndStreamTransConflictCheck(pMnode, pStream->uid, MND_STREAM_CHECKPOINT_NAME, lock);
|
||||
if (conflict) {
|
||||
mWarn("checkpoint conflict with other trans in %s, ignore the checkpoint for stream:%s %" PRIx64, pStream->sourceDb,
|
||||
pStream->name, pStream->uid);
|
||||
return TSDB_CODE_MND_TRANS_CONFLICT;
|
||||
code = mndStreamTransConflictCheck(pMnode, pStream->uid, MND_STREAM_CHECKPOINT_NAME, lock);
|
||||
if (code) {
|
||||
mWarn("checkpoint conflict with other trans in %s, code:%s ignore the checkpoint for stream:%s %" PRIx64,
|
||||
pStream->sourceDb, tstrerror(code), pStream->name, pStream->uid);
|
||||
goto _ERR;
|
||||
}
|
||||
|
||||
STrans *pTrans = NULL;
|
||||
code = doCreateTrans(pMnode, pStream, NULL, TRN_CONFLICT_NOTHING, MND_STREAM_CHECKPOINT_NAME,
|
||||
"gen checkpoint for stream", &pTrans);
|
||||
if (pTrans == NULL || code) {
|
||||
code = TSDB_CODE_MND_TRANS_CONFLICT;
|
||||
"gen checkpoint for stream", &pTrans);
|
||||
if (code) {
|
||||
mError("failed to checkpoint of stream name%s, checkpointId: %" PRId64 ", reason:%s", pStream->name, checkpointId,
|
||||
tstrerror(code));
|
||||
goto _ERR;
|
||||
|
@ -1126,7 +1121,9 @@ static int32_t mndProcessStreamCheckpointTrans(SMnode *pMnode, SStreamObj *pStre
|
|||
|
||||
code = mndTransPrepare(pMnode, pTrans);
|
||||
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||
mError("failed to prepare checkpoint trans since %s", terrstr());
|
||||
mError("failed to prepare checkpoint trans since %s", tstrerror(code));
|
||||
} else {
|
||||
code = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||
}
|
||||
|
||||
_ERR:
|
||||
|
@ -1147,6 +1144,9 @@ int32_t extractStreamNodeList(SMnode *pMnode) {
|
|||
}
|
||||
|
||||
static bool taskNodeIsUpdated(SMnode *pMnode) {
|
||||
bool allReady = true;
|
||||
SArray *pNodeSnapshot = NULL;
|
||||
|
||||
// check if the node update happens or not
|
||||
streamMutexLock(&execInfo.lock);
|
||||
|
||||
|
@ -1171,13 +1171,11 @@ static bool taskNodeIsUpdated(SMnode *pMnode) {
|
|||
}
|
||||
}
|
||||
|
||||
bool allReady = true;
|
||||
SArray *pNodeSnapshot = NULL;
|
||||
|
||||
int32_t code = mndTakeVgroupSnapshot(pMnode, &allReady, &pNodeSnapshot);
|
||||
if (code) {
|
||||
mError("failed to get the vgroup snapshot, ignore it and continue");
|
||||
}
|
||||
|
||||
if (!allReady) {
|
||||
mWarn("not all vnodes ready, quit from vnodes status check");
|
||||
taosArrayDestroy(pNodeSnapshot);
|
||||
|
@ -1185,12 +1183,16 @@ static bool taskNodeIsUpdated(SMnode *pMnode) {
|
|||
return true;
|
||||
}
|
||||
|
||||
SVgroupChangeInfo changeInfo = mndFindChangedNodeInfo(pMnode, execInfo.pNodeList, pNodeSnapshot);
|
||||
SVgroupChangeInfo changeInfo = {0};
|
||||
code = mndFindChangedNodeInfo(pMnode, execInfo.pNodeList, pNodeSnapshot, &changeInfo);
|
||||
if (code) {
|
||||
streamMutexUnlock(&execInfo.lock);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool nodeUpdated = (taosArrayGetSize(changeInfo.pUpdateNodeList) > 0);
|
||||
|
||||
taosArrayDestroy(changeInfo.pUpdateNodeList);
|
||||
taosHashCleanup(changeInfo.pDBMap);
|
||||
mndDestroyVgroupChangeInfo(&changeInfo);
|
||||
taosArrayDestroy(pNodeSnapshot);
|
||||
|
||||
if (nodeUpdated) {
|
||||
|
@ -1400,7 +1402,7 @@ static int32_t mndProcessStreamCheckpoint(SRpcMsg *pReq) {
|
|||
code = mndProcessStreamCheckpointTrans(pMnode, p, checkpointId, 1, true);
|
||||
sdbRelease(pSdb, p);
|
||||
|
||||
if (code != -1) {
|
||||
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||
started += 1;
|
||||
|
||||
if (started >= capacity) {
|
||||
|
@ -1438,10 +1440,9 @@ static int32_t mndProcessDropStreamReq(SRpcMsg *pReq) {
|
|||
tFreeMDropStreamReq(&dropReq);
|
||||
return 0;
|
||||
} else {
|
||||
code = TSDB_CODE_MND_STREAM_NOT_EXIST;
|
||||
mError("stream:%s not exist failed to drop it", dropReq.name);
|
||||
tFreeMDropStreamReq(&dropReq);
|
||||
TAOS_RETURN(code);
|
||||
TAOS_RETURN(TSDB_CODE_MND_STREAM_NOT_EXIST);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1480,17 +1481,17 @@ static int32_t mndProcessDropStreamReq(SRpcMsg *pReq) {
|
|||
}
|
||||
|
||||
// check if it is conflict with other trans in both sourceDb and targetDb.
|
||||
bool conflict = mndStreamTransConflictCheck(pMnode, pStream->uid, MND_STREAM_DROP_NAME, true);
|
||||
if (conflict) {
|
||||
code = mndStreamTransConflictCheck(pMnode, pStream->uid, MND_STREAM_DROP_NAME, true);
|
||||
if (code) {
|
||||
sdbRelease(pMnode->pSdb, pStream);
|
||||
tFreeMDropStreamReq(&dropReq);
|
||||
return terrno;
|
||||
return code;
|
||||
}
|
||||
|
||||
STrans *pTrans = NULL;
|
||||
code = doCreateTrans(pMnode, pStream, pReq, TRN_CONFLICT_NOTHING, MND_STREAM_DROP_NAME, "drop stream", &pTrans);
|
||||
if (pTrans == NULL || code) {
|
||||
mError("stream:%s uid:0x%" PRIx64 " failed to drop since %s", dropReq.name, pStream->uid, terrstr());
|
||||
mError("stream:%s uid:0x%" PRIx64 " failed to drop since %s", dropReq.name, pStream->uid, tstrerror(code));
|
||||
sdbRelease(pMnode->pSdb, pStream);
|
||||
tFreeMDropStreamReq(&dropReq);
|
||||
TAOS_RETURN(code);
|
||||
|
@ -1526,7 +1527,7 @@ static int32_t mndProcessDropStreamReq(SRpcMsg *pReq) {
|
|||
|
||||
code = mndTransPrepare(pMnode, pTrans);
|
||||
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||
mError("trans:%d, failed to prepare drop stream trans since %s", pTrans->id, terrstr());
|
||||
mError("trans:%d, failed to prepare drop stream trans since %s", pTrans->id, tstrerror(code));
|
||||
sdbRelease(pMnode->pSdb, pStream);
|
||||
mndTransDrop(pTrans);
|
||||
tFreeMDropStreamReq(&dropReq);
|
||||
|
@ -1756,16 +1757,16 @@ static int32_t mndProcessPauseStreamReq(SRpcMsg *pReq) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (mndCheckDbPrivilegeByName(pMnode, pReq->info.conn.user, MND_OPER_WRITE_DB, pStream->targetDb) != 0) {
|
||||
if ((code = mndCheckDbPrivilegeByName(pMnode, pReq->info.conn.user, MND_OPER_WRITE_DB, pStream->targetDb)) != 0) {
|
||||
sdbRelease(pMnode->pSdb, pStream);
|
||||
return -1;
|
||||
return code;
|
||||
}
|
||||
|
||||
// check if it is conflict with other trans in both sourceDb and targetDb.
|
||||
bool conflict = mndStreamTransConflictCheck(pMnode, pStream->uid, MND_STREAM_PAUSE_NAME, true);
|
||||
if (conflict) {
|
||||
code = mndStreamTransConflictCheck(pMnode, pStream->uid, MND_STREAM_PAUSE_NAME, true);
|
||||
if (code) {
|
||||
sdbRelease(pMnode->pSdb, pStream);
|
||||
TAOS_RETURN(TSDB_CODE_MND_TRANS_CONFLICT);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
bool updated = taskNodeIsUpdated(pMnode);
|
||||
|
@ -1821,7 +1822,7 @@ static int32_t mndProcessPauseStreamReq(SRpcMsg *pReq) {
|
|||
STrans *pTrans = NULL;
|
||||
code = doCreateTrans(pMnode, pStream, pReq, TRN_CONFLICT_NOTHING, MND_STREAM_PAUSE_NAME, "pause the stream", &pTrans);
|
||||
if (pTrans == NULL || code) {
|
||||
mError("stream:%s failed to pause stream since %s", pauseReq.name, terrstr());
|
||||
mError("stream:%s failed to pause stream since %s", pauseReq.name, tstrerror(code));
|
||||
sdbRelease(pMnode->pSdb, pStream);
|
||||
return code;
|
||||
}
|
||||
|
@ -1836,7 +1837,7 @@ static int32_t mndProcessPauseStreamReq(SRpcMsg *pReq) {
|
|||
// if nodeUpdate happened, not send pause trans
|
||||
code = mndStreamSetPauseAction(pMnode, pTrans, pStream);
|
||||
if (code) {
|
||||
mError("stream:%s, failed to pause task since %s", pauseReq.name, terrstr());
|
||||
mError("stream:%s, failed to pause task since %s", pauseReq.name, tstrerror(code));
|
||||
sdbRelease(pMnode->pSdb, pStream);
|
||||
mndTransDrop(pTrans);
|
||||
return code;
|
||||
|
@ -1857,7 +1858,7 @@ static int32_t mndProcessPauseStreamReq(SRpcMsg *pReq) {
|
|||
|
||||
code = mndTransPrepare(pMnode, pTrans);
|
||||
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||
mError("trans:%d, failed to prepare pause stream trans since %s", pTrans->id, terrstr());
|
||||
mError("trans:%d, failed to prepare pause stream trans since %s", pTrans->id, tstrerror(code));
|
||||
sdbRelease(pMnode->pSdb, pStream);
|
||||
mndTransDrop(pTrans);
|
||||
return code;
|
||||
|
@ -1874,8 +1875,8 @@ static int32_t mndProcessResumeStreamReq(SRpcMsg *pReq) {
|
|||
SStreamObj *pStream = NULL;
|
||||
int32_t code = 0;
|
||||
|
||||
if ((terrno = grantCheckExpire(TSDB_GRANT_STREAMS)) < 0) {
|
||||
return terrno;
|
||||
if ((code = grantCheckExpire(TSDB_GRANT_STREAMS)) < 0) {
|
||||
return code;
|
||||
}
|
||||
|
||||
SMResumeStreamReq resumeReq = {0};
|
||||
|
@ -1906,17 +1907,17 @@ static int32_t mndProcessResumeStreamReq(SRpcMsg *pReq) {
|
|||
}
|
||||
|
||||
// check if it is conflict with other trans in both sourceDb and targetDb.
|
||||
bool conflict = mndStreamTransConflictCheck(pMnode, pStream->uid, MND_STREAM_RESUME_NAME, true);
|
||||
if (conflict) {
|
||||
code = mndStreamTransConflictCheck(pMnode, pStream->uid, MND_STREAM_RESUME_NAME, true);
|
||||
if (code) {
|
||||
sdbRelease(pMnode->pSdb, pStream);
|
||||
return terrno;
|
||||
return code;
|
||||
}
|
||||
|
||||
STrans *pTrans = NULL;
|
||||
code =
|
||||
doCreateTrans(pMnode, pStream, pReq, TRN_CONFLICT_NOTHING, MND_STREAM_RESUME_NAME, "resume the stream", &pTrans);
|
||||
if (pTrans == NULL || code) {
|
||||
mError("stream:%s, failed to resume stream since %s", resumeReq.name, terrstr());
|
||||
mError("stream:%s, failed to resume stream since %s", resumeReq.name, tstrerror(code));
|
||||
sdbRelease(pMnode->pSdb, pStream);
|
||||
return code;
|
||||
}
|
||||
|
@ -1929,8 +1930,9 @@ static int32_t mndProcessResumeStreamReq(SRpcMsg *pReq) {
|
|||
}
|
||||
|
||||
// set the resume action
|
||||
if (mndStreamSetResumeAction(pTrans, pMnode, pStream, resumeReq.igUntreated) < 0) {
|
||||
mError("stream:%s, failed to drop task since %s", resumeReq.name, terrstr());
|
||||
code = mndStreamSetResumeAction(pTrans, pMnode, pStream, resumeReq.igUntreated);
|
||||
if (code) {
|
||||
mError("stream:%s, failed to drop task since %s", resumeReq.name, tstrerror(code));
|
||||
sdbRelease(pMnode->pSdb, pStream);
|
||||
mndTransDrop(pTrans);
|
||||
return code;
|
||||
|
@ -1950,7 +1952,7 @@ static int32_t mndProcessResumeStreamReq(SRpcMsg *pReq) {
|
|||
taosWUnLockLatch(&pStream->lock);
|
||||
code = mndTransPrepare(pMnode, pTrans);
|
||||
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||
mError("trans:%d, failed to prepare pause stream trans since %s", pTrans->id, terrstr());
|
||||
mError("trans:%d, failed to prepare pause stream trans since %s", pTrans->id, tstrerror(code));
|
||||
sdbRelease(pMnode->pSdb, pStream);
|
||||
mndTransDrop(pTrans);
|
||||
return code;
|
||||
|
@ -1977,11 +1979,22 @@ static bool isNodeEpsetChanged(const SEpSet *pPrevEpset, const SEpSet *pCurrent)
|
|||
// tasks on the will be removed replica.
|
||||
// 3. vgroup redistribution is an combination operation of first increase replica and then decrease replica. So we
|
||||
// will handle it as mentioned in 1 & 2 items.
|
||||
static SVgroupChangeInfo mndFindChangedNodeInfo(SMnode *pMnode, const SArray *pPrevNodeList, const SArray *pNodeList) {
|
||||
SVgroupChangeInfo info = {
|
||||
.pUpdateNodeList = taosArrayInit(4, sizeof(SNodeUpdateInfo)),
|
||||
.pDBMap = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_VARCHAR), true, HASH_NO_LOCK),
|
||||
};
|
||||
static int32_t mndFindChangedNodeInfo(SMnode *pMnode, const SArray *pPrevNodeList, const SArray *pNodeList,
|
||||
SVgroupChangeInfo *pInfo) {
|
||||
int32_t code = 0;
|
||||
int32_t lino = 0;
|
||||
|
||||
if (pInfo == NULL) {
|
||||
return TSDB_CODE_INVALID_PARA;
|
||||
}
|
||||
|
||||
pInfo->pUpdateNodeList = taosArrayInit(4, sizeof(SNodeUpdateInfo)),
|
||||
pInfo->pDBMap = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_VARCHAR), true, HASH_NO_LOCK);
|
||||
|
||||
if (pInfo->pUpdateNodeList == NULL || pInfo->pDBMap == NULL) {
|
||||
mndDestroyVgroupChangeInfo(pInfo);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
int32_t numOfNodes = taosArrayGetSize(pPrevNodeList);
|
||||
for (int32_t i = 0; i < numOfNodes; ++i) {
|
||||
|
@ -2002,7 +2015,11 @@ static SVgroupChangeInfo mndFindChangedNodeInfo(SMnode *pMnode, const SArray *pP
|
|||
const SEp *pPrevEp = GET_ACTIVE_EP(&pPrevEntry->epset);
|
||||
|
||||
char buf[256] = {0};
|
||||
(void) epsetToStr(&pCurrent->epset, buf, tListLen(buf)); // ignore this error
|
||||
code = epsetToStr(&pCurrent->epset, buf, tListLen(buf)); // ignore this error
|
||||
if (code) {
|
||||
mError("failed to convert epset string, code:%s", tstrerror(code));
|
||||
TSDB_CHECK_CODE(code, lino, _err);
|
||||
}
|
||||
|
||||
mDebug("nodeId:%d restart/epset changed detected, old:%s:%d -> new:%s, stageUpdate:%d", pCurrent->nodeId,
|
||||
pPrevEp->fqdn, pPrevEp->port, buf, pPrevEntry->stageUpdated);
|
||||
|
@ -2011,20 +2028,16 @@ static SVgroupChangeInfo mndFindChangedNodeInfo(SMnode *pMnode, const SArray *pP
|
|||
epsetAssign(&updateInfo.prevEp, &pPrevEntry->epset);
|
||||
epsetAssign(&updateInfo.newEp, &pCurrent->epset);
|
||||
|
||||
void* p = taosArrayPush(info.pUpdateNodeList, &updateInfo);
|
||||
if (p == NULL) {
|
||||
mError("failed to put update entry into node list, code:%s", tstrerror(TSDB_CODE_OUT_OF_MEMORY));
|
||||
}
|
||||
void* p = taosArrayPush(pInfo->pUpdateNodeList, &updateInfo);
|
||||
TSDB_CHECK_NULL(p, code, lino, _err, terrno);
|
||||
}
|
||||
|
||||
// todo handle the snode info
|
||||
if (pCurrent->nodeId != SNODE_HANDLE) {
|
||||
SVgObj *pVgroup = mndAcquireVgroup(pMnode, pCurrent->nodeId);
|
||||
int32_t code = taosHashPut(info.pDBMap, pVgroup->dbName, strlen(pVgroup->dbName), NULL, 0);
|
||||
code = taosHashPut(pInfo->pDBMap, pVgroup->dbName, strlen(pVgroup->dbName), NULL, 0);
|
||||
mndReleaseVgroup(pMnode, pVgroup);
|
||||
if (code) {
|
||||
mError("failed to put into dbmap, code:out of memory");
|
||||
}
|
||||
TSDB_CHECK_CODE(code, lino, _err);
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -2032,7 +2045,18 @@ static SVgroupChangeInfo mndFindChangedNodeInfo(SMnode *pMnode, const SArray *pP
|
|||
}
|
||||
}
|
||||
|
||||
return info;
|
||||
return code;
|
||||
|
||||
_err:
|
||||
mndDestroyVgroupChangeInfo(pInfo);
|
||||
return code;
|
||||
}
|
||||
|
||||
static void mndDestroyVgroupChangeInfo(SVgroupChangeInfo* pInfo) {
|
||||
if (pInfo != NULL) {
|
||||
taosArrayDestroy(pInfo->pUpdateNodeList);
|
||||
taosHashCleanup(pInfo->pDBMap);
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t mndProcessVgroupChange(SMnode *pMnode, SVgroupChangeInfo *pChangeInfo, bool includeAllNodes) {
|
||||
|
@ -2049,13 +2073,13 @@ static int32_t mndProcessVgroupChange(SMnode *pMnode, SVgroupChangeInfo *pChange
|
|||
break;
|
||||
}
|
||||
|
||||
bool conflict = mndStreamTransConflictCheck(pMnode, pStream->uid, MND_STREAM_TASK_UPDATE_NAME, false);
|
||||
code = mndStreamTransConflictCheck(pMnode, pStream->uid, MND_STREAM_TASK_UPDATE_NAME, false);
|
||||
sdbRelease(pSdb, pStream);
|
||||
|
||||
if (conflict) {
|
||||
mError("nodeUpdate conflict with other trans, current nodeUpdate ignored");
|
||||
if (code) {
|
||||
mError("nodeUpdate conflict with other trans, current nodeUpdate ignored, code:%s", tstrerror(code));
|
||||
sdbCancelFetch(pSdb, pIter);
|
||||
return terrno;
|
||||
return code;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2119,7 +2143,7 @@ static int32_t mndProcessVgroupChange(SMnode *pMnode, SVgroupChangeInfo *pChange
|
|||
|
||||
code = mndTransPrepare(pMnode, pTrans);
|
||||
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||
mError("trans:%d, failed to prepare update stream trans since %s", pTrans->id, terrstr());
|
||||
mError("trans:%d, failed to prepare update stream trans since %s", pTrans->id, tstrerror(code));
|
||||
sdbRelease(pMnode->pSdb, pStream);
|
||||
mndTransDrop(pTrans);
|
||||
return code;
|
||||
|
@ -2276,7 +2300,11 @@ static int32_t mndProcessNodeCheckReq(SRpcMsg *pMsg) {
|
|||
goto _end;
|
||||
}
|
||||
|
||||
SVgroupChangeInfo changeInfo = mndFindChangedNodeInfo(pMnode, execInfo.pNodeList, pNodeSnapshot);
|
||||
SVgroupChangeInfo changeInfo = {0};
|
||||
code = mndFindChangedNodeInfo(pMnode, execInfo.pNodeList, pNodeSnapshot, &changeInfo);
|
||||
if (code) {
|
||||
goto _end;
|
||||
}
|
||||
|
||||
{
|
||||
if (execInfo.role == NODE_ROLE_LEADER && execInfo.switchFromFollower) {
|
||||
|
@ -2310,8 +2338,7 @@ static int32_t mndProcessNodeCheckReq(SRpcMsg *pMsg) {
|
|||
mDebug("no update found in nodeList");
|
||||
}
|
||||
|
||||
taosArrayDestroy(changeInfo.pUpdateNodeList);
|
||||
taosHashCleanup(changeInfo.pDBMap);
|
||||
mndDestroyVgroupChangeInfo(&changeInfo);
|
||||
|
||||
_end:
|
||||
streamMutexUnlock(&execInfo.lock);
|
||||
|
@ -2640,9 +2667,8 @@ int32_t mndProcessCheckpointReport(SRpcMsg *pReq) {
|
|||
void *p = taosHashGet(execInfo.pTaskMap, &id, sizeof(id));
|
||||
if (p == NULL) {
|
||||
mError("failed to find the stream:0x%" PRIx64 " in buf, not handle the checkpoint-report", req.streamId);
|
||||
terrno = TSDB_CODE_MND_STREAM_NOT_EXIST;
|
||||
streamMutexUnlock(&execInfo.lock);
|
||||
return terrno;
|
||||
return TSDB_CODE_MND_STREAM_NOT_EXIST;
|
||||
} else {
|
||||
mDebug("s-task:0x%" PRIx64 "-0x%x in buf not in mnode/meta, create stream trans may not complete yet",
|
||||
req.streamId, req.taskId);
|
||||
|
@ -2993,7 +3019,7 @@ int32_t mndCreateStreamChkptInfoUpdateTrans(SMnode *pMnode, SStreamObj *pStream,
|
|||
|
||||
code = mndTransPrepare(pMnode, pTrans);
|
||||
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||
mError("trans:%d, failed to prepare update checkpoint-info meta trans since %s", pTrans->id, terrstr());
|
||||
mError("trans:%d, failed to prepare update checkpoint-info meta trans since %s", pTrans->id, tstrerror(code));
|
||||
sdbRelease(pMnode->pSdb, pStream);
|
||||
mndTransDrop(pTrans);
|
||||
return code;
|
||||
|
@ -3038,9 +3064,8 @@ static int32_t mndProcessDropOrphanTaskReq(SRpcMsg *pReq) {
|
|||
}
|
||||
|
||||
// check if it is conflict with other trans in both sourceDb and targetDb.
|
||||
bool conflict = mndStreamTransConflictCheck(pMnode, pTask->streamId, MND_STREAM_DROP_NAME, false);
|
||||
if (conflict) {
|
||||
code = TSDB_CODE_MND_TRANS_CONFLICT;
|
||||
code = mndStreamTransConflictCheck(pMnode, pTask->streamId, MND_STREAM_DROP_NAME, false);
|
||||
if (code) {
|
||||
goto _err;
|
||||
}
|
||||
|
||||
|
@ -3048,7 +3073,7 @@ static int32_t mndProcessDropOrphanTaskReq(SRpcMsg *pReq) {
|
|||
|
||||
code = doCreateTrans(pMnode, &dummyObj, NULL, TRN_CONFLICT_NOTHING, MND_STREAM_DROP_NAME, "drop stream", &pTrans);
|
||||
if (pTrans == NULL || code != 0) {
|
||||
mError("failed to create trans to drop orphan tasks since %s", terrstr());
|
||||
mError("failed to create trans to drop orphan tasks since %s", tstrerror(code));
|
||||
goto _err;
|
||||
}
|
||||
|
||||
|
@ -3059,7 +3084,7 @@ static int32_t mndProcessDropOrphanTaskReq(SRpcMsg *pReq) {
|
|||
|
||||
// drop all tasks
|
||||
if ((code = mndStreamSetDropActionFromList(pMnode, pTrans, msg.pList)) < 0) {
|
||||
mError("failed to create trans to drop orphan tasks since %s", terrstr());
|
||||
mError("failed to create trans to drop orphan tasks since %s", tstrerror(code));
|
||||
goto _err;
|
||||
}
|
||||
|
||||
|
@ -3070,7 +3095,7 @@ static int32_t mndProcessDropOrphanTaskReq(SRpcMsg *pReq) {
|
|||
|
||||
code = mndTransPrepare(pMnode, pTrans);
|
||||
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||
mError("trans:%d, failed to prepare drop stream trans since %s", pTrans->id, terrstr());
|
||||
mError("trans:%d, failed to prepare drop stream trans since %s", pTrans->id, tstrerror(code));
|
||||
goto _err;
|
||||
}
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ int32_t mndCreateStreamResetStatusTrans(SMnode *pMnode, SStreamObj *pStream) {
|
|||
|
||||
code = mndTransPrepare(pMnode, pTrans);
|
||||
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||
mError("trans:%d, failed to prepare update stream trans since %s", pTrans->id, terrstr());
|
||||
mError("trans:%d, failed to prepare update stream trans since %s", pTrans->id, tstrerror(code));
|
||||
sdbRelease(pMnode->pSdb, pStream);
|
||||
mndTransDrop(pTrans);
|
||||
return code;
|
||||
|
@ -109,6 +109,9 @@ int32_t mndCreateStreamResetStatusTrans(SMnode *pMnode, SStreamObj *pStream) {
|
|||
sdbRelease(pMnode->pSdb, pStream);
|
||||
mndTransDrop(pTrans);
|
||||
|
||||
if (code == 0) {
|
||||
code = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -221,8 +224,8 @@ int32_t mndProcessResetStatusReq(SRpcMsg *pReq) {
|
|||
code = TSDB_CODE_STREAM_TASK_NOT_EXIST;
|
||||
mError("failed to acquire the streamObj:0x%" PRIx64 " to reset checkpoint, may have been dropped", pStream->uid);
|
||||
} else {
|
||||
bool conflict = mndStreamTransConflictCheck(pMnode, pStream->uid, MND_STREAM_TASK_RESET_NAME, false);
|
||||
if (conflict) {
|
||||
code = mndStreamTransConflictCheck(pMnode, pStream->uid, MND_STREAM_TASK_RESET_NAME, false);
|
||||
if (code) {
|
||||
mError("stream:%s other trans exists in DB:%s, dstTable:%s failed to start reset-status trans", pStream->name,
|
||||
pStream->sourceDb, pStream->targetSTbName);
|
||||
} else {
|
||||
|
|
|
@ -50,7 +50,7 @@ int32_t mndStreamClearFinishedTrans(SMnode *pMnode, int32_t *pNumOfActiveChkpt)
|
|||
pEntry->startTime);
|
||||
void* p = taosArrayPush(pList, &info);
|
||||
if (p == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
} else {
|
||||
if (strcmp(pEntry->name, MND_STREAM_CHECKPOINT_NAME) == 0) {
|
||||
|
@ -77,7 +77,6 @@ int32_t mndStreamClearFinishedTrans(SMnode *pMnode, int32_t *pNumOfActiveChkpt)
|
|||
mDebug("clear %d finished stream-trans, remained:%d, active checkpoint trans:%d", size,
|
||||
taosHashGetSize(execInfo.transMgmt.pDBTrans), num);
|
||||
|
||||
terrno = TSDB_CODE_SUCCESS;
|
||||
taosArrayDestroy(pList);
|
||||
|
||||
if (pNumOfActiveChkpt != NULL) {
|
||||
|
@ -91,7 +90,7 @@ int32_t mndStreamClearFinishedTrans(SMnode *pMnode, int32_t *pNumOfActiveChkpt)
|
|||
// For a given stream:
|
||||
// 1. checkpoint trans is conflict with any other trans except for the drop and reset trans.
|
||||
// 2. create/drop/reset/update trans are conflict with any other trans.
|
||||
bool mndStreamTransConflictCheck(SMnode *pMnode, int64_t streamId, const char *pTransName, bool lock) {
|
||||
int32_t mndStreamTransConflictCheck(SMnode *pMnode, int64_t streamId, const char *pTransName, bool lock) {
|
||||
if (lock) {
|
||||
streamMutexLock(&execInfo.lock);
|
||||
}
|
||||
|
@ -101,7 +100,7 @@ bool mndStreamTransConflictCheck(SMnode *pMnode, int64_t streamId, const char *p
|
|||
if (lock) {
|
||||
streamMutexUnlock(&execInfo.lock);
|
||||
}
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t code = mndStreamClearFinishedTrans(pMnode, NULL);
|
||||
|
@ -121,8 +120,7 @@ bool mndStreamTransConflictCheck(SMnode *pMnode, int64_t streamId, const char *p
|
|||
if ((strcmp(pTransName, MND_STREAM_DROP_NAME) != 0) && (strcmp(pTransName, MND_STREAM_TASK_RESET_NAME) != 0)) {
|
||||
mWarn("conflict with other transId:%d streamUid:0x%" PRIx64 ", trans:%s", tInfo.transId, tInfo.streamId,
|
||||
tInfo.name);
|
||||
terrno = TSDB_CODE_MND_TRANS_CONFLICT;
|
||||
return true;
|
||||
return TSDB_CODE_MND_TRANS_CONFLICT;
|
||||
} else {
|
||||
mDebug("not conflict with checkpoint trans, name:%s, continue creating trans", pTransName);
|
||||
}
|
||||
|
@ -131,8 +129,7 @@ bool mndStreamTransConflictCheck(SMnode *pMnode, int64_t streamId, const char *p
|
|||
strcmp(tInfo.name, MND_STREAM_TASK_UPDATE_NAME) == 0) {
|
||||
mWarn("conflict with other transId:%d streamUid:0x%" PRIx64 ", trans:%s", tInfo.transId, tInfo.streamId,
|
||||
tInfo.name);
|
||||
terrno = TSDB_CODE_MND_TRANS_CONFLICT;
|
||||
return true;
|
||||
return TSDB_CODE_MND_TRANS_CONFLICT;
|
||||
}
|
||||
} else {
|
||||
mDebug("stream:0x%" PRIx64 " no conflict trans existed, continue create trans", streamId);
|
||||
|
@ -142,7 +139,7 @@ bool mndStreamTransConflictCheck(SMnode *pMnode, int64_t streamId, const char *p
|
|||
streamMutexUnlock(&execInfo.lock);
|
||||
}
|
||||
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t mndStreamGetRelTrans(SMnode *pMnode, int64_t streamId) {
|
||||
|
@ -202,47 +199,48 @@ int32_t doCreateTrans(SMnode *pMnode, SStreamObj *pStream, SRpcMsg *pReq, ETrnCo
|
|||
SSdbRaw *mndStreamActionEncode(SStreamObj *pStream) {
|
||||
int32_t code = 0;
|
||||
int32_t lino = 0;
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
void *buf = NULL;
|
||||
void *buf = NULL;
|
||||
|
||||
SEncoder encoder;
|
||||
tEncoderInit(&encoder, NULL, 0);
|
||||
if (tEncodeSStreamObj(&encoder, pStream) < 0) {
|
||||
if ((code = tEncodeSStreamObj(&encoder, pStream)) < 0) {
|
||||
tEncoderClear(&encoder);
|
||||
goto STREAM_ENCODE_OVER;
|
||||
TSDB_CHECK_CODE(code, lino, _over);
|
||||
}
|
||||
|
||||
int32_t tlen = encoder.pos;
|
||||
tEncoderClear(&encoder);
|
||||
|
||||
int32_t size = sizeof(int32_t) + tlen + MND_STREAM_RESERVE_SIZE;
|
||||
SSdbRaw *pRaw = sdbAllocRaw(SDB_STREAM, MND_STREAM_VER_NUMBER, size);
|
||||
if (pRaw == NULL) goto STREAM_ENCODE_OVER;
|
||||
TSDB_CHECK_NULL(pRaw, code, lino, _over, terrno);
|
||||
|
||||
buf = taosMemoryMalloc(tlen);
|
||||
if (buf == NULL) goto STREAM_ENCODE_OVER;
|
||||
TSDB_CHECK_NULL(buf, code, lino, _over, terrno);
|
||||
|
||||
tEncoderInit(&encoder, buf, tlen);
|
||||
if (tEncodeSStreamObj(&encoder, pStream) < 0) {
|
||||
if ((code = tEncodeSStreamObj(&encoder, pStream)) < 0) {
|
||||
tEncoderClear(&encoder);
|
||||
goto STREAM_ENCODE_OVER;
|
||||
TSDB_CHECK_CODE(code, lino, _over);
|
||||
}
|
||||
|
||||
tEncoderClear(&encoder);
|
||||
|
||||
int32_t dataPos = 0;
|
||||
SDB_SET_INT32(pRaw, dataPos, tlen, STREAM_ENCODE_OVER);
|
||||
SDB_SET_BINARY(pRaw, dataPos, buf, tlen, STREAM_ENCODE_OVER);
|
||||
SDB_SET_DATALEN(pRaw, dataPos, STREAM_ENCODE_OVER);
|
||||
SDB_SET_INT32(pRaw, dataPos, tlen, _over);
|
||||
SDB_SET_BINARY(pRaw, dataPos, buf, tlen, _over);
|
||||
SDB_SET_DATALEN(pRaw, dataPos, _over);
|
||||
|
||||
terrno = TSDB_CODE_SUCCESS;
|
||||
|
||||
STREAM_ENCODE_OVER:
|
||||
_over:
|
||||
taosMemoryFreeClear(buf);
|
||||
if (terrno != TSDB_CODE_SUCCESS) {
|
||||
mError("stream:%s, failed to encode to raw:%p since %s", pStream->name, pRaw, terrstr());
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
mError("stream:%s, failed to encode to raw:%p at line:%d since %s", pStream->name, pRaw, lino, tstrerror(code));
|
||||
sdbFreeRaw(pRaw);
|
||||
terrno = code;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
terrno = 0;
|
||||
mTrace("stream:%s, encode to raw:%p, row:%p, checkpoint:%" PRId64 "", pStream->name, pRaw, pStream,
|
||||
pStream->checkpointId);
|
||||
return pRaw;
|
||||
|
|
|
@ -653,7 +653,7 @@ static int32_t doSetUpdateTaskAction(SMnode *pMnode, STrans *pTrans, SStreamTask
|
|||
return code;
|
||||
}
|
||||
|
||||
code = setTransAction(pTrans, pBuf, len, TDMT_VND_STREAM_TASK_UPDATE, &epset, TSDB_CODE_VND_INVALID_VGROUP_ID, 0);
|
||||
code = setTransAction(pTrans, pBuf, len, TDMT_VND_STREAM_TASK_UPDATE, &epset, 0, TSDB_CODE_VND_INVALID_VGROUP_ID);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
taosMemoryFree(pBuf);
|
||||
}
|
||||
|
@ -1105,8 +1105,8 @@ int32_t mndScanCheckpointReportInfo(SRpcMsg *pReq) {
|
|||
mDebug("stream:0x%" PRIx64 " %s all %d tasks send checkpoint-report, start to update checkpoint-info",
|
||||
pStream->uid, pStream->name, total);
|
||||
|
||||
bool conflict = mndStreamTransConflictCheck(pMnode, pStream->uid, MND_STREAM_CHKPT_UPDATE_NAME, false);
|
||||
if (!conflict) {
|
||||
code = mndStreamTransConflictCheck(pMnode, pStream->uid, MND_STREAM_CHKPT_UPDATE_NAME, false);
|
||||
if (code == 0) {
|
||||
code = mndCreateStreamChkptInfoUpdateTrans(pMnode, pStream, px->pTaskList);
|
||||
if (code == TSDB_CODE_SUCCESS || code == TSDB_CODE_ACTION_IN_PROGRESS) { // remove this entry
|
||||
taosArrayClear(px->pTaskList);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -243,7 +243,7 @@ int32_t tsdbMemTableCreate(STsdb *pTsdb, SMemTable **ppMemTable);
|
|||
void tsdbMemTableDestroy(SMemTable *pMemTable, bool proactive);
|
||||
STbData *tsdbGetTbDataFromMemTable(SMemTable *pMemTable, tb_uid_t suid, tb_uid_t uid);
|
||||
int32_t tsdbRefMemTable(SMemTable *pMemTable, SQueryNode *pQNode);
|
||||
int32_t tsdbUnrefMemTable(SMemTable *pMemTable, SQueryNode *pNode, bool proactive);
|
||||
void tsdbUnrefMemTable(SMemTable *pMemTable, SQueryNode *pNode, bool proactive);
|
||||
// STbDataIter
|
||||
int32_t tsdbTbDataIterCreate(STbData *pTbData, STsdbRowKey *pFrom, int8_t backward, STbDataIter **ppIter);
|
||||
void *tsdbTbDataIterDestroy(STbDataIter *pIter);
|
||||
|
@ -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);
|
||||
|
||||
|
@ -377,7 +377,7 @@ struct STsdb {
|
|||
struct {
|
||||
SVHashTable *ht;
|
||||
SArray *arr;
|
||||
} * commitInfo;
|
||||
} *commitInfo;
|
||||
};
|
||||
|
||||
struct TSDBKEY {
|
||||
|
@ -678,8 +678,8 @@ typedef TARRAY2(STFileSet *) TFileSetArray;
|
|||
typedef struct STFileSetRange STFileSetRange;
|
||||
typedef TARRAY2(STFileSetRange *) TFileSetRangeArray; // disjoint ranges
|
||||
|
||||
int32_t tsdbTFileSetRangeClear(STFileSetRange **fsr);
|
||||
int32_t tsdbTFileSetRangeArrayDestroy(TFileSetRangeArray **ppArr);
|
||||
void tsdbTFileSetRangeClear(STFileSetRange **fsr);
|
||||
void tsdbTFileSetRangeArrayDestroy(TFileSetRangeArray **ppArr);
|
||||
|
||||
// fset partition
|
||||
enum {
|
||||
|
@ -898,7 +898,7 @@ typedef struct SSttDataInfoForTable {
|
|||
|
||||
int32_t tMergeTreeOpen2(SMergeTree *pMTree, SMergeTreeConf *pConf, SSttDataInfoForTable *pTableInfo);
|
||||
void tMergeTreeAddIter(SMergeTree *pMTree, SLDataIter *pIter);
|
||||
int32_t tMergeTreeNext(SMergeTree *pMTree, bool* pHasNext);
|
||||
int32_t tMergeTreeNext(SMergeTree *pMTree, bool *pHasNext);
|
||||
void tMergeTreePinSttBlock(SMergeTree *pMTree);
|
||||
void tMergeTreeUnpinSttBlock(SMergeTree *pMTree);
|
||||
bool tMergeTreeIgnoreEarlierTs(SMergeTree *pMTree);
|
||||
|
@ -914,13 +914,13 @@ typedef enum {
|
|||
READER_EXEC_ROWS = 0x2,
|
||||
} EExecMode;
|
||||
|
||||
#define LAST_COL_VERSION_1 (0x1) // add primary key, version
|
||||
#define LAST_COL_VERSION_2 (0x2) // add cache status
|
||||
#define LAST_COL_VERSION_1 (0x1) // add primary key, version
|
||||
#define LAST_COL_VERSION_2 (0x2) // add cache status
|
||||
#define LAST_COL_VERSION LAST_COL_VERSION_2
|
||||
|
||||
typedef enum {
|
||||
TSDB_LAST_CACHE_VALID = 0, // last_cache has valid data
|
||||
TSDB_LAST_CACHE_NO_CACHE, // last_cache has no data, but tsdb may have data
|
||||
TSDB_LAST_CACHE_VALID = 0, // last_cache has valid data
|
||||
TSDB_LAST_CACHE_NO_CACHE, // last_cache has no data, but tsdb may have data
|
||||
} ELastCacheStatus;
|
||||
|
||||
typedef struct {
|
||||
|
@ -1069,6 +1069,8 @@ typedef enum {
|
|||
ETsdbFsState tsdbSnapGetFsState(SVnode *pVnode);
|
||||
int32_t tsdbSnapPrepDescription(SVnode *pVnode, SSnapshot *pSnap);
|
||||
|
||||
void tsdbRemoveFile(const char *path);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -56,12 +56,12 @@ typedef enum {
|
|||
} EVAPriority;
|
||||
|
||||
int32_t vnodeAsyncOpen(int32_t numOfThreads);
|
||||
int32_t vnodeAsyncClose();
|
||||
void vnodeAsyncClose();
|
||||
int32_t vnodeAChannelInit(int64_t async, SVAChannelID* channelID);
|
||||
int32_t vnodeAChannelDestroy(SVAChannelID* channelID, bool waitRunning);
|
||||
int32_t vnodeAsync(SVAChannelID* channelID, EVAPriority priority, int32_t (*execute)(void*), void (*complete)(void*),
|
||||
void* arg, SVATaskID* taskID);
|
||||
int32_t vnodeAWait(SVATaskID* taskID);
|
||||
void vnodeAWait(SVATaskID* taskID);
|
||||
int32_t vnodeACancel(SVATaskID* taskID);
|
||||
int32_t vnodeAsyncSetWorkers(int64_t async, int32_t numWorkers);
|
||||
|
||||
|
@ -95,13 +95,13 @@ struct SVBufPool {
|
|||
};
|
||||
|
||||
int32_t vnodeOpenBufPool(SVnode* pVnode);
|
||||
int32_t vnodeCloseBufPool(SVnode* pVnode);
|
||||
void vnodeCloseBufPool(SVnode* pVnode);
|
||||
void vnodeBufPoolReset(SVBufPool* pPool);
|
||||
void vnodeBufPoolAddToFreeList(SVBufPool* pPool);
|
||||
int32_t vnodeBufPoolRecycle(SVBufPool* pPool);
|
||||
|
||||
// vnodeOpen.c
|
||||
int32_t vnodeGetPrimaryDir(const char* relPath, int32_t diskPrimary, STfs* pTfs, char* buf, size_t bufLen);
|
||||
void vnodeGetPrimaryDir(const char* relPath, int32_t diskPrimary, STfs* pTfs, char* buf, size_t bufLen);
|
||||
|
||||
// vnodeQuery.c
|
||||
int32_t vnodeQueryOpen(SVnode* pVnode);
|
||||
|
|
|
@ -130,8 +130,8 @@ void vnodeBufPoolRef(SVBufPool* pPool);
|
|||
void vnodeBufPoolUnRef(SVBufPool* pPool, bool proactive);
|
||||
int vnodeDecodeInfo(uint8_t* pData, SVnodeInfo* pInfo);
|
||||
|
||||
int32_t vnodeBufPoolRegisterQuery(SVBufPool* pPool, SQueryNode* pQNode);
|
||||
void vnodeBufPoolDeregisterQuery(SVBufPool* pPool, SQueryNode* pQNode, bool proactive);
|
||||
void vnodeBufPoolRegisterQuery(SVBufPool* pPool, SQueryNode* pQNode);
|
||||
void vnodeBufPoolDeregisterQuery(SVBufPool* pPool, SQueryNode* pQNode, bool proactive);
|
||||
|
||||
// meta
|
||||
typedef struct SMStbCursor SMStbCursor;
|
||||
|
@ -223,7 +223,7 @@ int tsdbScanAndConvertSubmitMsg(STsdb* pTsdb, SSubmitReq2* pMsg);
|
|||
int tsdbInsertData(STsdb* pTsdb, int64_t version, SSubmitReq2* pMsg, SSubmitRsp2* pRsp);
|
||||
int32_t tsdbInsertTableData(STsdb* pTsdb, int64_t version, SSubmitTbData* pSubmitTbData, int32_t* affectedRows);
|
||||
int32_t tsdbDeleteTableData(STsdb* pTsdb, int64_t version, tb_uid_t suid, tb_uid_t uid, TSKEY sKey, TSKEY eKey);
|
||||
int32_t tsdbSetKeepCfg(STsdb* pTsdb, STsdbCfg* pCfg);
|
||||
void tsdbSetKeepCfg(STsdb* pTsdb, STsdbCfg* pCfg);
|
||||
int64_t tsdbGetEarliestTs(STsdb* pTsdb);
|
||||
|
||||
// tq
|
||||
|
@ -593,7 +593,7 @@ struct SVHashTable {
|
|||
|
||||
#define vHashNumEntries(ht) ((ht)->numEntries)
|
||||
int32_t vHashInit(SVHashTable** ht, uint32_t (*hash)(const void*), int32_t (*compare)(const void*, const void*));
|
||||
int32_t vHashDestroy(SVHashTable** ht);
|
||||
void vHashDestroy(SVHashTable** ht);
|
||||
int32_t vHashPut(SVHashTable* ht, void* obj);
|
||||
int32_t vHashGet(SVHashTable* ht, const void* obj, void** retObj);
|
||||
int32_t vHashDrop(SVHashTable* ht, const void* obj);
|
||||
|
|
|
@ -48,7 +48,7 @@ int32_t metaOpen(SVnode *pVnode, SMeta **ppMeta, int8_t rollback) {
|
|||
char indexFullPath[128] = {0};
|
||||
|
||||
// create handle
|
||||
(void)vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, path, TSDB_FILENAME_LEN);
|
||||
vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, path, TSDB_FILENAME_LEN);
|
||||
offset = strlen(path);
|
||||
snprintf(path + offset, TSDB_FILENAME_LEN - offset - 1, "%s%s", TD_DIRSEP, VNODE_META_DIR);
|
||||
|
||||
|
|
|
@ -54,8 +54,8 @@ int metaGetTableEntryByVersion(SMetaReader *pReader, int64_t version, tb_uid_t u
|
|||
STbDbKey tbDbKey = {.version = version, .uid = uid};
|
||||
|
||||
// query table.db
|
||||
if (tdbTbGet(pMeta->pTbDb, &tbDbKey, sizeof(tbDbKey), &pReader->pBuf, &pReader->szBuf) < 0) {
|
||||
return terrno = TSDB_CODE_PAR_TABLE_NOT_EXIST;
|
||||
if ((code = tdbTbGet(pMeta->pTbDb, &tbDbKey, sizeof(tbDbKey), &pReader->pBuf, &pReader->szBuf)) < 0) {
|
||||
return terrno = (TSDB_CODE_NOT_FOUND == code ? TSDB_CODE_PAR_TABLE_NOT_EXIST : code);
|
||||
}
|
||||
|
||||
// decode the entry
|
||||
|
@ -98,8 +98,9 @@ int metaReaderGetTableEntryByUidCache(SMetaReader *pReader, tb_uid_t uid) {
|
|||
SMeta *pMeta = pReader->pMeta;
|
||||
|
||||
SMetaInfo info;
|
||||
if (metaGetInfo(pMeta, uid, &info, pReader) == TSDB_CODE_NOT_FOUND) {
|
||||
return terrno = TSDB_CODE_PAR_TABLE_NOT_EXIST;
|
||||
int32_t code = metaGetInfo(pMeta, uid, &info, pReader);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return terrno = (TSDB_CODE_NOT_FOUND == code ? TSDB_CODE_PAR_TABLE_NOT_EXIST : code);
|
||||
}
|
||||
|
||||
return metaGetTableEntryByVersion(pReader, info.version, uid);
|
||||
|
@ -1584,10 +1585,9 @@ int32_t metaGetInfo(SMeta *pMeta, int64_t uid, SMetaInfo *pInfo, SMetaReader *pR
|
|||
}
|
||||
|
||||
// search TDB
|
||||
if (tdbTbGet(pMeta->pUidIdx, &uid, sizeof(uid), &pData, &nData) < 0) {
|
||||
if ((code = tdbTbGet(pMeta->pUidIdx, &uid, sizeof(uid), &pData, &nData)) < 0) {
|
||||
// not found
|
||||
if (!lock) metaULock(pMeta);
|
||||
code = TSDB_CODE_NOT_FOUND;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ void tdRSmaGetDirName(SVnode *pVnode, STfs *pTfs, bool endWithSep, char *outputN
|
|||
int32_t offset = 0;
|
||||
|
||||
// vnode
|
||||
(void)vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pTfs, outputName, TSDB_FILENAME_LEN);
|
||||
vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pTfs, outputName, TSDB_FILENAME_LEN);
|
||||
offset = strlen(outputName);
|
||||
|
||||
// rsma
|
||||
|
|
|
@ -752,7 +752,7 @@ int32_t tqBuildStreamTask(void* pTqObj, SStreamTask* pTask, int64_t nextProcessV
|
|||
}
|
||||
|
||||
streamTaskResetUpstreamStageInfo(pTask);
|
||||
(void)streamSetupScheduleTrigger(pTask);
|
||||
streamSetupScheduleTrigger(pTask);
|
||||
|
||||
SCheckpointInfo* pChkInfo = &pTask->chkInfo;
|
||||
tqSetRestoreVersionInfo(pTask);
|
||||
|
@ -802,6 +802,7 @@ static void doStartFillhistoryStep2(SStreamTask* pTask, SStreamTask* pStreamTask
|
|||
const char* id = pTask->id.idStr;
|
||||
int64_t nextProcessedVer = pStreamTask->hTaskInfo.haltVer;
|
||||
SVersionRange* pStep2Range = &pTask->step2Range;
|
||||
int32_t vgId = pTask->pMeta->vgId;
|
||||
|
||||
// if it's an source task, extract the last version in wal.
|
||||
bool done = streamHistoryTaskSetVerRangeStep2(pTask, nextProcessedVer);
|
||||
|
@ -837,12 +838,15 @@ static void doStartFillhistoryStep2(SStreamTask* pTask, SStreamTask* pStreamTask
|
|||
tqDebug("s-task:%s wal reader start scan WAL verRange:%" PRId64 "-%" PRId64 ", set sched-status:%d", id, dstVer,
|
||||
pStep2Range->maxVer, TASK_SCHED_STATUS__INACTIVE);
|
||||
|
||||
(void)streamTaskSetSchedStatusInactive(pTask);
|
||||
int8_t status = streamTaskSetSchedStatusInactive(pTask);
|
||||
|
||||
// now the fill-history task starts to scan data from wal files.
|
||||
code = streamTaskHandleEvent(pTask->status.pSM, TASK_EVENT_SCANHIST_DONE);
|
||||
if (code == TSDB_CODE_SUCCESS) {
|
||||
(void)tqScanWalAsync(pTq, false);
|
||||
code = tqScanWalAsync(pTq, false);
|
||||
if (code) {
|
||||
tqError("vgId:%d failed to start scan wal file, code:%s", vgId, tstrerror(code));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1001,7 +1005,10 @@ int32_t tqProcessTaskRunReq(STQ* pTq, SRpcMsg* pMsg) {
|
|||
|
||||
// let's continue scan data in the wal files
|
||||
if (code == 0 && (pReq->reqType >= 0 || pReq->reqType == STREAM_EXEC_T_RESUME_TASK)) {
|
||||
(void)tqScanWalAsync(pTq, false); // it's ok to failed
|
||||
code = tqScanWalAsync(pTq, false); // it's ok to failed
|
||||
if (code) {
|
||||
tqError("vgId:%d failed to start scan wal file, code:%s", pTq->pStreamMeta->vgId, tstrerror(code));
|
||||
}
|
||||
}
|
||||
|
||||
return code;
|
||||
|
@ -1103,7 +1110,11 @@ int32_t tqProcessTaskCheckPointSourceReq(STQ* pTq, SRpcMsg* pMsg, SRpcMsg* pRsp)
|
|||
tqError("vgId:%d failed to decode checkpoint-source msg, code:%s", vgId, tstrerror(code));
|
||||
|
||||
SRpcMsg rsp = {0};
|
||||
(void)streamTaskBuildCheckpointSourceRsp(&req, &pMsg->info, &rsp, TSDB_CODE_SUCCESS);
|
||||
int32_t ret = streamTaskBuildCheckpointSourceRsp(&req, &pMsg->info, &rsp, TSDB_CODE_SUCCESS);
|
||||
if (ret) { // suppress the error in build checkpointsource rsp
|
||||
tqError("s-task:0x%x failed to build checkpoint-source rsp, code:%s", req.taskId, tstrerror(code));
|
||||
}
|
||||
|
||||
tmsgSendRsp(&rsp); // error occurs
|
||||
return TSDB_CODE_SUCCESS; // always return success to mnode, todo: handle failure of build and send msg to mnode
|
||||
}
|
||||
|
@ -1112,7 +1123,11 @@ int32_t tqProcessTaskCheckPointSourceReq(STQ* pTq, SRpcMsg* pMsg, SRpcMsg* pRsp)
|
|||
if (!vnodeIsRoleLeader(pTq->pVnode)) {
|
||||
tqDebug("vgId:%d not leader, ignore checkpoint-source msg, s-task:0x%x", vgId, req.taskId);
|
||||
SRpcMsg rsp = {0};
|
||||
(void)streamTaskBuildCheckpointSourceRsp(&req, &pMsg->info, &rsp, TSDB_CODE_SUCCESS);
|
||||
int32_t ret = streamTaskBuildCheckpointSourceRsp(&req, &pMsg->info, &rsp, TSDB_CODE_SUCCESS);
|
||||
if (ret) { // suppress the error in build checkpointsource rsp
|
||||
tqError("s-task:0x%x failed to build checkpoint-source rsp, code:%s", req.taskId, tstrerror(code));
|
||||
}
|
||||
|
||||
tmsgSendRsp(&rsp); // error occurs
|
||||
return TSDB_CODE_SUCCESS; // always return success to mnode, todo: handle failure of build and send msg to mnode
|
||||
}
|
||||
|
@ -1122,7 +1137,11 @@ int32_t tqProcessTaskCheckPointSourceReq(STQ* pTq, SRpcMsg* pMsg, SRpcMsg* pRsp)
|
|||
", transId:%d s-task:0x%x ignore it",
|
||||
vgId, req.checkpointId, req.transId, req.taskId);
|
||||
SRpcMsg rsp = {0};
|
||||
(void)streamTaskBuildCheckpointSourceRsp(&req, &pMsg->info, &rsp, TSDB_CODE_SUCCESS);
|
||||
int32_t ret = streamTaskBuildCheckpointSourceRsp(&req, &pMsg->info, &rsp, TSDB_CODE_SUCCESS);
|
||||
if (ret) { // suppress the error in build checkpointsource rsp
|
||||
tqError("s-task:0x%x failed to build checkpoint-source rsp, code:%s", req.taskId, tstrerror(code));
|
||||
}
|
||||
|
||||
tmsgSendRsp(&rsp); // error occurs
|
||||
return TSDB_CODE_SUCCESS; // always return success to mnode, , todo: handle failure of build and send msg to mnode
|
||||
}
|
||||
|
@ -1134,7 +1153,10 @@ int32_t tqProcessTaskCheckPointSourceReq(STQ* pTq, SRpcMsg* pMsg, SRpcMsg* pRsp)
|
|||
" transId:%d it may have been destroyed",
|
||||
vgId, req.taskId, req.checkpointId, req.transId);
|
||||
SRpcMsg rsp = {0};
|
||||
(void)streamTaskBuildCheckpointSourceRsp(&req, &pMsg->info, &rsp, TSDB_CODE_SUCCESS);
|
||||
int32_t ret = streamTaskBuildCheckpointSourceRsp(&req, &pMsg->info, &rsp, TSDB_CODE_SUCCESS);
|
||||
if (ret) { // suppress the error in build checkpointsource rsp
|
||||
tqError("s-task:%s failed to build checkpoint-source rsp, code:%s", pTask->id.idStr, tstrerror(code));
|
||||
}
|
||||
tmsgSendRsp(&rsp); // error occurs
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -1147,7 +1169,11 @@ int32_t tqProcessTaskCheckPointSourceReq(STQ* pTq, SRpcMsg* pMsg, SRpcMsg* pRsp)
|
|||
streamMetaReleaseTask(pMeta, pTask);
|
||||
|
||||
SRpcMsg rsp = {0};
|
||||
(void)streamTaskBuildCheckpointSourceRsp(&req, &pMsg->info, &rsp, TSDB_CODE_SUCCESS);
|
||||
int32_t ret = streamTaskBuildCheckpointSourceRsp(&req, &pMsg->info, &rsp, TSDB_CODE_SUCCESS);
|
||||
if (ret) { // suppress the error in build checkpointsource rsp
|
||||
tqError("s-task:%s failed to build checkpoint-source rsp, code:%s", pTask->id.idStr, tstrerror(code));
|
||||
}
|
||||
|
||||
tmsgSendRsp(&rsp); // error occurs
|
||||
return TSDB_CODE_SUCCESS; // todo retry handle error
|
||||
}
|
||||
|
@ -1165,7 +1191,11 @@ int32_t tqProcessTaskCheckPointSourceReq(STQ* pTq, SRpcMsg* pMsg, SRpcMsg* pRsp)
|
|||
streamMetaReleaseTask(pMeta, pTask);
|
||||
|
||||
SRpcMsg rsp = {0};
|
||||
(void)streamTaskBuildCheckpointSourceRsp(&req, &pMsg->info, &rsp, TSDB_CODE_SUCCESS);
|
||||
int32_t ret = streamTaskBuildCheckpointSourceRsp(&req, &pMsg->info, &rsp, TSDB_CODE_SUCCESS);
|
||||
if (ret) { // suppress the error in build checkpointsource rsp
|
||||
tqError("s-task:%s failed to build checkpoint-source rsp, code:%s", pTask->id.idStr, tstrerror(code));
|
||||
}
|
||||
|
||||
tmsgSendRsp(&rsp); // error occurs
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -1199,7 +1229,11 @@ int32_t tqProcessTaskCheckPointSourceReq(STQ* pTq, SRpcMsg* pMsg, SRpcMsg* pRsp)
|
|||
streamMetaReleaseTask(pMeta, pTask);
|
||||
|
||||
SRpcMsg rsp = {0};
|
||||
(void)streamTaskBuildCheckpointSourceRsp(&req, &pMsg->info, &rsp, TSDB_CODE_SUCCESS);
|
||||
int32_t ret = streamTaskBuildCheckpointSourceRsp(&req, &pMsg->info, &rsp, TSDB_CODE_SUCCESS);
|
||||
if (ret) { // suppress the error in build checkpointsource rsp
|
||||
tqError("s-task:%s failed to build checkpoint-source rsp, code:%s", pTask->id.idStr, tstrerror(code));
|
||||
}
|
||||
|
||||
tmsgSendRsp(&rsp); // error occurs
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -1228,7 +1262,10 @@ int32_t tqProcessTaskCheckPointSourceReq(STQ* pTq, SRpcMsg* pMsg, SRpcMsg* pRsp)
|
|||
code = streamAddCheckpointSourceRspMsg(&req, &pMsg->info, pTask);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
SRpcMsg rsp = {0};
|
||||
(void)streamTaskBuildCheckpointSourceRsp(&req, &pMsg->info, &rsp, TSDB_CODE_SUCCESS);
|
||||
int32_t ret = streamTaskBuildCheckpointSourceRsp(&req, &pMsg->info, &rsp, TSDB_CODE_SUCCESS);
|
||||
if (ret) { // suppress the error in build checkpointsource rsp
|
||||
tqError("s-task:%s failed to build checkpoint-source rsp, code:%s", pTask->id.idStr, tstrerror(code));
|
||||
}
|
||||
tmsgSendRsp(&rsp); // error occurs
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -389,7 +389,10 @@ static int32_t tqMetaTransformInfo(TDB* pMetaDB, TTB* pOld, TTB* pNew) {
|
|||
END:
|
||||
tdbFree(pKey);
|
||||
tdbFree(pVal);
|
||||
(void)tdbTbcClose(pCur);
|
||||
int32_t ret = tdbTbcClose(pCur);
|
||||
if (code == 0 && ret != 0) {
|
||||
code = ret;
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -461,7 +464,12 @@ static int32_t tqMetaRestoreCheckInfo(STQ* pTq) {
|
|||
END:
|
||||
tdbFree(pKey);
|
||||
tdbFree(pVal);
|
||||
(void)tdbTbcClose(pCur);
|
||||
|
||||
int32_t ret = tdbTbcClose(pCur);
|
||||
if (code == 0) {
|
||||
code = ret;
|
||||
}
|
||||
|
||||
tDeleteSTqCheckInfo(&info);
|
||||
return code;
|
||||
}
|
||||
|
@ -476,13 +484,13 @@ int32_t tqMetaOpen(STQ* pTq) {
|
|||
TQ_ERR_GO_TO_END(tqMetaOpenTdb(pTq));
|
||||
} else {
|
||||
TQ_ERR_GO_TO_END(tqMetaTransform(pTq));
|
||||
(void)taosRemoveFile(maindb);
|
||||
TQ_ERR_GO_TO_END(taosRemoveFile(maindb));
|
||||
}
|
||||
|
||||
TQ_ERR_GO_TO_END(tqBuildFName(&offsetNew, pTq->path, TQ_OFFSET_NAME));
|
||||
if(taosCheckExistFile(offsetNew)){
|
||||
TQ_ERR_GO_TO_END(tqOffsetRestoreFromFile(pTq, offsetNew));
|
||||
(void)taosRemoveFile(offsetNew);
|
||||
TQ_ERR_GO_TO_END(taosRemoveFile(offsetNew));
|
||||
}
|
||||
|
||||
TQ_ERR_GO_TO_END(tqMetaRestoreCheckInfo(pTq));
|
||||
|
@ -518,7 +526,7 @@ int32_t tqMetaTransform(STQ* pTq) {
|
|||
if (taosCopyFile(offset, offsetNew) < 0) {
|
||||
tqError("copy offset file error");
|
||||
} else {
|
||||
(void)taosRemoveFile(offset);
|
||||
TQ_ERR_GO_TO_END(taosRemoveFile(offset));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -527,22 +535,47 @@ END:
|
|||
taosMemoryFree(offsetNew);
|
||||
|
||||
// return 0 always, so ignore
|
||||
(void)tdbTbClose(pExecStore);
|
||||
(void)tdbTbClose(pCheckStore);
|
||||
(void)tdbClose(pMetaDB);
|
||||
int32_t ret = tdbTbClose(pExecStore);
|
||||
if (ret != 0) {
|
||||
tqError("vgId:%d failed to close stream exec store, code:%s", pTq->pStreamMeta->vgId, tstrerror(ret));
|
||||
}
|
||||
|
||||
ret = tdbTbClose(pCheckStore);
|
||||
if (ret != 0) {
|
||||
tqError("vgId:%d failed to close stream check store, code:%s", pTq->pStreamMeta->vgId, tstrerror(ret));
|
||||
}
|
||||
|
||||
ret = tdbClose(pMetaDB);
|
||||
if (ret != 0) {
|
||||
tqError("vgId:%d failed to close stream meta db store, code:%s", pTq->pStreamMeta->vgId, tstrerror(ret));
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
void tqMetaClose(STQ* pTq) {
|
||||
int32_t code = 0;
|
||||
if (pTq->pExecStore) {
|
||||
(void)tdbTbClose(pTq->pExecStore);
|
||||
code = tdbTbClose(pTq->pExecStore);
|
||||
if (code) {
|
||||
tqError("vgId:%d failed to close tq exec store, code:%s", pTq->pStreamMeta->vgId, tstrerror(code));
|
||||
}
|
||||
}
|
||||
if (pTq->pCheckStore) {
|
||||
(void)tdbTbClose(pTq->pCheckStore);
|
||||
code = tdbTbClose(pTq->pCheckStore);
|
||||
if (code) {
|
||||
tqError("vgId:%d failed to close tq check store, code:%s", pTq->pStreamMeta->vgId, tstrerror(code));
|
||||
}
|
||||
}
|
||||
if (pTq->pOffsetStore) {
|
||||
(void)tdbTbClose(pTq->pOffsetStore);
|
||||
code = tdbTbClose(pTq->pOffsetStore);
|
||||
if (code) {
|
||||
tqError("vgId:%d failed to close tq offset store, code:%s", pTq->pStreamMeta->vgId, tstrerror(code));
|
||||
}
|
||||
}
|
||||
|
||||
code = tdbClose(pTq->pMetaDB);
|
||||
if (code) {
|
||||
tqError("vgId:%d failed to close tq meta db store, code:%s", pTq->pStreamMeta->vgId, tstrerror(code));
|
||||
}
|
||||
(void)tdbClose(pTq->pMetaDB);
|
||||
}
|
||||
|
|
|
@ -83,18 +83,27 @@ int32_t streamTaskSnapReaderOpen(STQ* pTq, int64_t sver, int64_t ever, SStreamTa
|
|||
|
||||
_err:
|
||||
tqError("vgId:%d, vnode stream-task snapshot reader open failed since %s", TD_VID(pTq->pVnode), tstrerror(code));
|
||||
(void)streamTaskSnapReaderClose(pReader);
|
||||
int32_t ret = streamTaskSnapReaderClose(pReader);
|
||||
*ppReader = NULL;
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t streamTaskSnapReaderClose(SStreamTaskReader* pReader) {
|
||||
if (pReader == NULL) return 0;
|
||||
if (pReader == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t code = 0;
|
||||
tqInfo("vgId:%d, vnode stream-task snapshot reader closed", TD_VID(pReader->pTq->pVnode));
|
||||
int32_t vgId = TD_VID(pReader->pTq->pVnode);
|
||||
|
||||
taosArrayDestroy(pReader->tdbTbList);
|
||||
(void)tdbTbcClose(pReader->pCur);
|
||||
code = tdbTbcClose(pReader->pCur);
|
||||
if (code) {
|
||||
tqError("vgId:%d failed to close stream meta reader, code:%s", vgId, tstrerror(code));
|
||||
} else {
|
||||
tqInfo("vgId:%d, vnode stream-task snapshot reader closed", vgId);
|
||||
}
|
||||
|
||||
taosMemoryFree(pReader);
|
||||
return code;
|
||||
}
|
||||
|
@ -113,6 +122,7 @@ int32_t streamTaskSnapRead(SStreamTaskReader* pReader, uint8_t** ppData) {
|
|||
tqDebug("vgId:%d, vnode stream-task snapshot start read data", TD_VID(pReader->pTq->pVnode));
|
||||
|
||||
STablePair* pPair = taosArrayGet(pReader->tdbTbList, pReader->pos);
|
||||
|
||||
NextTbl:
|
||||
except = 0;
|
||||
for (;;) {
|
||||
|
@ -127,6 +137,7 @@ NextTbl:
|
|||
code = terrno;
|
||||
goto _err;
|
||||
}
|
||||
|
||||
memcpy(pVal, tVal, tLen);
|
||||
vLen = tLen;
|
||||
}
|
||||
|
@ -163,8 +174,8 @@ NextTbl:
|
|||
taosMemoryFree(pVal);
|
||||
|
||||
tqDebug("vgId:%d, vnode stream-task snapshot read data vLen:%d", TD_VID(pReader->pTq->pVnode), vLen);
|
||||
|
||||
return code;
|
||||
|
||||
_err:
|
||||
tqError("vgId:%d, vnode stream-task snapshot read data failed since %s", TD_VID(pReader->pTq->pVnode),
|
||||
tstrerror(code));
|
||||
|
|
|
@ -207,7 +207,10 @@ int32_t tqStreamTaskProcessUpdateReq(SStreamMeta* pMeta, SMsgCb* cb, SRpcMsg* pM
|
|||
updated = streamTaskUpdateEpsetInfo(pTask, req.pNodeList);
|
||||
|
||||
// send the checkpoint-source-rsp for source task to end the checkpoint trans in mnode
|
||||
(void)streamTaskSendCheckpointsourceRsp(pTask);
|
||||
code = streamTaskSendCheckpointsourceRsp(pTask);
|
||||
if (code) {
|
||||
tqError("%s failed to send checkpoint-source rsp, code:%s", pTask->id.idStr, tstrerror(code));
|
||||
}
|
||||
streamTaskResetStatus(pTask);
|
||||
|
||||
streamTaskStopMonitorCheckRsp(&pTask->taskCheckInfo, pTask->id.idStr);
|
||||
|
@ -806,25 +809,26 @@ int32_t tqStreamTaskProcessRunReq(SStreamMeta* pMeta, SRpcMsg* pMsg, bool isLead
|
|||
|
||||
int32_t type = pReq->reqType;
|
||||
int32_t vgId = pMeta->vgId;
|
||||
int32_t code = 0;
|
||||
|
||||
if (type == STREAM_EXEC_T_START_ONE_TASK) {
|
||||
(void)streamMetaStartOneTask(pMeta, pReq->streamId, pReq->taskId);
|
||||
code = streamMetaStartOneTask(pMeta, pReq->streamId, pReq->taskId);
|
||||
return 0;
|
||||
} else if (type == STREAM_EXEC_T_START_ALL_TASKS) {
|
||||
(void)streamMetaStartAllTasks(pMeta);
|
||||
code = streamMetaStartAllTasks(pMeta);
|
||||
return 0;
|
||||
} else if (type == STREAM_EXEC_T_RESTART_ALL_TASKS) {
|
||||
(void)restartStreamTasks(pMeta, isLeader);
|
||||
code = restartStreamTasks(pMeta, isLeader);
|
||||
return 0;
|
||||
} else if (type == STREAM_EXEC_T_STOP_ALL_TASKS) {
|
||||
(void)streamMetaStopAllTasks(pMeta);
|
||||
code = streamMetaStopAllTasks(pMeta);
|
||||
return 0;
|
||||
} else if (type == STREAM_EXEC_T_ADD_FAILED_TASK) {
|
||||
int32_t code = streamMetaAddFailedTask(pMeta, pReq->streamId, pReq->taskId);
|
||||
code = streamMetaAddFailedTask(pMeta, pReq->streamId, pReq->taskId);
|
||||
return code;
|
||||
} else if (type == STREAM_EXEC_T_RESUME_TASK) { // task resume to run after idle for a while
|
||||
SStreamTask* pTask = NULL;
|
||||
int32_t code = streamMetaAcquireTask(pMeta, pReq->streamId, pReq->taskId, &pTask);
|
||||
code = streamMetaAcquireTask(pMeta, pReq->streamId, pReq->taskId, &pTask);
|
||||
|
||||
if (pTask != NULL && (code == 0)) {
|
||||
char* pStatus = NULL;
|
||||
|
@ -846,7 +850,7 @@ int32_t tqStreamTaskProcessRunReq(SStreamMeta* pMeta, SRpcMsg* pMsg, bool isLead
|
|||
}
|
||||
|
||||
SStreamTask* pTask = NULL;
|
||||
int32_t code = streamMetaAcquireTask(pMeta, pReq->streamId, pReq->taskId, &pTask);
|
||||
code = streamMetaAcquireTask(pMeta, pReq->streamId, pReq->taskId, &pTask);
|
||||
if ((pTask != NULL) && (code == 0)) { // even in halt status, the data in inputQ must be processed
|
||||
char* p = NULL;
|
||||
if (streamTaskReadyToRun(pTask, &p)) {
|
||||
|
@ -864,7 +868,7 @@ int32_t tqStreamTaskProcessRunReq(SStreamMeta* pMeta, SRpcMsg* pMsg, bool isLead
|
|||
} else { // NOTE: pTask->status.schedStatus is not updated since it is not be handled by the run exec.
|
||||
// todo add one function to handle this
|
||||
tqError("vgId:%d failed to found s-task, taskId:0x%x may have been dropped", vgId, pReq->taskId);
|
||||
return -1;
|
||||
return code;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1229,7 +1233,8 @@ int32_t tqStreamTaskProcessConsenChkptIdReq(SStreamMeta* pMeta, SRpcMsg* pMsg) {
|
|||
tqError(
|
||||
"vgId:%d process set consensus checkpointId req, failed to acquire task:0x%x, it may have been dropped already",
|
||||
pMeta->vgId, req.taskId);
|
||||
(void)streamMetaAddFailedTask(pMeta, req.streamId, req.taskId);
|
||||
// ignore this code to avoid error code over write
|
||||
int32_t ret = streamMetaAddFailedTask(pMeta, req.streamId, req.taskId);
|
||||
return code;
|
||||
}
|
||||
|
||||
|
|
|
@ -117,7 +117,7 @@ typedef struct {
|
|||
|
||||
static void tsdbGetRocksPath(STsdb *pTsdb, char *path) {
|
||||
SVnode *pVnode = pTsdb->pVnode;
|
||||
(void)vnodeGetPrimaryDir(pTsdb->path, pVnode->diskPrimary, pVnode->pTfs, path, TSDB_FILENAME_LEN);
|
||||
vnodeGetPrimaryDir(pTsdb->path, pVnode->diskPrimary, pVnode->pTfs, path, TSDB_FILENAME_LEN);
|
||||
|
||||
int32_t offset = strlen(path);
|
||||
snprintf(path + offset, TSDB_FILENAME_LEN - offset - 1, "%scache.rdb", TD_DIRSEP);
|
||||
|
@ -582,6 +582,8 @@ _exit:
|
|||
taosMemoryFree(pCol->rowKey.pks[j].pData);
|
||||
}
|
||||
}
|
||||
|
||||
(void)memset(pCol, 0, sizeof(SLastCol));
|
||||
}
|
||||
|
||||
TAOS_RETURN(code);
|
||||
|
@ -643,7 +645,9 @@ static int32_t tsdbCacheNewTableColumn(STsdb *pTsdb, int64_t uid, int16_t cid, i
|
|||
LRUStatus status = taosLRUCacheInsert(pCache, pLastKey, ROCKS_KEY_LEN, pLastCol, charge, tsdbCacheDeleter, NULL,
|
||||
TAOS_LRU_PRIORITY_LOW, &pTsdb->flushState);
|
||||
if (status != TAOS_LRU_STATUS_OK) {
|
||||
// code = -1;
|
||||
tsdbError("vgId:%d, %s failed at line %d status %d.", TD_VID(pTsdb->pVnode), __func__, __LINE__, status);
|
||||
tsdbCacheFreeSLastColItem(pLastCol);
|
||||
code = TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
_exit:
|
||||
|
@ -1015,29 +1019,6 @@ static int32_t tsdbCacheUpdateValue(SValue *pOld, SValue *pNew) {
|
|||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||
}
|
||||
|
||||
#ifdef BUILD_NO_CALL
|
||||
static void tsdbCacheUpdateLastCol(SLastCol *pLastCol, SRowKey *pRowKey, SColVal *pColVal) {
|
||||
// update rowkey
|
||||
pLastCol->rowKey.ts = pRowKey->ts;
|
||||
pLastCol->rowKey.numOfPKs = pRowKey->numOfPKs;
|
||||
for (int8_t i = 0; i < pRowKey->numOfPKs; i++) {
|
||||
SValue *pPKValue = &pLastCol->rowKey.pks[i];
|
||||
SValue *pNewPKValue = &pRowKey->pks[i];
|
||||
|
||||
(void)tsdbCacheUpdateValue(pPKValue, pNewPKValue);
|
||||
}
|
||||
|
||||
// update colval
|
||||
pLastCol->colVal.cid = pColVal->cid;
|
||||
pLastCol->colVal.flag = pColVal->flag;
|
||||
(void)tsdbCacheUpdateValue(&pLastCol->colVal.value, &pColVal->value);
|
||||
|
||||
if (!pLastCol->dirty) {
|
||||
pLastCol->dirty = 1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static void tsdbCacheUpdateLastColToNone(SLastCol *pLastCol, ELastCacheStatus cacheStatus) {
|
||||
// update rowkey
|
||||
pLastCol->rowKey.ts = TSKEY_MIN;
|
||||
|
@ -1104,8 +1085,9 @@ static int32_t tsdbCachePutToLRU(STsdb *pTsdb, SLastKey *pLastKey, SLastCol *pLa
|
|||
LRUStatus status = taosLRUCacheInsert(pTsdb->lruCache, pLastKey, ROCKS_KEY_LEN, pLRULastCol, charge, tsdbCacheDeleter,
|
||||
NULL, TAOS_LRU_PRIORITY_LOW, &pTsdb->flushState);
|
||||
if (TAOS_LRU_STATUS_OK != status && TAOS_LRU_STATUS_OK_OVERWRITTEN != status) {
|
||||
tsdbError("tsdb/cache/putlru: vgId:%d, failed to insert status %d.", TD_VID(pTsdb->pVnode), status);
|
||||
code = TSDB_CODE_INVALID_DATA_FMT;
|
||||
tsdbError("vgId:%d, %s failed at line %d status %d.", TD_VID(pTsdb->pVnode), __func__, __LINE__, status);
|
||||
tsdbCacheFreeSLastColItem(pLRULastCol);
|
||||
code = TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
_exit:
|
||||
|
@ -1217,23 +1199,23 @@ static int32_t tsdbCacheUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, SArray
|
|||
tsdbError("tsdb/cache: vgId:%d, deserialize failed since %s.", TD_VID(pTsdb->pVnode), tstrerror(code));
|
||||
}
|
||||
*/
|
||||
SLastCol *PToFree = pLastCol;
|
||||
SLastCol *pToFree = pLastCol;
|
||||
|
||||
if (pLastCol && pLastCol->cacheStatus == TSDB_LAST_CACHE_NO_CACHE) {
|
||||
if ((code = tsdbCachePutToLRU(pTsdb, &idxKey->key, pLastCol)) != TSDB_CODE_SUCCESS) {
|
||||
tsdbError("tsdb/cache: vgId:%d, put lru failed at line %d since %s.", TD_VID(pTsdb->pVnode), lino,
|
||||
tstrerror(code));
|
||||
taosMemoryFreeClear(PToFree);
|
||||
taosMemoryFreeClear(pToFree);
|
||||
break;
|
||||
}
|
||||
|
||||
// cache invalid => skip update
|
||||
taosMemoryFreeClear(PToFree);
|
||||
taosMemoryFreeClear(pToFree);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (IS_LAST_KEY(idxKey->key) && !COL_VAL_IS_VALUE(pColVal)) {
|
||||
taosMemoryFreeClear(PToFree);
|
||||
taosMemoryFreeClear(pToFree);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1247,18 +1229,18 @@ static int32_t tsdbCacheUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, SArray
|
|||
if ((code = tsdbCachePutToRocksdb(pTsdb, &idxKey->key, &lastColTmp)) != TSDB_CODE_SUCCESS) {
|
||||
tsdbError("tsdb/cache: vgId:%d, put rocks failed at line %d since %s.", TD_VID(pTsdb->pVnode), lino,
|
||||
tstrerror(code));
|
||||
taosMemoryFreeClear(PToFree);
|
||||
taosMemoryFreeClear(pToFree);
|
||||
break;
|
||||
}
|
||||
if ((code = tsdbCachePutToLRU(pTsdb, &idxKey->key, &lastColTmp)) != TSDB_CODE_SUCCESS) {
|
||||
tsdbError("tsdb/cache: vgId:%d, put lru failed at line %d since %s.", TD_VID(pTsdb->pVnode), lino,
|
||||
tstrerror(code));
|
||||
taosMemoryFreeClear(PToFree);
|
||||
taosMemoryFreeClear(pToFree);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
taosMemoryFreeClear(PToFree);
|
||||
taosMemoryFreeClear(pToFree);
|
||||
}
|
||||
|
||||
rocksMayWrite(pTsdb, true, false);
|
||||
|
@ -1586,14 +1568,17 @@ static int32_t tsdbCacheLoadFromRaw(STsdb *pTsdb, tb_uid_t uid, SArray *pLastArr
|
|||
pLastCol = pTmpLastCol;
|
||||
code = tsdbCacheReallocSLastCol(pLastCol, &charge);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
taosMemoryFree(pTmpLastCol);
|
||||
taosMemoryFree(pLastCol);
|
||||
TAOS_CHECK_EXIT(code);
|
||||
}
|
||||
|
||||
LRUStatus status = taosLRUCacheInsert(pCache, &idxKey->key, ROCKS_KEY_LEN, pLastCol, charge, tsdbCacheDeleter, NULL,
|
||||
TAOS_LRU_PRIORITY_LOW, &pTsdb->flushState);
|
||||
if (status != TAOS_LRU_STATUS_OK) {
|
||||
// code = -1;
|
||||
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);
|
||||
TAOS_CHECK_EXIT(TSDB_CODE_FAILED);
|
||||
}
|
||||
|
||||
// store result back to rocks cache
|
||||
|
@ -1672,14 +1657,13 @@ static int32_t tsdbCacheLoadFromRocks(STsdb *pTsdb, tb_uid_t uid, SArray *pLastA
|
|||
}
|
||||
|
||||
(void)tsdbCacheDeserialize(values_list[i], values_list_sizes[i], &pLastCol);
|
||||
SLastCol *PToFree = pLastCol;
|
||||
SLastCol *pToFree = pLastCol;
|
||||
SIdxKey *idxKey = &((SIdxKey *)TARRAY_DATA(remainCols))[j];
|
||||
if (pLastCol && pLastCol->cacheStatus != TSDB_LAST_CACHE_NO_CACHE) {
|
||||
SLastCol *pTmpLastCol = taosMemoryCalloc(1, sizeof(SLastCol));
|
||||
if (!pTmpLastCol) {
|
||||
taosMemoryFreeClear(PToFree);
|
||||
code = terrno;
|
||||
goto _exit;
|
||||
taosMemoryFreeClear(pToFree);
|
||||
TAOS_CHECK_EXIT(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
size_t charge = 0;
|
||||
|
@ -1687,18 +1671,28 @@ static int32_t tsdbCacheLoadFromRocks(STsdb *pTsdb, tb_uid_t uid, SArray *pLastA
|
|||
pLastCol = pTmpLastCol;
|
||||
code = tsdbCacheReallocSLastCol(pLastCol, &charge);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
taosMemoryFree(pTmpLastCol);
|
||||
taosMemoryFreeClear(PToFree);
|
||||
goto _exit;
|
||||
taosMemoryFreeClear(pLastCol);
|
||||
taosMemoryFreeClear(pToFree);
|
||||
TAOS_CHECK_EXIT(code);
|
||||
}
|
||||
|
||||
SLastCol lastCol = *pLastCol;
|
||||
TAOS_CHECK_EXIT(tsdbCacheReallocSLastCol(&lastCol, NULL));
|
||||
code = tsdbCacheReallocSLastCol(&lastCol, NULL);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
tsdbCacheFreeSLastColItem(pLastCol);
|
||||
taosMemoryFreeClear(pLastCol);
|
||||
taosMemoryFreeClear(pToFree);
|
||||
TAOS_CHECK_EXIT(code);
|
||||
}
|
||||
|
||||
LRUStatus status = taosLRUCacheInsert(pCache, &idxKey->key, ROCKS_KEY_LEN, pLastCol, charge, tsdbCacheDeleter,
|
||||
NULL, TAOS_LRU_PRIORITY_LOW, &pTsdb->flushState);
|
||||
if (status != TAOS_LRU_STATUS_OK) {
|
||||
code = -1;
|
||||
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);
|
||||
}
|
||||
|
||||
taosArraySet(pLastArray, idxKey->idx, &lastCol);
|
||||
|
@ -1708,7 +1702,7 @@ static int32_t tsdbCacheLoadFromRocks(STsdb *pTsdb, tb_uid_t uid, SArray *pLastA
|
|||
++j;
|
||||
}
|
||||
|
||||
taosMemoryFreeClear(PToFree);
|
||||
taosMemoryFreeClear(pToFree);
|
||||
}
|
||||
|
||||
if (TARRAY_SIZE(remainCols) > 0) {
|
||||
|
@ -2159,7 +2153,7 @@ static int32_t loadTombFromBlk(const TTombBlkArray *pTombBlkArray, SCacheRowsRea
|
|||
uint64_t uid = uidList[j];
|
||||
STableLoadInfo *pInfo = getTableLoadInfo(pReader, uid);
|
||||
if (!pInfo) {
|
||||
(void)tTombBlockDestroy(&block);
|
||||
tTombBlockDestroy(&block);
|
||||
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
|
@ -2231,7 +2225,7 @@ static int32_t loadTombFromBlk(const TTombBlkArray *pTombBlkArray, SCacheRowsRea
|
|||
}
|
||||
}
|
||||
|
||||
(void)tTombBlockDestroy(&block);
|
||||
tTombBlockDestroy(&block);
|
||||
|
||||
if (finished) {
|
||||
TAOS_RETURN(code);
|
||||
|
@ -2538,7 +2532,7 @@ static int32_t getNextRowFromFS(void *iter, TSDBROW **ppRow, bool *pIgnoreEarlie
|
|||
if (!state->pBrinBlock) {
|
||||
state->pBrinBlock = &state->brinBlock;
|
||||
} else {
|
||||
(void)tBrinBlockClear(&state->brinBlock);
|
||||
tBrinBlockClear(&state->brinBlock);
|
||||
}
|
||||
|
||||
TAOS_CHECK_GOTO(tsdbDataFileReadBrinBlock(state->pr->pFileReader, pBrinBlk, &state->brinBlock), &lino, _err);
|
||||
|
@ -2550,7 +2544,7 @@ static int32_t getNextRowFromFS(void *iter, TSDBROW **ppRow, bool *pIgnoreEarlie
|
|||
if (SFSNEXTROW_BRINBLOCK == state->state) {
|
||||
_next_brinrecord:
|
||||
if (state->iBrinRecord < 0) { // empty brin block, goto _next_brinindex
|
||||
(void)tBrinBlockClear(&state->brinBlock);
|
||||
tBrinBlockClear(&state->brinBlock);
|
||||
goto _next_brinindex;
|
||||
}
|
||||
|
||||
|
@ -2691,12 +2685,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);
|
||||
|
@ -2809,7 +2805,7 @@ int32_t clearNextRowFromFS(void *iter) {
|
|||
}
|
||||
|
||||
if (state->pBrinBlock) {
|
||||
(void)tBrinBlockDestroy(state->pBrinBlock);
|
||||
tBrinBlockDestroy(state->pBrinBlock);
|
||||
state->pBrinBlock = NULL;
|
||||
}
|
||||
|
||||
|
@ -2842,7 +2838,7 @@ static void clearLastFileSet(SFSNextRowIter *state) {
|
|||
}
|
||||
|
||||
if (state->pr->pFileReader) {
|
||||
(void)tsdbDataFileReaderClose(&state->pr->pFileReader);
|
||||
tsdbDataFileReaderClose(&state->pr->pFileReader);
|
||||
state->pr->pFileReader = NULL;
|
||||
|
||||
state->pr->pCurFileSet = NULL;
|
||||
|
@ -2927,9 +2923,7 @@ _err:
|
|||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
static int32_t nextRowIterClose(CacheNextRowIter *pIter) {
|
||||
int32_t code = 0;
|
||||
|
||||
static void nextRowIterClose(CacheNextRowIter *pIter) {
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
if (pIter->input[i].nextRowClearFn) {
|
||||
(void)pIter->input[i].nextRowClearFn(pIter->input[i].iter);
|
||||
|
@ -2943,9 +2937,6 @@ static int32_t nextRowIterClose(CacheNextRowIter *pIter) {
|
|||
if (pIter->pMemDelData) {
|
||||
taosArrayDestroy(pIter->pMemDelData);
|
||||
}
|
||||
|
||||
_err:
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
// iterate next row non deleted backward ts, version (from high to low)
|
||||
|
@ -3260,7 +3251,7 @@ static int32_t mergeLastCid(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray, SC
|
|||
}
|
||||
*ppLastArray = pColArray;
|
||||
|
||||
(void)nextRowIterClose(&iter);
|
||||
nextRowIterClose(&iter);
|
||||
taosArrayDestroy(aColArray);
|
||||
|
||||
TAOS_RETURN(code);
|
||||
|
@ -3381,7 +3372,7 @@ static int32_t mergeLastRowCid(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray,
|
|||
}
|
||||
*ppLastArray = pColArray;
|
||||
|
||||
(void)nextRowIterClose(&iter);
|
||||
nextRowIterClose(&iter);
|
||||
taosArrayDestroy(aColArray);
|
||||
|
||||
TAOS_RETURN(code);
|
||||
|
|
|
@ -387,7 +387,7 @@ void tsdbCacherowsReaderClose(void* pReader) {
|
|||
}
|
||||
|
||||
if (p->pFileReader) {
|
||||
(void) tsdbDataFileReaderClose(&p->pFileReader);
|
||||
tsdbDataFileReaderClose(&p->pFileReader);
|
||||
p->pFileReader = NULL;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -251,8 +251,8 @@ _exit:
|
|||
}
|
||||
|
||||
static int32_t tsdbCommitCloseIter(SCommitter2 *committer) {
|
||||
TAOS_UNUSED(tsdbIterMergerClose(&committer->tombIterMerger));
|
||||
TAOS_UNUSED(tsdbIterMergerClose(&committer->dataIterMerger));
|
||||
tsdbIterMergerClose(&committer->tombIterMerger);
|
||||
tsdbIterMergerClose(&committer->dataIterMerger);
|
||||
TARRAY2_CLEAR(committer->tombIterArray, tsdbIterClose);
|
||||
TARRAY2_CLEAR(committer->dataIterArray, tsdbIterClose);
|
||||
return 0;
|
||||
|
@ -418,7 +418,7 @@ static int32_t tsdbCommitInfoDestroy(STsdb *pTsdb) {
|
|||
taosMemoryFree(info);
|
||||
}
|
||||
|
||||
TAOS_UNUSED(vHashDestroy(&pTsdb->commitInfo->ht));
|
||||
vHashDestroy(&pTsdb->commitInfo->ht);
|
||||
taosArrayDestroy(pTsdb->commitInfo->arr);
|
||||
pTsdb->commitInfo->arr = NULL;
|
||||
taosMemoryFreeClear(pTsdb->commitInfo);
|
||||
|
@ -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) {
|
||||
|
@ -669,7 +669,7 @@ int32_t tsdbCommitBegin(STsdb *tsdb, SCommitInfo *info) {
|
|||
(void)taosThreadMutexLock(&tsdb->mutex);
|
||||
tsdb->imem = NULL;
|
||||
(void)taosThreadMutexUnlock(&tsdb->mutex);
|
||||
TAOS_UNUSED(tsdbUnrefMemTable(imem, NULL, true));
|
||||
tsdbUnrefMemTable(imem, NULL, true);
|
||||
} else {
|
||||
SCommitter2 committer = {0};
|
||||
|
||||
|
@ -710,14 +710,14 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
(void)taosThreadMutexUnlock(&tsdb->mutex);
|
||||
|
||||
TAOS_UNUSED(tsdbCommitInfoDestroy(tsdb));
|
||||
TAOS_UNUSED(tsdbUnrefMemTable(pMemTable, NULL, true));
|
||||
tsdbUnrefMemTable(pMemTable, NULL, true);
|
||||
}
|
||||
|
||||
_exit:
|
||||
|
@ -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);
|
||||
|
|
|
@ -35,7 +35,7 @@ int32_t tsdbDataFileRAWReaderOpen(const char *fname, const SDataFileRAWReaderCon
|
|||
}
|
||||
} else {
|
||||
char fname1[TSDB_FILENAME_LEN];
|
||||
(void)tsdbTFileName(config->tsdb, &config->file, fname1);
|
||||
tsdbTFileName(config->tsdb, &config->file, fname1);
|
||||
TAOS_CHECK_GOTO(tsdbOpenFile(fname1, config->tsdb, TD_FILE_READ, &reader[0]->fd, lcn), &lino, _exit);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -157,7 +157,7 @@ static int32_t tsdbDataFileRAWWriterOpenDataFD(SDataFileRAWWriter *writer) {
|
|||
flag |= (TD_FILE_CREATE | TD_FILE_TRUNC);
|
||||
}
|
||||
|
||||
(void)tsdbTFileName(writer->config->tsdb, &writer->file, fname);
|
||||
tsdbTFileName(writer->config->tsdb, &writer->file, fname);
|
||||
TAOS_CHECK_GOTO(tsdbOpenFile(fname, writer->config->tsdb, flag, &writer->fd, writer->file.lcn), &lino, _exit);
|
||||
|
||||
_exit:
|
||||
|
@ -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;
|
||||
|
|
|
@ -135,7 +135,7 @@ int32_t tsdbDataFileReaderOpen(const char *fname[], const SDataFileReaderConfig
|
|||
for (int32_t i = 0; i < TSDB_FTYPE_MAX; ++i) {
|
||||
if (config->files[i].exist) {
|
||||
char fname1[TSDB_FILENAME_LEN];
|
||||
(void)tsdbTFileName(config->tsdb, &config->files[i].file, fname1);
|
||||
tsdbTFileName(config->tsdb, &config->files[i].file, fname1);
|
||||
int32_t lcn = config->files[i].file.lcn;
|
||||
TAOS_CHECK_GOTO(tsdbOpenFile(fname1, config->tsdb, TD_FILE_READ, &reader[0]->fd[i], lcn), &lino, _exit);
|
||||
}
|
||||
|
@ -150,9 +150,9 @@ _exit:
|
|||
return code;
|
||||
}
|
||||
|
||||
int32_t tsdbDataFileReaderClose(SDataFileReader **reader) {
|
||||
void tsdbDataFileReaderClose(SDataFileReader **reader) {
|
||||
if (reader[0] == NULL) {
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
|
||||
TARRAY2_DESTROY(reader[0]->tombBlkArray, NULL);
|
||||
|
@ -170,7 +170,6 @@ int32_t tsdbDataFileReaderClose(SDataFileReader **reader) {
|
|||
|
||||
taosMemoryFree(reader[0]);
|
||||
reader[0] = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t tsdbDataFileReadBrinBlk(SDataFileReader *reader, const TBrinBlkArray **brinBlkArray) {
|
||||
|
@ -230,7 +229,7 @@ int32_t tsdbDataFileReadBrinBlock(SDataFileReader *reader, const SBrinBlk *brinB
|
|||
|
||||
// decode brin block
|
||||
SBufferReader br = BUFFER_READER_INITIALIZER(0, buffer);
|
||||
(void)tBrinBlockClear(brinBlock);
|
||||
tBrinBlockClear(brinBlock);
|
||||
brinBlock->numOfPKs = brinBlk->numOfPKs;
|
||||
brinBlock->numOfRecords = brinBlk->numRec;
|
||||
for (int32_t i = 0; i < 10; i++) { // int64_t
|
||||
|
@ -677,20 +676,20 @@ static int32_t tsdbDataFileWriterCloseAbort(SDataFileWriter *writer) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int32_t tsdbDataFileWriterDoClose(SDataFileWriter *writer) {
|
||||
static void tsdbDataFileWriterDoClose(SDataFileWriter *writer) {
|
||||
if (writer->ctx->reader) {
|
||||
(void)tsdbDataFileReaderClose(&writer->ctx->reader);
|
||||
tsdbDataFileReaderClose(&writer->ctx->reader);
|
||||
}
|
||||
|
||||
tTombBlockDestroy(writer->tombBlock);
|
||||
TARRAY2_DESTROY(writer->tombBlkArray, NULL);
|
||||
tBlockDataDestroy(writer->blockData);
|
||||
(void)tBrinBlockDestroy(writer->brinBlock);
|
||||
tBrinBlockDestroy(writer->brinBlock);
|
||||
TARRAY2_DESTROY(writer->brinBlkArray, NULL);
|
||||
|
||||
tTombBlockDestroy(writer->ctx->tombBlock);
|
||||
tBlockDataDestroy(writer->ctx->blockData);
|
||||
(void)tBrinBlockDestroy(writer->ctx->brinBlock);
|
||||
tBrinBlockDestroy(writer->ctx->brinBlock);
|
||||
|
||||
for (int32_t i = 0; i < ARRAY_SIZE(writer->local); ++i) {
|
||||
tBufferDestroy(writer->local + i);
|
||||
|
@ -698,7 +697,6 @@ static int32_t tsdbDataFileWriterDoClose(SDataFileWriter *writer) {
|
|||
|
||||
tDestroyTSchema(writer->skmRow->pTSchema);
|
||||
tDestroyTSchema(writer->skmTb->pTSchema);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t tsdbDataFileWriterDoOpenReader(SDataFileWriter *writer) {
|
||||
|
@ -819,10 +817,9 @@ _exit:
|
|||
return code;
|
||||
}
|
||||
|
||||
int32_t tsdbWriterUpdVerRange(SVersionRange *range, int64_t minVer, int64_t maxVer) {
|
||||
void tsdbWriterUpdVerRange(SVersionRange *range, int64_t minVer, int64_t maxVer) {
|
||||
range->minVer = TMIN(range->minVer, minVer);
|
||||
range->maxVer = TMAX(range->maxVer, maxVer);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t tsdbFileWriteBrinBlock(STsdbFD *fd, SBrinBlock *brinBlock, uint32_t cmprAlg, int64_t *fileSize,
|
||||
|
@ -850,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;
|
||||
|
@ -869,7 +866,7 @@ int32_t tsdbFileWriteBrinBlock(STsdbFD *fd, SBrinBlock *brinBlock, uint32_t cmpr
|
|||
}
|
||||
}
|
||||
|
||||
(void)tsdbWriterUpdVerRange(range, brinBlk.minVer, brinBlk.maxVer);
|
||||
tsdbWriterUpdVerRange(range, brinBlk.minVer, brinBlk.maxVer);
|
||||
|
||||
// write to file
|
||||
for (int32_t i = 0; i < 10; ++i) {
|
||||
|
@ -930,7 +927,7 @@ int32_t tsdbFileWriteBrinBlock(STsdbFD *fd, SBrinBlock *brinBlock, uint32_t cmpr
|
|||
// append to brinBlkArray
|
||||
TAOS_CHECK_RETURN(TARRAY2_APPEND_PTR(brinBlkArray, &brinBlk));
|
||||
|
||||
(void)tBrinBlockClear(brinBlock);
|
||||
tBrinBlockClear(brinBlock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1032,7 +1029,7 @@ static int32_t tsdbDataFileDoWriteBlockData(SDataFileWriter *writer, SBlockData
|
|||
}
|
||||
}
|
||||
|
||||
(void)tsdbWriterUpdVerRange(&writer->ctx->range, record->minVer, record->maxVer);
|
||||
tsdbWriterUpdVerRange(&writer->ctx->range, record->minVer, record->maxVer);
|
||||
|
||||
code = metaGetColCmpr(writer->config->tsdb->pVnode->pMeta, bData->suid != 0 ? bData->suid : bData->uid,
|
||||
&cmprInfo.pColCmpr);
|
||||
|
@ -1163,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;
|
||||
|
@ -1173,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);
|
||||
|
@ -1383,7 +1382,7 @@ int32_t tsdbFileWriteTombBlock(STsdbFD *fd, STombBlock *tombBlock, int8_t cmprAl
|
|||
}
|
||||
}
|
||||
|
||||
(void)tsdbWriterUpdVerRange(range, tombBlk.minVer, tombBlk.maxVer);
|
||||
tsdbWriterUpdVerRange(range, tombBlk.minVer, tombBlk.maxVer);
|
||||
|
||||
for (int32_t i = 0; i < ARRAY_SIZE(tombBlock->buffers); i++) {
|
||||
tBufferClear(buffer0);
|
||||
|
@ -1615,10 +1614,9 @@ _exit:
|
|||
return code;
|
||||
}
|
||||
|
||||
int32_t tsdbTFileUpdVerRange(STFile *f, SVersionRange range) {
|
||||
void tsdbTFileUpdVerRange(STFile *f, SVersionRange range) {
|
||||
f->minVer = TMIN(f->minVer, range.minVer);
|
||||
f->maxVer = TMAX(f->maxVer, range.maxVer);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t tsdbDataFileWriterCloseCommit(SDataFileWriter *writer, TFileOpArray *opArr) {
|
||||
|
@ -1658,8 +1656,8 @@ static int32_t tsdbDataFileWriterCloseCommit(SDataFileWriter *writer, TFileOpArr
|
|||
.fid = writer->config->fid,
|
||||
.nf = writer->files[ftype],
|
||||
};
|
||||
(void)tsdbTFileUpdVerRange(&op.nf, ofRange);
|
||||
(void)tsdbTFileUpdVerRange(&op.nf, writer->ctx->range);
|
||||
tsdbTFileUpdVerRange(&op.nf, ofRange);
|
||||
tsdbTFileUpdVerRange(&op.nf, writer->ctx->range);
|
||||
TAOS_CHECK_GOTO(TARRAY2_APPEND(opArr, op), &lino, _exit);
|
||||
|
||||
// .data
|
||||
|
@ -1670,7 +1668,7 @@ static int32_t tsdbDataFileWriterCloseCommit(SDataFileWriter *writer, TFileOpArr
|
|||
.fid = writer->config->fid,
|
||||
.nf = writer->files[ftype],
|
||||
};
|
||||
(void)tsdbTFileUpdVerRange(&op.nf, writer->ctx->range);
|
||||
tsdbTFileUpdVerRange(&op.nf, writer->ctx->range);
|
||||
TAOS_CHECK_GOTO(TARRAY2_APPEND(opArr, op), &lino, _exit);
|
||||
} else if (writer->config->files[ftype].file.size != writer->files[ftype].size) {
|
||||
op = (STFileOp){
|
||||
|
@ -1679,7 +1677,7 @@ static int32_t tsdbDataFileWriterCloseCommit(SDataFileWriter *writer, TFileOpArr
|
|||
.of = writer->config->files[ftype].file,
|
||||
.nf = writer->files[ftype],
|
||||
};
|
||||
(void)tsdbTFileUpdVerRange(&op.nf, writer->ctx->range);
|
||||
tsdbTFileUpdVerRange(&op.nf, writer->ctx->range);
|
||||
TAOS_CHECK_GOTO(TARRAY2_APPEND(opArr, op), &lino, _exit);
|
||||
}
|
||||
|
||||
|
@ -1691,7 +1689,7 @@ static int32_t tsdbDataFileWriterCloseCommit(SDataFileWriter *writer, TFileOpArr
|
|||
.fid = writer->config->fid,
|
||||
.nf = writer->files[ftype],
|
||||
};
|
||||
(void)tsdbTFileUpdVerRange(&op.nf, writer->ctx->range);
|
||||
tsdbTFileUpdVerRange(&op.nf, writer->ctx->range);
|
||||
TAOS_CHECK_GOTO(TARRAY2_APPEND(opArr, op), &lino, _exit);
|
||||
} else if (writer->config->files[ftype].file.size != writer->files[ftype].size) {
|
||||
op = (STFileOp){
|
||||
|
@ -1700,7 +1698,7 @@ static int32_t tsdbDataFileWriterCloseCommit(SDataFileWriter *writer, TFileOpArr
|
|||
.of = writer->config->files[ftype].file,
|
||||
.nf = writer->files[ftype],
|
||||
};
|
||||
(void)tsdbTFileUpdVerRange(&op.nf, writer->ctx->range);
|
||||
tsdbTFileUpdVerRange(&op.nf, writer->ctx->range);
|
||||
TAOS_CHECK_GOTO(TARRAY2_APPEND(opArr, op), &lino, _exit);
|
||||
}
|
||||
}
|
||||
|
@ -1734,8 +1732,8 @@ static int32_t tsdbDataFileWriterCloseCommit(SDataFileWriter *writer, TFileOpArr
|
|||
.fid = writer->config->fid,
|
||||
.nf = writer->files[ftype],
|
||||
};
|
||||
(void)tsdbTFileUpdVerRange(&op.nf, ofRange);
|
||||
(void)tsdbTFileUpdVerRange(&op.nf, writer->ctx->tombRange);
|
||||
tsdbTFileUpdVerRange(&op.nf, ofRange);
|
||||
tsdbTFileUpdVerRange(&op.nf, writer->ctx->tombRange);
|
||||
TAOS_CHECK_GOTO(TARRAY2_APPEND(opArr, op), &lino, _exit);
|
||||
}
|
||||
int32_t encryptAlgorithm = writer->config->tsdb->pVnode->config.tsdbCfg.encryptAlgorithm;
|
||||
|
@ -1772,7 +1770,7 @@ static int32_t tsdbDataFileWriterOpenDataFD(SDataFileWriter *writer) {
|
|||
}
|
||||
|
||||
int32_t lcn = writer->files[ftype].lcn;
|
||||
(void)tsdbTFileName(writer->config->tsdb, &writer->files[ftype], fname);
|
||||
tsdbTFileName(writer->config->tsdb, &writer->files[ftype], fname);
|
||||
TAOS_CHECK_GOTO(tsdbOpenFile(fname, writer->config->tsdb, flag, &writer->fd[ftype], lcn), &lino, _exit);
|
||||
|
||||
if (writer->files[ftype].size == 0) {
|
||||
|
@ -1822,7 +1820,7 @@ int32_t tsdbDataFileWriterClose(SDataFileWriter **writer, bool abort, TFileOpArr
|
|||
} else {
|
||||
TAOS_CHECK_GOTO(tsdbDataFileWriterCloseCommit(writer[0], opArr), &lino, _exit);
|
||||
}
|
||||
(void)tsdbDataFileWriterDoClose(writer[0]);
|
||||
tsdbDataFileWriterDoClose(writer[0]);
|
||||
}
|
||||
taosMemoryFree(writer[0]);
|
||||
writer[0] = NULL;
|
||||
|
@ -1935,7 +1933,7 @@ static int32_t tsdbDataFileWriterOpenTombFD(SDataFileWriter *writer) {
|
|||
int32_t flag = (TD_FILE_READ | TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC);
|
||||
|
||||
int32_t lcn = writer->files[ftype].lcn;
|
||||
(void)tsdbTFileName(writer->config->tsdb, writer->files + ftype, fname);
|
||||
tsdbTFileName(writer->config->tsdb, writer->files + ftype, fname);
|
||||
|
||||
TAOS_CHECK_GOTO(tsdbOpenFile(fname, writer->config->tsdb, flag, &writer->fd[ftype], lcn), &lino, _exit);
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ typedef struct SDataFileReaderConfig {
|
|||
|
||||
int32_t tsdbDataFileReaderOpen(const char *fname[/* TSDB_FTYPE_MAX */], const SDataFileReaderConfig *config,
|
||||
SDataFileReader **reader);
|
||||
int32_t tsdbDataFileReaderClose(SDataFileReader **reader);
|
||||
void tsdbDataFileReaderClose(SDataFileReader **reader);
|
||||
// .head
|
||||
int32_t tsdbDataFileReadBrinBlk(SDataFileReader *reader, const TBrinBlkArray **brinBlkArray);
|
||||
int32_t tsdbDataFileReadBrinBlock(SDataFileReader *reader, const SBrinBlk *brinBlk, SBrinBlock *brinBlock);
|
||||
|
@ -115,8 +115,8 @@ int32_t tsdbFileWriteTombFooter(STsdbFD *fd, const STombFooter *footer, int64_t
|
|||
char *encryptKey);
|
||||
|
||||
// utils
|
||||
int32_t tsdbWriterUpdVerRange(SVersionRange *range, int64_t minVer, int64_t maxVer);
|
||||
int32_t tsdbTFileUpdVerRange(STFile *f, SVersionRange range);
|
||||
void tsdbWriterUpdVerRange(SVersionRange *range, int64_t minVer, int64_t maxVer);
|
||||
void tsdbTFileUpdVerRange(STFile *f, SVersionRange range);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -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)) {
|
||||
|
@ -270,14 +272,14 @@ void tsdbGetCurrentFName(STsdb *pTsdb, char *current, char *current_t) {
|
|||
|
||||
// CURRENT
|
||||
if (current) {
|
||||
(void)vnodeGetPrimaryDir(pTsdb->path, pVnode->diskPrimary, pVnode->pTfs, current, TSDB_FILENAME_LEN);
|
||||
vnodeGetPrimaryDir(pTsdb->path, pVnode->diskPrimary, pVnode->pTfs, current, TSDB_FILENAME_LEN);
|
||||
offset = strlen(current);
|
||||
snprintf(current + offset, TSDB_FILENAME_LEN - offset - 1, "%sCURRENT", TD_DIRSEP);
|
||||
}
|
||||
|
||||
// CURRENT.t
|
||||
if (current_t) {
|
||||
(void)vnodeGetPrimaryDir(pTsdb->path, pVnode->diskPrimary, pVnode->pTfs, current_t, TSDB_FILENAME_LEN);
|
||||
vnodeGetPrimaryDir(pTsdb->path, pVnode->diskPrimary, pVnode->pTfs, current_t, TSDB_FILENAME_LEN);
|
||||
offset = strlen(current_t);
|
||||
snprintf(current_t + offset, TSDB_FILENAME_LEN - offset - 1, "%sCURRENT.t", TD_DIRSEP);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -340,21 +342,21 @@ static int32_t tsdbRemoveFileSet(STsdb *pTsdb, SDFileSet *pSet) {
|
|||
int32_t nRef = atomic_sub_fetch_32(&pSet->pHeadF->nRef, 1);
|
||||
if (nRef == 0) {
|
||||
tsdbHeadFileName(pTsdb, pSet->diskId, pSet->fid, pSet->pHeadF, fname);
|
||||
(void)taosRemoveFile(fname);
|
||||
tsdbRemoveFile(fname);
|
||||
taosMemoryFree(pSet->pHeadF);
|
||||
}
|
||||
|
||||
nRef = atomic_sub_fetch_32(&pSet->pDataF->nRef, 1);
|
||||
if (nRef == 0) {
|
||||
tsdbDataFileName(pTsdb, pSet->diskId, pSet->fid, pSet->pDataF, fname);
|
||||
(void)taosRemoveFile(fname);
|
||||
tsdbRemoveFile(fname);
|
||||
taosMemoryFree(pSet->pDataF);
|
||||
}
|
||||
|
||||
nRef = atomic_sub_fetch_32(&pSet->pSmaF->nRef, 1);
|
||||
if (nRef == 0) {
|
||||
tsdbSmaFileName(pTsdb, pSet->diskId, pSet->fid, pSet->pSmaF, fname);
|
||||
(void)taosRemoveFile(fname);
|
||||
tsdbRemoveFile(fname);
|
||||
taosMemoryFree(pSet->pSmaF);
|
||||
}
|
||||
|
||||
|
@ -362,7 +364,7 @@ static int32_t tsdbRemoveFileSet(STsdb *pTsdb, SDFileSet *pSet) {
|
|||
nRef = atomic_sub_fetch_32(&pSet->aSttF[iStt]->nRef, 1);
|
||||
if (nRef == 0) {
|
||||
tsdbSttFileName(pTsdb, pSet->diskId, pSet->fid, pSet->aSttF[iStt], fname);
|
||||
(void)taosRemoveFile(fname);
|
||||
tsdbRemoveFile(fname);
|
||||
taosMemoryFree(pSet->aSttF[iStt]);
|
||||
}
|
||||
}
|
||||
|
@ -449,7 +451,7 @@ static int32_t tsdbMergeFileSet(STsdb *pTsdb, SDFileSet *pSetOld, SDFileSet *pSe
|
|||
nRef = atomic_sub_fetch_32(&pHeadF->nRef, 1);
|
||||
if (nRef == 0) {
|
||||
tsdbHeadFileName(pTsdb, pSetOld->diskId, pSetOld->fid, pHeadF, fname);
|
||||
(void)taosRemoveFile(fname);
|
||||
tsdbRemoveFile(fname);
|
||||
taosMemoryFree(pHeadF);
|
||||
}
|
||||
} else {
|
||||
|
@ -472,7 +474,7 @@ static int32_t tsdbMergeFileSet(STsdb *pTsdb, SDFileSet *pSetOld, SDFileSet *pSe
|
|||
nRef = atomic_sub_fetch_32(&pDataF->nRef, 1);
|
||||
if (nRef == 0) {
|
||||
tsdbDataFileName(pTsdb, pSetOld->diskId, pSetOld->fid, pDataF, fname);
|
||||
(void)taosRemoveFile(fname);
|
||||
tsdbRemoveFile(fname);
|
||||
taosMemoryFree(pDataF);
|
||||
}
|
||||
} else {
|
||||
|
@ -493,7 +495,7 @@ static int32_t tsdbMergeFileSet(STsdb *pTsdb, SDFileSet *pSetOld, SDFileSet *pSe
|
|||
nRef = atomic_sub_fetch_32(&pSmaF->nRef, 1);
|
||||
if (nRef == 0) {
|
||||
tsdbSmaFileName(pTsdb, pSetOld->diskId, pSetOld->fid, pSmaF, fname);
|
||||
(void)taosRemoveFile(fname);
|
||||
tsdbRemoveFile(fname);
|
||||
taosMemoryFree(pSmaF);
|
||||
}
|
||||
} else {
|
||||
|
@ -517,7 +519,7 @@ static int32_t tsdbMergeFileSet(STsdb *pTsdb, SDFileSet *pSetOld, SDFileSet *pSe
|
|||
nRef = atomic_sub_fetch_32(&pSttFile->nRef, 1);
|
||||
if (nRef == 0) {
|
||||
tsdbSttFileName(pTsdb, pSetOld->diskId, pSetOld->fid, pSttFile, fname);
|
||||
(void)taosRemoveFile(fname);
|
||||
tsdbRemoveFile(fname);
|
||||
taosMemoryFree(pSttFile);
|
||||
}
|
||||
pSetOld->aSttF[iStt] = NULL;
|
||||
|
@ -538,7 +540,7 @@ static int32_t tsdbMergeFileSet(STsdb *pTsdb, SDFileSet *pSetOld, SDFileSet *pSe
|
|||
nRef = atomic_sub_fetch_32(&pSttFile->nRef, 1);
|
||||
if (nRef == 0) {
|
||||
tsdbSttFileName(pTsdb, pSetOld->diskId, pSetOld->fid, pSttFile, fname);
|
||||
(void)taosRemoveFile(fname);
|
||||
tsdbRemoveFile(fname);
|
||||
taosMemoryFree(pSttFile);
|
||||
}
|
||||
|
||||
|
@ -563,7 +565,7 @@ static int32_t tsdbMergeFileSet(STsdb *pTsdb, SDFileSet *pSetOld, SDFileSet *pSe
|
|||
nRef = atomic_sub_fetch_32(&pSttFile->nRef, 1);
|
||||
if (nRef == 0) {
|
||||
tsdbSttFileName(pTsdb, pSetOld->diskId, pSetOld->fid, pSttFile, fname);
|
||||
(void)taosRemoveFile(fname);
|
||||
tsdbRemoveFile(fname);
|
||||
taosMemoryFree(pSttFile);
|
||||
}
|
||||
}
|
||||
|
@ -619,7 +621,7 @@ static int32_t tsdbFSApplyChange(STsdb *pTsdb, STsdbFS *pFS) {
|
|||
nRef = atomic_sub_fetch_32(&pDelFile->nRef, 1);
|
||||
if (nRef == 0) {
|
||||
tsdbDelFileName(pTsdb, pDelFile, fname);
|
||||
(void)taosRemoveFile(fname);
|
||||
tsdbRemoveFile(fname);
|
||||
taosMemoryFree(pDelFile);
|
||||
}
|
||||
}
|
||||
|
@ -629,7 +631,7 @@ static int32_t tsdbFSApplyChange(STsdb *pTsdb, STsdbFS *pFS) {
|
|||
nRef = atomic_sub_fetch_32(&pTsdb->fs.pDelFile->nRef, 1);
|
||||
if (nRef == 0) {
|
||||
tsdbDelFileName(pTsdb, pTsdb->fs.pDelFile, fname);
|
||||
(void)taosRemoveFile(fname);
|
||||
tsdbRemoveFile(fname);
|
||||
taosMemoryFree(pTsdb->fs.pDelFile);
|
||||
}
|
||||
pTsdb->fs.pDelFile = NULL;
|
||||
|
@ -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);
|
||||
|
@ -741,7 +740,7 @@ static int32_t tsdbFSRollback(STsdb *pTsdb) {
|
|||
|
||||
char current_t[TSDB_FILENAME_LEN] = {0};
|
||||
tsdbGetCurrentFName(pTsdb, NULL, current_t);
|
||||
(void)taosRemoveFile(current_t);
|
||||
tsdbRemoveFile(current_t);
|
||||
|
||||
_exit:
|
||||
if (code) {
|
||||
|
|
|
@ -20,8 +20,6 @@
|
|||
|
||||
#define BLOCK_COMMIT_FACTOR 3
|
||||
|
||||
extern void remove_file(const char *fname);
|
||||
|
||||
typedef struct STFileHashEntry {
|
||||
struct STFileHashEntry *next;
|
||||
char fname[TSDB_FILENAME_LEN];
|
||||
|
@ -55,25 +53,22 @@ static int32_t create_fs(STsdb *pTsdb, STFileSystem **fs) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int32_t destroy_fs(STFileSystem **fs) {
|
||||
if (fs[0] == NULL) return 0;
|
||||
static void destroy_fs(STFileSystem **fs) {
|
||||
if (fs[0] == NULL) return;
|
||||
|
||||
TARRAY2_DESTROY(fs[0]->fSetArr, NULL);
|
||||
TARRAY2_DESTROY(fs[0]->fSetArrTmp, NULL);
|
||||
(void)tsem_destroy(&fs[0]->canEdit);
|
||||
taosMemoryFree(fs[0]);
|
||||
fs[0] = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t current_fname(STsdb *pTsdb, char *fname, EFCurrentT ftype) {
|
||||
void current_fname(STsdb *pTsdb, char *fname, EFCurrentT ftype) {
|
||||
int32_t offset = 0;
|
||||
|
||||
(void)vnodeGetPrimaryDir(pTsdb->path, pTsdb->pVnode->diskPrimary, pTsdb->pVnode->pTfs, fname, TSDB_FILENAME_LEN);
|
||||
vnodeGetPrimaryDir(pTsdb->path, pTsdb->pVnode->diskPrimary, pTsdb->pVnode->pTfs, fname, TSDB_FILENAME_LEN);
|
||||
offset = strlen(fname);
|
||||
snprintf(fname + offset, TSDB_FILENAME_LEN - offset - 1, "%s%s", TD_DIRSEP, gCurrentFname[ftype]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t save_json(const cJSON *json, const char *fname) {
|
||||
|
@ -89,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:
|
||||
|
@ -116,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);
|
||||
|
@ -130,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';
|
||||
|
||||
|
@ -257,7 +253,7 @@ static int32_t apply_commit(STFileSystem *fs) {
|
|||
if (fset1 && fset2) {
|
||||
if (fset1->fid < fset2->fid) {
|
||||
// delete fset1
|
||||
(void)tsdbTFileSetRemove(fset1);
|
||||
tsdbTFileSetRemove(fset1);
|
||||
i1++;
|
||||
} else if (fset1->fid > fset2->fid) {
|
||||
// create new file set with fid of fset2->fid
|
||||
|
@ -276,7 +272,7 @@ static int32_t apply_commit(STFileSystem *fs) {
|
|||
}
|
||||
} else if (fset1) {
|
||||
// delete fset1
|
||||
(void)tsdbTFileSetRemove(fset1);
|
||||
tsdbTFileSetRemove(fset1);
|
||||
i1++;
|
||||
} else {
|
||||
// create new file set with fid of fset2->fid
|
||||
|
@ -300,19 +296,16 @@ static int32_t commit_edit(STFileSystem *fs) {
|
|||
char current[TSDB_FILENAME_LEN];
|
||||
char current_t[TSDB_FILENAME_LEN];
|
||||
|
||||
(void)current_fname(fs->tsdb, current, TSDB_FCURRENT);
|
||||
current_fname(fs->tsdb, current, TSDB_FCURRENT);
|
||||
if (fs->etype == TSDB_FEDIT_COMMIT) {
|
||||
(void)current_fname(fs->tsdb, current_t, TSDB_FCURRENT_C);
|
||||
current_fname(fs->tsdb, current_t, TSDB_FCURRENT_C);
|
||||
} else {
|
||||
(void)current_fname(fs->tsdb, current_t, TSDB_FCURRENT_M);
|
||||
current_fname(fs->tsdb, current_t, TSDB_FCURRENT_M);
|
||||
}
|
||||
|
||||
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);
|
||||
|
@ -335,9 +328,9 @@ static int32_t abort_edit(STFileSystem *fs) {
|
|||
char fname[TSDB_FILENAME_LEN];
|
||||
|
||||
if (fs->etype == TSDB_FEDIT_COMMIT) {
|
||||
(void)current_fname(fs->tsdb, fname, TSDB_FCURRENT_C);
|
||||
current_fname(fs->tsdb, fname, TSDB_FCURRENT_C);
|
||||
} else {
|
||||
(void)current_fname(fs->tsdb, fname, TSDB_FCURRENT_M);
|
||||
current_fname(fs->tsdb, fname, TSDB_FCURRENT_M);
|
||||
}
|
||||
|
||||
int32_t code;
|
||||
|
@ -370,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);
|
||||
|
@ -421,7 +414,7 @@ static int32_t tsdbFSCreateFileObjHash(STFileSystem *fs, STFileHash *hash) {
|
|||
}
|
||||
|
||||
// vnode.json
|
||||
(void)current_fname(fs->tsdb, fname, TSDB_FCURRENT);
|
||||
current_fname(fs->tsdb, fname, TSDB_FCURRENT);
|
||||
code = tsdbFSAddEntryToFileObjHash(hash, fname);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
|
@ -538,7 +531,7 @@ static int32_t tsdbFSDoSanAndFix(STFileSystem *fs) {
|
|||
if (tsdbFSGetFileObjHashEntry(&fobjHash, file->aname) == NULL &&
|
||||
strncmp(file->aname + strlen(file->aname) - 3, ".cp", 3) &&
|
||||
strncmp(file->aname + strlen(file->aname) - 5, ".data", 5)) {
|
||||
remove_file(file->aname);
|
||||
tsdbRemoveFile(file->aname);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -605,9 +598,9 @@ static int32_t open_fs(STFileSystem *fs, int8_t rollback) {
|
|||
char cCurrent[TSDB_FILENAME_LEN];
|
||||
char mCurrent[TSDB_FILENAME_LEN];
|
||||
|
||||
(void)current_fname(pTsdb, fCurrent, TSDB_FCURRENT);
|
||||
(void)current_fname(pTsdb, cCurrent, TSDB_FCURRENT_C);
|
||||
(void)current_fname(pTsdb, mCurrent, TSDB_FCURRENT_M);
|
||||
current_fname(pTsdb, fCurrent, TSDB_FCURRENT);
|
||||
current_fname(pTsdb, cCurrent, TSDB_FCURRENT_C);
|
||||
current_fname(pTsdb, mCurrent, TSDB_FCURRENT_M);
|
||||
|
||||
if (taosCheckExistFile(fCurrent)) { // current.json exists
|
||||
code = load_fs(pTsdb, fCurrent, fs->fSetArr);
|
||||
|
@ -653,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) {
|
||||
|
@ -746,15 +738,15 @@ int32_t tsdbOpenFS(STsdb *pTsdb, STFileSystem **fs, int8_t rollback) {
|
|||
_exit:
|
||||
if (code) {
|
||||
tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
|
||||
(void)destroy_fs(fs);
|
||||
destroy_fs(fs);
|
||||
} else {
|
||||
tsdbInfo("vgId:%d %s success", TD_VID(pTsdb->pVnode), __func__);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t 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;
|
||||
|
@ -779,7 +771,7 @@ int32_t tsdbDisableAndCancelAllBgTask(STsdb *pTsdb) {
|
|||
}
|
||||
fset->channel = (SVAChannelID){0};
|
||||
fset->mergeScheduled = false;
|
||||
(void)tsdbFSSetBlockCommit(fset, false);
|
||||
tsdbFSSetBlockCommit(fset, false);
|
||||
fset->channelOpened = false;
|
||||
}
|
||||
}
|
||||
|
@ -789,30 +781,32 @@ 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;
|
||||
}
|
||||
|
||||
int32_t tsdbEnableBgTask(STsdb *pTsdb) {
|
||||
void tsdbEnableBgTask(STsdb *pTsdb) {
|
||||
(void)taosThreadMutexLock(&pTsdb->mutex);
|
||||
pTsdb->bgTaskDisabled = false;
|
||||
(void)taosThreadMutexUnlock(&pTsdb->mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
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]);
|
||||
(void)destroy_fs(fs);
|
||||
return 0;
|
||||
TAOS_UNUSED(tsdbDisableAndCancelAllBgTask((*fs)->tsdb));
|
||||
close_file_system(fs[0]);
|
||||
destroy_fs(fs);
|
||||
return;
|
||||
}
|
||||
|
||||
int64_t tsdbFSAllocEid(STFileSystem *fs) {
|
||||
|
@ -834,9 +828,9 @@ int32_t tsdbFSEditBegin(STFileSystem *fs, const TFileOpArray *opArray, EFEditT e
|
|||
char current_t[TSDB_FILENAME_LEN];
|
||||
|
||||
if (etype == TSDB_FEDIT_COMMIT) {
|
||||
(void)current_fname(fs->tsdb, current_t, TSDB_FCURRENT_C);
|
||||
current_fname(fs->tsdb, current_t, TSDB_FCURRENT_C);
|
||||
} else {
|
||||
(void)current_fname(fs->tsdb, current_t, TSDB_FCURRENT_M);
|
||||
current_fname(fs->tsdb, current_t, TSDB_FCURRENT_M);
|
||||
}
|
||||
|
||||
(void)tsem_wait(&fs->canEdit);
|
||||
|
@ -860,7 +854,7 @@ _exit:
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t tsdbFSSetBlockCommit(STFileSet *fset, bool block) {
|
||||
static void tsdbFSSetBlockCommit(STFileSet *fset, bool block) {
|
||||
if (block) {
|
||||
fset->blockCommit = true;
|
||||
} else {
|
||||
|
@ -869,13 +863,12 @@ static int32_t tsdbFSSetBlockCommit(STFileSet *fset, bool block) {
|
|||
(void)taosThreadCondSignal(&fset->canCommit);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t tsdbFSCheckCommit(STsdb *tsdb, int32_t fid) {
|
||||
(void)taosThreadMutexLock(&tsdb->mutex);
|
||||
STFileSet *fset;
|
||||
(void)tsdbFSGetFSet(tsdb->pFS, fid, &fset);
|
||||
tsdbFSGetFSet(tsdb->pFS, fid, &fset);
|
||||
if (fset) {
|
||||
while (fset->blockCommit) {
|
||||
fset->numWaitCommit++;
|
||||
|
@ -902,13 +895,13 @@ int32_t tsdbFSEditCommit(STFileSystem *fs) {
|
|||
STFileSet *fset;
|
||||
TARRAY2_FOREACH_REVERSE(fs->fSetArr, fset) {
|
||||
if (TARRAY2_SIZE(fset->lvlArr) == 0) {
|
||||
(void)tsdbFSSetBlockCommit(fset, false);
|
||||
tsdbFSSetBlockCommit(fset, false);
|
||||
continue;
|
||||
}
|
||||
|
||||
SSttLvl *lvl = TARRAY2_FIRST(fset->lvlArr);
|
||||
if (lvl->level != 0) {
|
||||
(void)tsdbFSSetBlockCommit(fset, false);
|
||||
tsdbFSSetBlockCommit(fset, false);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -933,9 +926,9 @@ int32_t tsdbFSEditCommit(STFileSystem *fs) {
|
|||
}
|
||||
|
||||
if (numFile >= sttTrigger * BLOCK_COMMIT_FACTOR) {
|
||||
(void)tsdbFSSetBlockCommit(fset, true);
|
||||
tsdbFSSetBlockCommit(fset, true);
|
||||
} else {
|
||||
(void)tsdbFSSetBlockCommit(fset, false);
|
||||
tsdbFSSetBlockCommit(fset, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -956,12 +949,11 @@ int32_t tsdbFSEditAbort(STFileSystem *fs) {
|
|||
return code;
|
||||
}
|
||||
|
||||
int32_t tsdbFSGetFSet(STFileSystem *fs, int32_t fid, STFileSet **fset) {
|
||||
void tsdbFSGetFSet(STFileSystem *fs, int32_t fid, STFileSet **fset) {
|
||||
STFileSet tfset = {.fid = fid};
|
||||
STFileSet *pset = &tfset;
|
||||
STFileSet **fsetPtr = TARRAY2_SEARCH(fs->fSetArr, &pset, tsdbTFileSetCmprFn, TD_EQ);
|
||||
fset[0] = (fsetPtr == NULL) ? NULL : fsetPtr[0];
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t tsdbFSCreateCopySnapshot(STFileSystem *fs, TFileSetArray **fsetArr) {
|
||||
|
@ -992,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) {
|
||||
|
@ -1034,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) {
|
||||
|
@ -1111,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) {
|
||||
|
@ -1167,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;
|
||||
}
|
||||
|
@ -1180,12 +1170,12 @@ _out:
|
|||
return code;
|
||||
}
|
||||
|
||||
int32_t tsdbFSDestroyRefRangedSnapshot(TFileSetRangeArray **fsrArr) { return tsdbTFileSetRangeArrayDestroy(fsrArr); }
|
||||
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;
|
||||
|
||||
(void)tsdbFSGetFSet(tsdb->pFS, fid, fset);
|
||||
tsdbFSGetFSet(tsdb->pFS, fid, fset);
|
||||
if (sttTrigger == 1 && (*fset)) {
|
||||
for (;;) {
|
||||
if ((*fset)->taskRunning) {
|
||||
|
@ -1193,7 +1183,7 @@ int32_t tsdbBeginTaskOnFileSet(STsdb *tsdb, int32_t fid, STFileSet **fset) {
|
|||
|
||||
(void)taosThreadCondWait(&(*fset)->beginTask, &tsdb->mutex);
|
||||
|
||||
(void)tsdbFSGetFSet(tsdb->pFS, fid, fset);
|
||||
tsdbFSGetFSet(tsdb->pFS, fid, fset);
|
||||
|
||||
(*fset)->numWaitTask--;
|
||||
} else {
|
||||
|
@ -1203,15 +1193,13 @@ 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;
|
||||
(void)tsdbFSGetFSet(tsdb->pFS, fid, &fset);
|
||||
tsdbFSGetFSet(tsdb->pFS, fid, &fset);
|
||||
if (fset != NULL && fset->taskRunning) {
|
||||
fset->taskRunning = false;
|
||||
if (fset->numWaitTask > 0) {
|
||||
|
@ -1220,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,20 +38,20 @@ 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);
|
||||
int32_t tsdbFSDestroyRefRangedSnapshot(TFileSetRangeArray **fsrArr);
|
||||
void tsdbFSDestroyRefRangedSnapshot(TFileSetRangeArray **fsrArr);
|
||||
// txn
|
||||
int64_t tsdbFSAllocEid(STFileSystem *fs);
|
||||
void tsdbFSUpdateEid(STFileSystem *fs, int64_t cid);
|
||||
|
@ -59,13 +59,13 @@ int32_t tsdbFSEditBegin(STFileSystem *fs, const TFileOpArray *opArray, EFEditT e
|
|||
int32_t tsdbFSEditCommit(STFileSystem *fs);
|
||||
int32_t tsdbFSEditAbort(STFileSystem *fs);
|
||||
// other
|
||||
int32_t tsdbFSGetFSet(STFileSystem *fs, int32_t fid, STFileSet **fset);
|
||||
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);
|
||||
int32_t current_fname(STsdb *pTsdb, char *fname, EFCurrentT ftype);
|
||||
void current_fname(STsdb *pTsdb, char *fname, EFCurrentT ftype);
|
||||
|
||||
/* Exposed Structs */
|
||||
struct STFileSystem {
|
||||
|
|
|
@ -27,13 +27,12 @@ int32_t tsdbSttLvlInit(int32_t level, SSttLvl **lvl) {
|
|||
|
||||
static void tsdbSttLvlClearFObj(void *data) { TAOS_UNUSED(tsdbTFileObjUnref(*(STFileObj **)data)); }
|
||||
|
||||
int32_t tsdbSttLvlClear(SSttLvl **lvl) {
|
||||
void tsdbSttLvlClear(SSttLvl **lvl) {
|
||||
if (lvl[0] != NULL) {
|
||||
TARRAY2_DESTROY(lvl[0]->fobjArr, tsdbSttLvlClearFObj);
|
||||
taosMemoryFree(lvl[0]);
|
||||
lvl[0] = NULL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t tsdbSttLvlInitEx(STsdb *pTsdb, const SSttLvl *lvl1, SSttLvl **lvl) {
|
||||
|
@ -45,13 +44,13 @@ static int32_t tsdbSttLvlInitEx(STsdb *pTsdb, const SSttLvl *lvl1, SSttLvl **lvl
|
|||
STFileObj *fobj;
|
||||
code = tsdbTFileObjInit(pTsdb, fobj1->f, &fobj);
|
||||
if (code) {
|
||||
(void)tsdbSttLvlClear(lvl);
|
||||
tsdbSttLvlClear(lvl);
|
||||
return code;
|
||||
}
|
||||
|
||||
code = TARRAY2_APPEND(lvl[0]->fobjArr, fobj);
|
||||
if (code) {
|
||||
(void)tsdbSttLvlClear(lvl);
|
||||
tsdbSttLvlClear(lvl);
|
||||
taosMemoryFree(fobj);
|
||||
return code;
|
||||
}
|
||||
|
@ -65,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;
|
||||
}
|
||||
|
@ -83,7 +89,7 @@ static int32_t tsdbSttLvlFilteredInitEx(STsdb *pTsdb, const SSttLvl *lvl1, int64
|
|||
STFileObj *fobj;
|
||||
code = tsdbTFileObjInit(pTsdb, fobj1->f, &fobj);
|
||||
if (code) {
|
||||
(void)tsdbSttLvlClear(lvl);
|
||||
tsdbSttLvlClear(lvl);
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -100,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]);
|
||||
|
@ -204,7 +215,7 @@ static int32_t tsdbJsonToSttLvl(STsdb *pTsdb, const cJSON *json, SSttLvl **lvl)
|
|||
|
||||
item1 = cJSON_GetObjectItem(json, "files");
|
||||
if (!cJSON_IsArray(item1)) {
|
||||
(void)tsdbSttLvlClear(lvl);
|
||||
tsdbSttLvlClear(lvl);
|
||||
return TSDB_CODE_FILE_CORRUPTED;
|
||||
}
|
||||
|
||||
|
@ -212,14 +223,14 @@ static int32_t tsdbJsonToSttLvl(STsdb *pTsdb, const cJSON *json, SSttLvl **lvl)
|
|||
STFile tf;
|
||||
code = tsdbJsonToTFile(item2, TSDB_FTYPE_STT, &tf);
|
||||
if (code) {
|
||||
(void)tsdbSttLvlClear(lvl);
|
||||
tsdbSttLvlClear(lvl);
|
||||
return code;
|
||||
}
|
||||
|
||||
STFileObj *fobj;
|
||||
code = tsdbTFileObjInit(pTsdb, &tf, &fobj);
|
||||
if (code) {
|
||||
(void)tsdbSttLvlClear(lvl);
|
||||
tsdbSttLvlClear(lvl);
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -349,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 {
|
||||
|
@ -392,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;
|
||||
|
@ -405,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;
|
||||
}
|
||||
}
|
||||
|
@ -571,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];
|
||||
}
|
||||
|
||||
|
@ -596,29 +615,32 @@ 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;
|
||||
}
|
||||
|
||||
int32_t tsdbTFileSetRangeArrayDestroy(TFileSetRangeArray **ppArr) {
|
||||
void tsdbTFileSetRangeArrayDestroy(TFileSetRangeArray **ppArr) {
|
||||
if (ppArr && ppArr[0]) {
|
||||
TARRAY2_DESTROY(ppArr[0], tsdbTFileSetRangeClear);
|
||||
taosMemoryFree(ppArr[0]);
|
||||
ppArr[0] = NULL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
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);
|
||||
|
@ -629,19 +651,20 @@ void tsdbTFileSetClear(STFileSet **fset) {
|
|||
}
|
||||
}
|
||||
|
||||
int32_t tsdbTFileSetRemove(STFileSet *fset) {
|
||||
if (fset == NULL) return 0;
|
||||
void tsdbTFileSetRemove(STFileSet *fset) {
|
||||
if (fset == NULL) return;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
TARRAY2_DESTROY(fset->lvlArr, tsdbSttLvlRemove);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SSttLvl *tsdbTFileSetGetSttLvl(STFileSet *fset, int32_t level) {
|
||||
|
|
|
@ -43,7 +43,7 @@ int32_t tsdbTFileSetInit(int32_t fid, STFileSet **fset);
|
|||
int32_t tsdbTFileSetInitCopy(STsdb *pTsdb, const STFileSet *fset1, STFileSet **fset);
|
||||
int32_t tsdbTFileSetInitRef(STsdb *pTsdb, const STFileSet *fset1, STFileSet **fset);
|
||||
void tsdbTFileSetClear(STFileSet **fset);
|
||||
int32_t tsdbTFileSetRemove(STFileSet *fset);
|
||||
void tsdbTFileSetRemove(STFileSet *fset);
|
||||
|
||||
int32_t tsdbTFileSetFilteredInitDup(STsdb *pTsdb, const STFileSet *fset1, int64_t ever, STFileSet **fset,
|
||||
TFileOpArray *fopArr);
|
||||
|
@ -57,7 +57,6 @@ int32_t tsdbJsonToTFileSet(STsdb *pTsdb, const cJSON *json, STFileSet **fset);
|
|||
// cmpr
|
||||
int32_t tsdbTFileSetCmprFn(const STFileSet **fset1, const STFileSet **fset2);
|
||||
// edit
|
||||
int32_t tsdbSttLvlClear(SSttLvl **lvl);
|
||||
int32_t tsdbTFileSetEdit(STsdb *pTsdb, STFileSet *fset, const STFileOp *op);
|
||||
int32_t tsdbTFileSetApplyEdit(STsdb *pTsdb, const STFileSet *fset1, STFileSet *fset);
|
||||
// max commit id
|
||||
|
@ -68,7 +67,7 @@ SSttLvl *tsdbTFileSetGetSttLvl(STFileSet *fset, int32_t level);
|
|||
bool tsdbTFileSetIsEmpty(const STFileSet *fset);
|
||||
// stt
|
||||
int32_t tsdbSttLvlInit(int32_t level, SSttLvl **lvl);
|
||||
int32_t tsdbSttLvlClear(SSttLvl **lvl);
|
||||
void tsdbSttLvlClear(SSttLvl **lvl);
|
||||
// open channel
|
||||
int32_t tsdbTFileSetOpenChannel(STFileSet *fset);
|
||||
|
||||
|
|
|
@ -221,7 +221,7 @@ void tsdbDelFileName(STsdb *pTsdb, SDelFile *pFile, char fname[]) {
|
|||
int32_t offset = 0;
|
||||
SVnode *pVnode = pTsdb->pVnode;
|
||||
|
||||
(void)vnodeGetPrimaryDir(pTsdb->path, pVnode->diskPrimary, pVnode->pTfs, fname, TSDB_FILENAME_LEN);
|
||||
vnodeGetPrimaryDir(pTsdb->path, pVnode->diskPrimary, pVnode->pTfs, fname, TSDB_FILENAME_LEN);
|
||||
offset = strlen(fname);
|
||||
snprintf((char *)fname + offset, TSDB_FILENAME_LEN - offset - 1, "%sv%dver%" PRId64 ".del", TD_DIRSEP,
|
||||
TD_VID(pTsdb->pVnode), pFile->commitID);
|
||||
|
|
|
@ -43,9 +43,13 @@ static const struct {
|
|||
[TSDB_FTYPE_STT] = {"stt", stt_to_json, stt_from_json},
|
||||
};
|
||||
|
||||
void remove_file(const char *fname) {
|
||||
(void)taosRemoveFile(fname);
|
||||
tsdbInfo("file:%s is removed", fname);
|
||||
void tsdbRemoveFile(const char *fname) {
|
||||
int32_t code = taosRemoveFile(fname);
|
||||
if (code) {
|
||||
tsdbError("failed to remove file:%s, code:%d, error:%s", fname, code, tstrerror(code));
|
||||
} else {
|
||||
tsdbInfo("file:%s is removed", fname);
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t tfile_to_json(const STFile *file, cJSON *json) {
|
||||
|
@ -234,7 +238,7 @@ int32_t tsdbTFileObjInit(STsdb *pTsdb, const STFile *f, STFileObj **fobj) {
|
|||
fobj[0]->f[0] = f[0];
|
||||
fobj[0]->state = TSDB_FSTATE_LIVE;
|
||||
fobj[0]->ref = 1;
|
||||
(void)tsdbTFileName(pTsdb, f, fobj[0]->fname);
|
||||
tsdbTFileName(pTsdb, f, fobj[0]->fname);
|
||||
// fobj[0]->nlevel = tfsGetLevel(pTsdb->pVnode->pTfs);
|
||||
fobj[0]->nlevel = vnodeNodeId(pTsdb->pVnode);
|
||||
return 0;
|
||||
|
@ -245,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;
|
||||
}
|
||||
|
||||
|
@ -269,7 +273,7 @@ int32_t tsdbTFileObjUnref(STFileObj *fobj) {
|
|||
tsdbTrace("unref file %s, fobj:%p ref %d", fobj->fname, fobj, nRef);
|
||||
if (nRef == 0) {
|
||||
if (fobj->state == TSDB_FSTATE_DEAD) {
|
||||
remove_file(fobj->fname);
|
||||
tsdbRemoveFile(fobj->fname);
|
||||
}
|
||||
taosMemoryFree(fobj);
|
||||
}
|
||||
|
@ -279,7 +283,7 @@ int32_t tsdbTFileObjUnref(STFileObj *fobj) {
|
|||
|
||||
static void tsdbTFileObjRemoveLC(STFileObj *fobj, bool remove_all) {
|
||||
if (fobj->f->type != TSDB_FTYPE_DATA || fobj->f->lcn < 1) {
|
||||
remove_file(fobj->fname);
|
||||
tsdbRemoveFile(fobj->fname);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -295,7 +299,7 @@ static void tsdbTFileObjRemoveLC(STFileObj *fobj, bool remove_all) {
|
|||
}
|
||||
snprintf(dot + 1, TSDB_FQDN_LEN - (dot + 1 - lc_path), "%d.data", fobj->f->lcn);
|
||||
|
||||
remove_file(lc_path);
|
||||
tsdbRemoveFile(lc_path);
|
||||
|
||||
} else {
|
||||
// delete by data file prefix
|
||||
|
@ -324,15 +328,15 @@ static void tsdbTFileObjRemoveLC(STFileObj *fobj, bool remove_all) {
|
|||
}
|
||||
snprintf(dot + 1, TSDB_FQDN_LEN - (dot + 1 - lc_path), "%d.data", fobj->f->lcn);
|
||||
|
||||
remove_file(lc_path);
|
||||
tsdbRemoveFile(lc_path);
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
@ -366,7 +370,7 @@ int32_t tsdbTFileObjRemoveUpdateLC(STFileObj *fobj) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32_t tsdbTFileName(STsdb *pTsdb, const STFile *f, char fname[]) {
|
||||
void tsdbTFileName(STsdb *pTsdb, const STFile *f, char fname[]) {
|
||||
SVnode *pVnode = pTsdb->pVnode;
|
||||
STfs *pTfs = pVnode->pTfs;
|
||||
|
||||
|
@ -393,10 +397,9 @@ int32_t tsdbTFileName(STsdb *pTsdb, const STFile *f, char fname[]) {
|
|||
f->cid, //
|
||||
g_tfile_info[f->type].suffix);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
|
@ -425,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) {
|
||||
|
|
|
@ -44,8 +44,8 @@ enum {
|
|||
// STFile
|
||||
int32_t tsdbTFileToJson(const STFile *f, cJSON *json);
|
||||
int32_t tsdbJsonToTFile(const cJSON *json, tsdb_ftype_t ftype, STFile *f);
|
||||
int32_t tsdbTFileName(STsdb *pTsdb, const STFile *f, char fname[]);
|
||||
int32_t tsdbTFileLastChunkName(STsdb *pTsdb, const STFile *f, char fname[]);
|
||||
void tsdbTFileName(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
|
||||
|
@ -430,7 +432,7 @@ static int32_t tsdbMemTombIterOpen(STsdbIter *iter) {
|
|||
}
|
||||
|
||||
static int32_t tsdbDataIterClose(STsdbIter *iter) {
|
||||
(void)tBrinBlockDestroy(iter->dataData->brinBlock);
|
||||
tBrinBlockDestroy(iter->dataData->brinBlock);
|
||||
tBlockDataDestroy(iter->dataData->blockData);
|
||||
return 0;
|
||||
}
|
||||
|
@ -699,12 +701,11 @@ int32_t tsdbIterMergerOpen(const TTsdbIterArray *iterArray, SIterMerger **merger
|
|||
return tsdbIterMergerNext(merger[0]);
|
||||
}
|
||||
|
||||
int32_t tsdbIterMergerClose(SIterMerger **merger) {
|
||||
void tsdbIterMergerClose(SIterMerger **merger) {
|
||||
if (merger[0]) {
|
||||
taosMemoryFree(merger[0]);
|
||||
merger[0] = NULL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t tsdbIterMergerNext(SIterMerger *merger) {
|
||||
|
|
|
@ -59,7 +59,7 @@ int32_t tsdbIterNext(STsdbIter *iter);
|
|||
|
||||
// SIterMerger ===============
|
||||
int32_t tsdbIterMergerOpen(const TTsdbIterArray *iterArray, SIterMerger **merger, bool isTomb);
|
||||
int32_t tsdbIterMergerClose(SIterMerger **merger);
|
||||
void tsdbIterMergerClose(SIterMerger **merger);
|
||||
int32_t tsdbIterMergerNext(SIterMerger *merger);
|
||||
int32_t tsdbIterMergerSkipTableData(SIterMerger *merger, const TABLEID *tbid);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
@ -731,15 +735,13 @@ int32_t tsdbRefMemTable(SMemTable *pMemTable, SQueryNode *pQNode) {
|
|||
tsdbError("vgId:%d, memtable ref count is invalid, ref:%d", TD_VID(pMemTable->pTsdb->pVnode), nRef);
|
||||
}
|
||||
|
||||
(void)vnodeBufPoolRegisterQuery(pMemTable->pPool, pQNode);
|
||||
vnodeBufPoolRegisterQuery(pMemTable->pPool, pQNode);
|
||||
|
||||
_exit:
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t tsdbUnrefMemTable(SMemTable *pMemTable, SQueryNode *pNode, bool proactive) {
|
||||
int32_t code = 0;
|
||||
|
||||
void tsdbUnrefMemTable(SMemTable *pMemTable, SQueryNode *pNode, bool proactive) {
|
||||
if (pNode) {
|
||||
vnodeBufPoolDeregisterQuery(pMemTable->pPool, pNode, proactive);
|
||||
}
|
||||
|
@ -747,8 +749,6 @@ int32_t tsdbUnrefMemTable(SMemTable *pMemTable, SQueryNode *pNode, bool proactiv
|
|||
if (atomic_sub_fetch_32(&pMemTable->nRef, 1) == 0) {
|
||||
tsdbMemTableDestroy(pMemTable, proactive);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t tbDataPCmprFn(const void *p1, const void *p2) {
|
||||
|
|
|
@ -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) {
|
||||
|
@ -204,7 +203,7 @@ static int32_t tsdbMergeFileSetBeginOpenReader(SMerger *merger) {
|
|||
TAOS_CHECK_GOTO(tsdbSttFileReaderOpen(fobj->fname, &config, &reader), &lino, _exit);
|
||||
|
||||
if ((code = TARRAY2_APPEND(merger->sttReaderArr, reader))) {
|
||||
(void)tsdbSttFileReaderClose(&reader);
|
||||
tsdbSttFileReaderClose(&reader);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -339,9 +340,9 @@ static int32_t tsdbMergeFileSetEndCloseWriter(SMerger *merger) {
|
|||
}
|
||||
|
||||
static int32_t tsdbMergeFileSetEndCloseIter(SMerger *merger) {
|
||||
(void)tsdbIterMergerClose(&merger->tombIterMerger);
|
||||
tsdbIterMergerClose(&merger->tombIterMerger);
|
||||
TARRAY2_CLEAR(merger->tombIterArr, tsdbIterClose);
|
||||
(void)tsdbIterMergerClose(&merger->dataIterMerger);
|
||||
tsdbIterMergerClose(&merger->dataIterMerger);
|
||||
TARRAY2_CLEAR(merger->dataIterArr, tsdbIterClose);
|
||||
return 0;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -463,7 +464,7 @@ static int32_t tsdbMergeGetFSet(SMerger *merger) {
|
|||
STFileSet *fset;
|
||||
|
||||
(void)taosThreadMutexLock(&merger->tsdb->mutex);
|
||||
(void)tsdbFSGetFSet(merger->tsdb->pFS, merger->fid, &fset);
|
||||
tsdbFSGetFSet(merger->tsdb->pFS, merger->fid, &fset);
|
||||
if (fset == NULL) {
|
||||
(void)taosThreadMutexUnlock(&merger->tsdb->mutex);
|
||||
return 0;
|
||||
|
|
|
@ -379,6 +379,7 @@ static int32_t loadSttStatisticsBlockData(SSttFileReader *pSttFileReader, SSttBl
|
|||
int32_t lino = 0;
|
||||
void *px = NULL;
|
||||
int32_t startIndex = 0;
|
||||
int32_t ret = 0;
|
||||
|
||||
int32_t numOfBlocks = TARRAY2_SIZE(pStatisBlkArray);
|
||||
if (numOfBlocks <= 0) {
|
||||
|
@ -487,7 +488,9 @@ static int32_t loadSttStatisticsBlockData(SSttFileReader *pSttFileReader, SSttBl
|
|||
} else {
|
||||
STbStatisRecord record = {0};
|
||||
while (i < rows) {
|
||||
(void)tStatisBlockGet(&block, i, &record);
|
||||
code = tStatisBlockGet(&block, i, &record);
|
||||
TSDB_CHECK_CODE(code, lino, _end);
|
||||
|
||||
if (record.suid != suid) {
|
||||
break;
|
||||
}
|
||||
|
@ -534,7 +537,7 @@ static int32_t loadSttStatisticsBlockData(SSttFileReader *pSttFileReader, SSttBl
|
|||
}
|
||||
|
||||
_end:
|
||||
(void) tStatisBlockDestroy(&block);
|
||||
tStatisBlockDestroy(&block);
|
||||
if (code != 0) {
|
||||
tsdbError("%s error happens at:%s line number: %d, code:%s", id, __func__, lino, tstrerror(code));
|
||||
} else {
|
||||
|
@ -678,7 +681,7 @@ int32_t tLDataIterOpen2(SLDataIter *pIter, SSttFileReader *pSttFileReader, int32
|
|||
}
|
||||
|
||||
void tLDataIterClose2(SLDataIter *pIter) {
|
||||
(void)tsdbSttFileReaderClose(&pIter->pReader); // always return 0
|
||||
tsdbSttFileReaderClose(&pIter->pReader);
|
||||
pIter->pReader = NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,9 +17,9 @@
|
|||
#include "tsdbFS2.h"
|
||||
|
||||
extern int32_t tsdbOpenCompMonitor(STsdb *tsdb);
|
||||
extern int32_t tsdbCloseCompMonitor(STsdb *tsdb);
|
||||
extern void tsdbCloseCompMonitor(STsdb *tsdb);
|
||||
|
||||
int32_t tsdbSetKeepCfg(STsdb *pTsdb, STsdbCfg *pCfg) {
|
||||
void tsdbSetKeepCfg(STsdb *pTsdb, STsdbCfg *pCfg) {
|
||||
STsdbKeepCfg *pKeepCfg = &pTsdb->keepCfg;
|
||||
pKeepCfg->precision = pCfg->precision;
|
||||
pKeepCfg->days = pCfg->days;
|
||||
|
@ -27,7 +27,6 @@ int32_t tsdbSetKeepCfg(STsdb *pTsdb, STsdbCfg *pCfg) {
|
|||
pKeepCfg->keep1 = pCfg->keep1;
|
||||
pKeepCfg->keep2 = pCfg->keep2;
|
||||
pKeepCfg->keepTimeOffset = pCfg->keepTimeOffset;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int64_t tsdbGetEarliestTs(STsdb *pTsdb) {
|
||||
|
@ -59,26 +58,30 @@ int32_t tsdbOpen(SVnode *pVnode, STsdb **ppTsdb, const char *dir, STsdbKeepCfg *
|
|||
pTsdb->pVnode = pVnode;
|
||||
(void)taosThreadMutexInit(&pTsdb->mutex, NULL);
|
||||
if (!pKeepCfg) {
|
||||
(void)tsdbSetKeepCfg(pTsdb, &pVnode->config.tsdbCfg);
|
||||
tsdbSetKeepCfg(pTsdb, &pVnode->config.tsdbCfg);
|
||||
} else {
|
||||
memcpy(&pTsdb->keepCfg, pKeepCfg, sizeof(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);
|
||||
|
@ -87,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 {
|
||||
|
@ -110,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);
|
||||
|
|
|
@ -308,7 +308,7 @@ static int32_t filesetIteratorNext(SFilesetIter* pIter, STsdbReader* pReader, bo
|
|||
|
||||
while (1) {
|
||||
if (pReader->pFileReader != NULL) {
|
||||
(void) tsdbDataFileReaderClose(&pReader->pFileReader);
|
||||
tsdbDataFileReaderClose(&pReader->pFileReader);
|
||||
}
|
||||
|
||||
pReader->status.pCurrentFileset = pIter->pFilesetList->data[pIter->index];
|
||||
|
@ -449,10 +449,14 @@ static int32_t tsdbUninitReaderLock(STsdbReader* pReader) {
|
|||
|
||||
static int32_t tsdbAcquireReader(STsdbReader* pReader) {
|
||||
int32_t code = -1;
|
||||
tsdbTrace("tsdb/read: %p, pre-take read mutex: %p, code: %d", pReader, &pReader->readerMutex, code);
|
||||
tsdbTrace("tsdb/read: %s, pre-take read mutex: %p, code: %d", pReader->idStr, &pReader->readerMutex, code);
|
||||
|
||||
code = taosThreadMutexLock(&pReader->readerMutex);
|
||||
tsdbTrace("tsdb/read: %p, post-take read mutex: %p, code: %d", pReader, &pReader->readerMutex, code);
|
||||
if (code != 0) {
|
||||
tsdbError("tsdb/read:%p, failed to lock reader mutex, code:%s", pReader->idStr, tstrerror(code));
|
||||
} else {
|
||||
tsdbTrace("tsdb/read: %s, post-take read mutex: %p, code: %d", pReader->idStr, &pReader->readerMutex, code);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
@ -4574,7 +4578,10 @@ int32_t tsdbSetTableList2(STsdbReader* pReader, const void* pTableList, int32_t
|
|||
STableBlockScanInfo** p = NULL;
|
||||
int32_t iter = 0;
|
||||
|
||||
(void)tsdbAcquireReader(pReader);
|
||||
code = tsdbAcquireReader(pReader);
|
||||
if (code) {
|
||||
return code;
|
||||
}
|
||||
|
||||
while ((p = tSimpleHashIterate(pReader->status.pTableMap, p, &iter)) != NULL) {
|
||||
clearBlockScanInfo(*p);
|
||||
|
@ -4808,7 +4815,10 @@ void tsdbReaderClose2(STsdbReader* pReader) {
|
|||
return;
|
||||
}
|
||||
|
||||
(void)tsdbAcquireReader(pReader);
|
||||
int32_t code = tsdbAcquireReader(pReader);
|
||||
if (code) {
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
if (pReader->innerReader[0] != NULL || pReader->innerReader[1] != NULL) {
|
||||
|
@ -4851,7 +4861,7 @@ void tsdbReaderClose2(STsdbReader* pReader) {
|
|||
clearBlockScanInfoBuf(&pReader->blockInfoBuf);
|
||||
|
||||
if (pReader->pFileReader != NULL) {
|
||||
(void) tsdbDataFileReaderClose(&pReader->pFileReader);
|
||||
tsdbDataFileReaderClose(&pReader->pFileReader);
|
||||
}
|
||||
|
||||
SReadCostSummary* pCost = &pReader->cost;
|
||||
|
@ -4905,7 +4915,7 @@ static int32_t doSuspendCurrentReader(STsdbReader* pCurrentReader) {
|
|||
SReaderStatus* pStatus = &pCurrentReader->status;
|
||||
|
||||
if (pStatus->loadFromFile) {
|
||||
(void) tsdbDataFileReaderClose(&pCurrentReader->pFileReader);
|
||||
tsdbDataFileReaderClose(&pCurrentReader->pFileReader);
|
||||
|
||||
SReadCostSummary* pCost = &pCurrentReader->cost;
|
||||
destroySttBlockReader(pStatus->pLDataIterArray, &pCost->sttCost);
|
||||
|
@ -5006,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;
|
||||
}
|
||||
|
@ -5553,7 +5563,7 @@ int32_t tsdbReaderReset2(STsdbReader* pReader, SQueryTableDataCond* pCond) {
|
|||
memset(&pReader->suppInfo.tsColAgg, 0, sizeof(SColumnDataAgg));
|
||||
|
||||
pReader->suppInfo.tsColAgg.colId = PRIMARYKEY_TIMESTAMP_COL_ID;
|
||||
(void) tsdbDataFileReaderClose(&pReader->pFileReader);
|
||||
tsdbDataFileReaderClose(&pReader->pFileReader);
|
||||
|
||||
int32_t numOfTables = tSimpleHashGetSize(pStatus->pTableMap);
|
||||
|
||||
|
@ -5852,16 +5862,17 @@ 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;
|
||||
int32_t lino = 0;
|
||||
*ppSnap = NULL;
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
@ -5869,8 +5880,7 @@ int32_t tsdbTakeReadSnap2(STsdbReader* pReader, _query_reseek_func_t reseek, STs
|
|||
STsdbReadSnap* pSnap = (STsdbReadSnap*)taosMemoryCalloc(1, sizeof(STsdbReadSnap));
|
||||
if (pSnap == NULL) {
|
||||
(void) taosThreadMutexUnlock(&pTsdb->mutex);
|
||||
code = terrno;
|
||||
goto _exit;
|
||||
TSDB_CHECK_NULL(pSnap, code, lino, _exit, terrno);
|
||||
}
|
||||
|
||||
// take snapshot
|
||||
|
@ -5879,14 +5889,14 @@ int32_t tsdbTakeReadSnap2(STsdbReader* pReader, _query_reseek_func_t reseek, STs
|
|||
pSnap->pNode = taosMemoryMalloc(sizeof(*pSnap->pNode));
|
||||
if (pSnap->pNode == NULL) {
|
||||
(void) taosThreadMutexUnlock(&pTsdb->mutex);
|
||||
code = terrno;
|
||||
goto _exit;
|
||||
TSDB_CHECK_NULL(pSnap->pNode, code, lino, _exit, terrno);
|
||||
}
|
||||
|
||||
pSnap->pNode->pQHandle = pReader;
|
||||
pSnap->pNode->reseek = reseek;
|
||||
|
||||
(void)tsdbRefMemTable(pTsdb->mem, pSnap->pNode);
|
||||
code = tsdbRefMemTable(pTsdb->mem, pSnap->pNode);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
|
||||
if (pTsdb->imem && (pRange->minVer <= pTsdb->imem->maxVer && pRange->maxVer >= pTsdb->imem->minVer)) {
|
||||
|
@ -5896,7 +5906,7 @@ int32_t tsdbTakeReadSnap2(STsdbReader* pReader, _query_reseek_func_t reseek, STs
|
|||
code = terrno;
|
||||
|
||||
if (pTsdb->mem && pSnap->pNode) {
|
||||
(void) tsdbUnrefMemTable(pTsdb->mem, pSnap->pNode, true); // unref the previous refed mem
|
||||
tsdbUnrefMemTable(pTsdb->mem, pSnap->pNode, true); // unref the previous refed mem
|
||||
}
|
||||
|
||||
(void) taosThreadMutexUnlock(&pTsdb->mutex);
|
||||
|
@ -5906,33 +5916,35 @@ int32_t tsdbTakeReadSnap2(STsdbReader* pReader, _query_reseek_func_t reseek, STs
|
|||
pSnap->pINode->pQHandle = pReader;
|
||||
pSnap->pINode->reseek = reseek;
|
||||
|
||||
(void)tsdbRefMemTable(pTsdb->imem, pSnap->pINode);
|
||||
code = tsdbRefMemTable(pTsdb->imem, pSnap->pINode);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
|
||||
// fs
|
||||
code = tsdbFSCreateRefSnapshotWithoutLock(pTsdb->pFS, &pSnap->pfSetArray);
|
||||
if (code) {
|
||||
if (pSnap->pNode) {
|
||||
(void) tsdbUnrefMemTable(pTsdb->mem, pSnap->pNode, true); // unref the previous refed mem
|
||||
tsdbUnrefMemTable(pTsdb->mem, pSnap->pNode, true); // unref the previous refed mem
|
||||
}
|
||||
|
||||
if (pSnap->pINode) {
|
||||
(void) tsdbUnrefMemTable(pTsdb->imem, pSnap->pINode, true);
|
||||
tsdbUnrefMemTable(pTsdb->imem, pSnap->pINode, true);
|
||||
}
|
||||
|
||||
(void) taosThreadMutexUnlock(&pTsdb->mutex);
|
||||
goto _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("vgId:%d take read snapshot failed, code:%s", TD_VID(pTsdb->pVnode), 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);
|
||||
|
@ -5946,17 +5958,17 @@ void tsdbUntakeReadSnap2(STsdbReader* pReader, STsdbReadSnap* pSnap, bool proact
|
|||
|
||||
if (pSnap) {
|
||||
if (pSnap->pMem) {
|
||||
(void) tsdbUnrefMemTable(pSnap->pMem, pSnap->pNode, proactive);
|
||||
tsdbUnrefMemTable(pSnap->pMem, pSnap->pNode, proactive);
|
||||
}
|
||||
|
||||
if (pSnap->pIMem) {
|
||||
(void) tsdbUnrefMemTable(pSnap->pIMem, pSnap->pINode, proactive);
|
||||
tsdbUnrefMemTable(pSnap->pIMem, pSnap->pINode, proactive);
|
||||
}
|
||||
|
||||
if (pSnap->pNode) taosMemoryFree(pSnap->pNode);
|
||||
if (pSnap->pINode) taosMemoryFree(pSnap->pINode);
|
||||
|
||||
(void) tsdbFSDestroyRefSnapshot(&pSnap->pfSetArray);
|
||||
tsdbFSDestroyRefSnapshot(&pSnap->pfSetArray);
|
||||
|
||||
taosMemoryFree(pSnap);
|
||||
}
|
||||
|
|
|
@ -490,7 +490,7 @@ int32_t getNextBrinRecord(SBrinRecordIter* pIter, SBrinRecord** pRecord) {
|
|||
return TSDB_CODE_INVALID_PARA;
|
||||
}
|
||||
|
||||
(void)tBrinBlockClear(&pIter->block);
|
||||
tBrinBlockClear(&pIter->block);
|
||||
int32_t code = tsdbDataFileReadBrinBlock(pIter->pReader, pIter->pCurrentBlk, &pIter->block);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
tsdbError("failed to read brinBlock from file, code:%s", tstrerror(code));
|
||||
|
@ -507,7 +507,7 @@ int32_t getNextBrinRecord(SBrinRecordIter* pIter, SBrinRecord** pRecord) {
|
|||
return code;
|
||||
}
|
||||
|
||||
void clearBrinBlockIter(SBrinRecordIter* pIter) { (void)tBrinBlockDestroy(&pIter->block); }
|
||||
void clearBrinBlockIter(SBrinRecordIter* pIter) { tBrinBlockDestroy(&pIter->block); }
|
||||
|
||||
// initialize the file block access order
|
||||
// sort the file blocks according to the offset of each data block in the files
|
||||
|
@ -779,8 +779,9 @@ typedef enum {
|
|||
BLK_CHECK_QUIT = 0x2,
|
||||
} ETombBlkCheckEnum;
|
||||
|
||||
static void loadNextStatisticsBlock(SSttFileReader* pSttFileReader, STbStatisBlock* pStatisBlock,
|
||||
const TStatisBlkArray* pStatisBlkArray, int32_t numOfRows, int32_t* i, int32_t* j);
|
||||
static int32_t loadNextStatisticsBlock(SSttFileReader* pSttFileReader, STbStatisBlock* pStatisBlock,
|
||||
const TStatisBlkArray* pStatisBlkArray, int32_t numOfRows, int32_t* i,
|
||||
int32_t* j);
|
||||
static int32_t doCheckTombBlock(STombBlock* pBlock, STsdbReader* pReader, int32_t numOfTables, int32_t* j,
|
||||
ETombBlkCheckEnum* pRet) {
|
||||
int32_t code = 0;
|
||||
|
@ -912,7 +913,7 @@ static int32_t doLoadTombDataFromTombBlk(const TTombBlkArray* pTombBlkArray, STs
|
|||
ETombBlkCheckEnum ret = 0;
|
||||
code = doCheckTombBlock(&block, pReader, numOfTables, &j, &ret);
|
||||
|
||||
(void)tTombBlockDestroy(&block);
|
||||
tTombBlockDestroy(&block);
|
||||
if (code != TSDB_CODE_SUCCESS || ret == BLK_CHECK_QUIT) {
|
||||
return code;
|
||||
}
|
||||
|
@ -994,11 +995,17 @@ int32_t loadMemTombData(SArray** ppMemDelData, STbData* pMemTbData, STbData* piM
|
|||
|
||||
int32_t getNumOfRowsInSttBlock(SSttFileReader* pSttFileReader, SSttBlockLoadInfo* pBlockLoadInfo,
|
||||
TStatisBlkArray* pStatisBlkArray, uint64_t suid, const uint64_t* pUidList,
|
||||
int32_t numOfTables) {
|
||||
int32_t numOfTables, int32_t* pNumOfRows) {
|
||||
int32_t num = 0;
|
||||
int32_t code = 0;
|
||||
int32_t lino = 0;
|
||||
|
||||
if (pNumOfRows != 0) {
|
||||
*pNumOfRows = 0;
|
||||
}
|
||||
|
||||
if (TARRAY2_SIZE(pStatisBlkArray) <= 0) {
|
||||
return 0;
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t i = 0;
|
||||
|
@ -1007,18 +1014,19 @@ int32_t getNumOfRowsInSttBlock(SSttFileReader* pSttFileReader, SSttBlockLoadInfo
|
|||
}
|
||||
|
||||
if (i >= TARRAY2_SIZE(pStatisBlkArray)) {
|
||||
return 0;
|
||||
return code;
|
||||
}
|
||||
|
||||
SStatisBlk* p = &pStatisBlkArray->data[i];
|
||||
STbStatisBlock* pStatisBlock = taosMemoryCalloc(1, sizeof(STbStatisBlock));
|
||||
(void)tStatisBlockInit(pStatisBlock);
|
||||
TSDB_CHECK_NULL(pStatisBlock, code, lino, _err, terrno);
|
||||
|
||||
code = tStatisBlockInit(pStatisBlock);
|
||||
TSDB_CHECK_CODE(code, lino, _err);
|
||||
|
||||
int64_t st = taosGetTimestampMs();
|
||||
int32_t code = tsdbSttFileReadStatisBlock(pSttFileReader, p, pStatisBlock);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return 0;
|
||||
}
|
||||
code = tsdbSttFileReadStatisBlock(pSttFileReader, p, pStatisBlock);
|
||||
TSDB_CHECK_CODE(code, lino, _err);
|
||||
|
||||
double el = (taosGetTimestampMs() - st) / 1000.0;
|
||||
pBlockLoadInfo->cost.loadStatisBlocks += 1;
|
||||
|
@ -1030,9 +1038,10 @@ int32_t getNumOfRowsInSttBlock(SSttFileReader* pSttFileReader, SSttBlockLoadInfo
|
|||
}
|
||||
|
||||
if (index >= pStatisBlock->numOfRecords) {
|
||||
(void)tStatisBlockDestroy(pStatisBlock);
|
||||
tStatisBlockDestroy(pStatisBlock);
|
||||
taosMemoryFreeClear(pStatisBlock);
|
||||
return num;
|
||||
*pNumOfRows = num;
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t j = index;
|
||||
|
@ -1040,9 +1049,10 @@ int32_t getNumOfRowsInSttBlock(SSttFileReader* pSttFileReader, SSttBlockLoadInfo
|
|||
while (i < TARRAY2_SIZE(pStatisBlkArray) && uidIndex < numOfTables) {
|
||||
p = &pStatisBlkArray->data[i];
|
||||
if (p->minTbid.suid > suid) {
|
||||
(void)tStatisBlockDestroy(pStatisBlock);
|
||||
tStatisBlockDestroy(pStatisBlock);
|
||||
taosMemoryFreeClear(pStatisBlock);
|
||||
return num;
|
||||
*pNumOfRows = num;
|
||||
return code;
|
||||
}
|
||||
|
||||
uint64_t uid = pUidList[uidIndex];
|
||||
|
@ -1051,30 +1061,45 @@ int32_t getNumOfRowsInSttBlock(SSttFileReader* pSttFileReader, SSttBlockLoadInfo
|
|||
num += ((int64_t*)pStatisBlock->counts.data)[j];
|
||||
uidIndex += 1;
|
||||
j += 1;
|
||||
loadNextStatisticsBlock(pSttFileReader, pStatisBlock, pStatisBlkArray, pStatisBlock->numOfRecords, &i, &j);
|
||||
code = loadNextStatisticsBlock(pSttFileReader, pStatisBlock, pStatisBlkArray, pStatisBlock->numOfRecords, &i, &j);
|
||||
TSDB_CHECK_CODE(code, lino, _err);
|
||||
} else if (((int64_t*)pStatisBlock->uids.data)[j] < uid) {
|
||||
j += 1;
|
||||
loadNextStatisticsBlock(pSttFileReader, pStatisBlock, pStatisBlkArray, pStatisBlock->numOfRecords, &i, &j);
|
||||
code = loadNextStatisticsBlock(pSttFileReader, pStatisBlock, pStatisBlkArray, pStatisBlock->numOfRecords, &i, &j);
|
||||
TSDB_CHECK_CODE(code, lino, _err);
|
||||
} else {
|
||||
uidIndex += 1;
|
||||
}
|
||||
}
|
||||
|
||||
(void)tStatisBlockDestroy(pStatisBlock);
|
||||
tStatisBlockDestroy(pStatisBlock);
|
||||
taosMemoryFreeClear(pStatisBlock);
|
||||
return num;
|
||||
*pNumOfRows = num;
|
||||
return code;
|
||||
|
||||
_err:
|
||||
tsdbError("%p failed to get number of rows in stt block, %s at line:%d code:%s", pSttFileReader, __func__, lino,
|
||||
tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
||||
// load next stt statistics block
|
||||
static void loadNextStatisticsBlock(SSttFileReader* pSttFileReader, STbStatisBlock* pStatisBlock,
|
||||
const TStatisBlkArray* pStatisBlkArray, int32_t numOfRows, int32_t* i, int32_t* j) {
|
||||
static int32_t loadNextStatisticsBlock(SSttFileReader* pSttFileReader, STbStatisBlock* pStatisBlock,
|
||||
const TStatisBlkArray* pStatisBlkArray, int32_t numOfRows, int32_t* i,
|
||||
int32_t* j) {
|
||||
if ((*j) >= numOfRows) {
|
||||
(*i) += 1;
|
||||
(*j) = 0;
|
||||
if ((*i) < TARRAY2_SIZE(pStatisBlkArray)) {
|
||||
(void)tsdbSttFileReadStatisBlock(pSttFileReader, &pStatisBlkArray->data[(*i)], pStatisBlock);
|
||||
int32_t code = tsdbSttFileReadStatisBlock(pSttFileReader, &pStatisBlkArray->data[(*i)], pStatisBlock);
|
||||
if (code != 0) {
|
||||
tsdbError("%p failed to read statisBlock, code:%s", pSttFileReader, tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t doAdjustValidDataIters(SArray* pLDIterList, int32_t numOfFileObj) {
|
||||
|
@ -1191,8 +1216,13 @@ int32_t tsdbGetRowsInSttFiles(STFileSet* pFileSet, SArray* pSttFileBlockIterArra
|
|||
STsdbReader* pReader = pConf->pReader;
|
||||
int32_t numOfTables = tSimpleHashGetSize(pReader->status.pTableMap);
|
||||
uint64_t* pUidList = pReader->status.uidList.tableUidList;
|
||||
numOfRows += getNumOfRowsInSttBlock(pIter->pReader, pIter->pBlockLoadInfo, pStatisBlkArray, pConf->suid, pUidList,
|
||||
numOfTables);
|
||||
int32_t n = 0;
|
||||
code = getNumOfRowsInSttBlock(pIter->pReader, pIter->pBlockLoadInfo, pStatisBlkArray, pConf->suid, pUidList,
|
||||
numOfTables, &n);
|
||||
numOfRows += n;
|
||||
if (code) {
|
||||
tsdbError("%s failed to get rows in stt blocks, code:%s", pstr, tstrerror(code));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -343,7 +343,7 @@ int32_t loadDataFileTombDataForAll(STsdbReader* pReader);
|
|||
int32_t loadSttTombDataForAll(STsdbReader* pReader, SSttFileReader* pSttFileReader, SSttBlockLoadInfo* pLoadInfo);
|
||||
int32_t getNumOfRowsInSttBlock(SSttFileReader* pSttFileReader, SSttBlockLoadInfo* pBlockLoadInfo,
|
||||
TStatisBlkArray* pStatisBlkArray, uint64_t suid, const uint64_t* pUidList,
|
||||
int32_t numOfTables);
|
||||
int32_t numOfTables, int32_t* pNumOfRows);
|
||||
void recordToBlockInfo(SFileDataBlockInfo* pBlockInfo, SBrinRecord* record);
|
||||
|
||||
void destroyLDataIter(SLDataIter* pIter);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -125,9 +125,12 @@ void tsdbCloseFile(STsdbFD **ppFD) {
|
|||
STsdbFD *pFD = *ppFD;
|
||||
if (pFD) {
|
||||
taosMemoryFree(pFD->pBuf);
|
||||
// if (!pFD->s3File) {
|
||||
(void)taosCloseFile(&pFD->pFD);
|
||||
//}
|
||||
int32_t code = taosCloseFile(&pFD->pFD);
|
||||
if (code) {
|
||||
tsdbError("failed to close file: %s, code:%d reason:%s", pFD->path, code, tstrerror(code));
|
||||
} else {
|
||||
tsdbTrace("close file: %s", pFD->path);
|
||||
}
|
||||
taosMemoryFree(pFD);
|
||||
*ppFD = NULL;
|
||||
}
|
||||
|
@ -154,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){
|
||||
|
@ -183,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) {
|
||||
|
@ -220,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);
|
||||
}
|
||||
|
@ -373,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);
|
||||
}
|
||||
|
@ -632,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);
|
||||
|
@ -657,7 +660,6 @@ int32_t tsdbDataFReaderClose(SDataFReader **ppReader) {
|
|||
}
|
||||
taosMemoryFree(*ppReader);
|
||||
*ppReader = NULL;
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t tsdbReadBlockIdx(SDataFReader *pReader, SArray *aBlockIdx) {
|
||||
|
@ -816,7 +818,7 @@ _exit:
|
|||
return code;
|
||||
}
|
||||
|
||||
int32_t tsdbDelFReaderClose(SDelFReader **ppReader) {
|
||||
void tsdbDelFReaderClose(SDelFReader **ppReader) {
|
||||
int32_t code = 0;
|
||||
SDelFReader *pReader = *ppReader;
|
||||
|
||||
|
@ -829,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:
|
||||
|
@ -112,18 +112,18 @@ static int32_t tsdbDoCopyFile(SRTNer *rtner, const STFileObj *from, const STFile
|
|||
TdFilePtr fdFrom = NULL;
|
||||
TdFilePtr fdTo = NULL;
|
||||
|
||||
(void)tsdbTFileName(rtner->tsdb, to, fname);
|
||||
tsdbTFileName(rtner->tsdb, to, fname);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -425,11 +426,11 @@ static int32_t tsdbCopyFileS3(SRTNer *rtner, const STFileObj *from, const STFile
|
|||
TdFilePtr fdFrom = NULL;
|
||||
// TdFilePtr fdTo = NULL;
|
||||
|
||||
(void)tsdbTFileName(rtner->tsdb, to, fname);
|
||||
tsdbTFileName(rtner->tsdb, to, fname);
|
||||
|
||||
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);
|
||||
|
@ -484,7 +485,7 @@ static int32_t tsdbMigrateDataFileLCS3(SRTNer *rtner, const STFileObj *fobj, int
|
|||
TAOS_CHECK_GOTO(TARRAY2_APPEND(&rtner->fopArr, op), &lino, _exit);
|
||||
|
||||
char fname[TSDB_FILENAME_LEN];
|
||||
(void)tsdbTFileName(rtner->tsdb, &op.nf, fname);
|
||||
tsdbTFileName(rtner->tsdb, &op.nf, fname);
|
||||
char *object_name = taosDirEntryBaseName(fname);
|
||||
char object_name_prefix[TSDB_FILENAME_LEN];
|
||||
int32_t node_id = vnodeNodeId(rtner->tsdb->pVnode);
|
||||
|
@ -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:
|
||||
|
@ -585,7 +586,7 @@ static int32_t tsdbMigrateDataFileS3(SRTNer *rtner, const STFileObj *fobj, int64
|
|||
TAOS_CHECK_GOTO(TARRAY2_APPEND(&rtner->fopArr, op), &lino, _exit);
|
||||
|
||||
char fname[TSDB_FILENAME_LEN];
|
||||
(void)tsdbTFileName(rtner->tsdb, &op.nf, fname);
|
||||
tsdbTFileName(rtner->tsdb, &op.nf, fname);
|
||||
char *object_name = taosDirEntryBaseName(fname);
|
||||
char object_name_prefix[TSDB_FILENAME_LEN];
|
||||
int32_t node_id = vnodeNodeId(rtner->tsdb->pVnode);
|
||||
|
@ -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;
|
||||
|
||||
|
@ -191,7 +207,7 @@ int32_t tsdbFSetPartListToRangeDiff(STsdbFSetPartList* pList, TFileSetRangeArray
|
|||
|
||||
_err:
|
||||
if (pDiff) {
|
||||
(void)tsdbTFileSetRangeArrayDestroy(&pDiff);
|
||||
tsdbTFileSetRangeArrayDestroy(&pDiff);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
@ -355,7 +371,11 @@ static STsdbFSetPartList* tsdbSnapGetFSetPartList(STFileSystem* fs) {
|
|||
terrno = code;
|
||||
break;
|
||||
}
|
||||
(void)TARRAY2_SORT_INSERT(pList, pItem, tsdbFSetPartCmprFn);
|
||||
code = TARRAY2_SORT_INSERT(pList, pItem, tsdbFSetPartCmprFn);
|
||||
if (code) {
|
||||
terrno = code;
|
||||
break;
|
||||
}
|
||||
}
|
||||
(void)taosThreadMutexUnlock(&fs->tsdb->mutex);
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ struct STsdbSnapReader {
|
|||
|
||||
static int32_t tsdbSnapReadFileSetCloseReader(STsdbSnapReader* reader) {
|
||||
TARRAY2_CLEAR(reader->sttReaderArr, tsdbSttFileReaderClose);
|
||||
TAOS_UNUSED(tsdbDataFileReaderClose(&reader->dataReader));
|
||||
tsdbDataFileReaderClose(&reader->dataReader);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,7 @@ static int32_t tsdbSnapReadFileSetOpenReader(STsdbSnapReader* reader) {
|
|||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
if ((code = TARRAY2_APPEND(reader->sttReaderArr, sttReader))) {
|
||||
TAOS_UNUSED(tsdbSttFileReaderClose(&sttReader));
|
||||
tsdbSttFileReaderClose(&sttReader);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
}
|
||||
|
@ -191,8 +191,8 @@ _exit:
|
|||
}
|
||||
|
||||
static int32_t tsdbSnapReadFileSetCloseIter(STsdbSnapReader* reader) {
|
||||
TAOS_UNUSED(tsdbIterMergerClose(&reader->dataIterMerger));
|
||||
TAOS_UNUSED(tsdbIterMergerClose(&reader->tombIterMerger));
|
||||
tsdbIterMergerClose(&reader->dataIterMerger);
|
||||
tsdbIterMergerClose(&reader->tombIterMerger);
|
||||
TARRAY2_CLEAR(reader->dataIterArr, tsdbIterClose);
|
||||
TARRAY2_CLEAR(reader->tombIterArr, tsdbIterClose);
|
||||
return 0;
|
||||
|
@ -430,7 +430,7 @@ _exit:
|
|||
if (code) {
|
||||
tsdbError("vgId:%d %s failed at %s:%d since %s, sver:%" PRId64 " ever:%" PRId64 " type:%d", TD_VID(tsdb->pVnode),
|
||||
__func__, __FILE__, lino, tstrerror(code), sver, ever, type);
|
||||
TAOS_UNUSED(tsdbTFileSetRangeArrayDestroy(&reader[0]->fsrArr));
|
||||
tsdbTFileSetRangeArrayDestroy(&reader[0]->fsrArr);
|
||||
taosMemoryFree(reader[0]);
|
||||
reader[0] = NULL;
|
||||
} else {
|
||||
|
@ -449,17 +449,17 @@ int32_t tsdbSnapReaderClose(STsdbSnapReader** reader) {
|
|||
|
||||
STsdb* tsdb = reader[0]->tsdb;
|
||||
|
||||
TAOS_UNUSED(tTombBlockDestroy(reader[0]->tombBlock));
|
||||
tTombBlockDestroy(reader[0]->tombBlock);
|
||||
tBlockDataDestroy(reader[0]->blockData);
|
||||
|
||||
TAOS_UNUSED(tsdbIterMergerClose(&reader[0]->dataIterMerger));
|
||||
TAOS_UNUSED(tsdbIterMergerClose(&reader[0]->tombIterMerger));
|
||||
tsdbIterMergerClose(&reader[0]->dataIterMerger);
|
||||
tsdbIterMergerClose(&reader[0]->tombIterMerger);
|
||||
TARRAY2_DESTROY(reader[0]->dataIterArr, tsdbIterClose);
|
||||
TARRAY2_DESTROY(reader[0]->tombIterArr, tsdbIterClose);
|
||||
TARRAY2_DESTROY(reader[0]->sttReaderArr, tsdbSttFileReaderClose);
|
||||
TAOS_UNUSED(tsdbDataFileReaderClose(&reader[0]->dataReader));
|
||||
tsdbDataFileReaderClose(&reader[0]->dataReader);
|
||||
|
||||
TAOS_UNUSED(tsdbFSDestroyRefRangedSnapshot(&reader[0]->fsrArr));
|
||||
tsdbFSDestroyRefRangedSnapshot(&reader[0]->fsrArr);
|
||||
tDestroyTSchema(reader[0]->skmTb->pTSchema);
|
||||
|
||||
for (int32_t i = 0; i < ARRAY_SIZE(reader[0]->buffers); ++i) {
|
||||
|
@ -691,7 +691,7 @@ _exit:
|
|||
|
||||
static int32_t tsdbSnapWriteFileSetCloseReader(STsdbSnapWriter* writer) {
|
||||
TARRAY2_CLEAR(writer->ctx->sttReaderArr, tsdbSttFileReaderClose);
|
||||
TAOS_UNUSED(tsdbDataFileReaderClose(&writer->ctx->dataReader));
|
||||
tsdbDataFileReaderClose(&writer->ctx->dataReader);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -767,8 +767,8 @@ _exit:
|
|||
}
|
||||
|
||||
static int32_t tsdbSnapWriteFileSetCloseIter(STsdbSnapWriter* writer) {
|
||||
TAOS_UNUSED(tsdbIterMergerClose(&writer->ctx->dataIterMerger));
|
||||
TAOS_UNUSED(tsdbIterMergerClose(&writer->ctx->tombIterMerger));
|
||||
tsdbIterMergerClose(&writer->ctx->dataIterMerger);
|
||||
tsdbIterMergerClose(&writer->ctx->tombIterMerger);
|
||||
TARRAY2_CLEAR(writer->ctx->dataIterArr, tsdbIterClose);
|
||||
TARRAY2_CLEAR(writer->ctx->tombIterArr, tsdbIterClose);
|
||||
return 0;
|
||||
|
@ -1119,15 +1119,15 @@ int32_t tsdbSnapWriterClose(STsdbSnapWriter** writer, int8_t rollback) {
|
|||
(void)taosThreadMutexUnlock(&writer[0]->tsdb->mutex);
|
||||
}
|
||||
|
||||
TAOS_UNUSED(tsdbIterMergerClose(&writer[0]->ctx->tombIterMerger));
|
||||
TAOS_UNUSED(tsdbIterMergerClose(&writer[0]->ctx->dataIterMerger));
|
||||
tsdbIterMergerClose(&writer[0]->ctx->tombIterMerger);
|
||||
tsdbIterMergerClose(&writer[0]->ctx->dataIterMerger);
|
||||
TARRAY2_DESTROY(writer[0]->ctx->tombIterArr, tsdbIterClose);
|
||||
TARRAY2_DESTROY(writer[0]->ctx->dataIterArr, tsdbIterClose);
|
||||
TARRAY2_DESTROY(writer[0]->ctx->sttReaderArr, tsdbSttFileReaderClose);
|
||||
TAOS_UNUSED(tsdbDataFileReaderClose(&writer[0]->ctx->dataReader));
|
||||
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;
|
||||
|
|
|
@ -55,7 +55,7 @@ int32_t tsdbSttFileReaderOpen(const char *fname, const SSttFileReaderConfig *con
|
|||
TAOS_CHECK_GOTO(tsdbOpenFile(fname, config->tsdb, TD_FILE_READ, &reader[0]->fd, 0), &lino, _exit);
|
||||
} else {
|
||||
char fname1[TSDB_FILENAME_LEN];
|
||||
(void)tsdbTFileName(config->tsdb, config->file, fname1);
|
||||
tsdbTFileName(config->tsdb, config->file, fname1);
|
||||
TAOS_CHECK_GOTO(tsdbOpenFile(fname1, config->tsdb, TD_FILE_READ, &reader[0]->fd, 0), &lino, _exit);
|
||||
}
|
||||
|
||||
|
@ -93,12 +93,12 @@ _exit:
|
|||
if (code) {
|
||||
tsdbError("vgId:%d %s failed at %s:%d since %s", TD_VID(config->tsdb->pVnode), __func__, __FILE__, lino,
|
||||
tstrerror(code));
|
||||
(void)tsdbSttFileReaderClose(reader);
|
||||
tsdbSttFileReaderClose(reader);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t tsdbSttFileReaderClose(SSttFileReader **reader) {
|
||||
void tsdbSttFileReaderClose(SSttFileReader **reader) {
|
||||
if (reader[0]) {
|
||||
for (int32_t i = 0; i < ARRAY_SIZE(reader[0]->local); ++i) {
|
||||
tBufferDestroy(reader[0]->local + i);
|
||||
|
@ -110,7 +110,6 @@ int32_t tsdbSttFileReaderClose(SSttFileReader **reader) {
|
|||
taosMemoryFree(reader[0]);
|
||||
reader[0] = NULL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// SSttFSegReader
|
||||
|
@ -524,7 +523,7 @@ static int32_t tsdbFileDoWriteSttBlockData(STsdbFD *fd, SBlockData *blockData, S
|
|||
if (sttBlk->maxVer < blockData->aVersion[iRow]) sttBlk->maxVer = blockData->aVersion[iRow];
|
||||
}
|
||||
|
||||
(void)tsdbWriterUpdVerRange(range, sttBlk->minVer, sttBlk->maxVer);
|
||||
tsdbWriterUpdVerRange(range, sttBlk->minVer, sttBlk->maxVer);
|
||||
TAOS_CHECK_RETURN(tBlockDataCompress(blockData, info, buffers, buffers + 4));
|
||||
|
||||
sttBlk->bInfo.offset = *fileSize;
|
||||
|
@ -591,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;
|
||||
|
||||
|
@ -807,7 +808,7 @@ static int32_t tsdbSttFWriterDoOpen(SSttFileWriter *writer) {
|
|||
int32_t flag = TD_FILE_READ | TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC;
|
||||
char fname[TSDB_FILENAME_LEN];
|
||||
|
||||
(void)tsdbTFileName(writer->config->tsdb, writer->file, fname);
|
||||
tsdbTFileName(writer->config->tsdb, writer->file, fname);
|
||||
TAOS_CHECK_GOTO(tsdbOpenFile(fname, writer->config->tsdb, flag, &writer->fd, 0), &lino, _exit);
|
||||
|
||||
uint8_t hdr[TSDB_FHDR_SIZE] = {0};
|
||||
|
@ -837,7 +838,7 @@ static void tsdbSttFWriterDoClose(SSttFileWriter *writer) {
|
|||
tDestroyTSchema(writer->skmRow->pTSchema);
|
||||
tDestroyTSchema(writer->skmTb->pTSchema);
|
||||
tTombBlockDestroy(writer->tombBlock);
|
||||
(void)tStatisBlockDestroy(writer->staticBlock);
|
||||
tStatisBlockDestroy(writer->staticBlock);
|
||||
tBlockDataDestroy(writer->blockData);
|
||||
TARRAY2_DESTROY(writer->tombBlkArray, NULL);
|
||||
TARRAY2_DESTROY(writer->statisBlkArray, NULL);
|
||||
|
@ -874,7 +875,7 @@ static int32_t tsdbSttFWriterCloseCommit(SSttFileWriter *writer, TFileOpArray *o
|
|||
.fid = writer->config->fid,
|
||||
.nf = writer->file[0],
|
||||
};
|
||||
(void)tsdbTFileUpdVerRange(&op.nf, writer->ctx->range);
|
||||
tsdbTFileUpdVerRange(&op.nf, writer->ctx->range);
|
||||
|
||||
TAOS_CHECK_GOTO(TARRAY2_APPEND(opArray, op), &lino, _exit);
|
||||
|
||||
|
@ -888,9 +889,9 @@ _exit:
|
|||
|
||||
static int32_t tsdbSttFWriterCloseAbort(SSttFileWriter *writer) {
|
||||
char fname[TSDB_FILENAME_LEN];
|
||||
(void)tsdbTFileName(writer->config->tsdb, writer->file, fname);
|
||||
tsdbTFileName(writer->config->tsdb, writer->file, fname);
|
||||
tsdbCloseFile(&writer->fd);
|
||||
(void)taosRemoveFile(fname);
|
||||
tsdbRemoveFile(fname);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ typedef TARRAY2(SSttFileReader *) TSttFileReaderArray;
|
|||
|
||||
// SSttFileReader
|
||||
int32_t tsdbSttFileReaderOpen(const char *fname, const SSttFileReaderConfig *config, SSttFileReader **reader);
|
||||
int32_t tsdbSttFileReaderClose(SSttFileReader **reader);
|
||||
void tsdbSttFileReaderClose(SSttFileReader **reader);
|
||||
|
||||
// SSttSegReader
|
||||
int32_t tsdbSttFileReadSttBlk(SSttFileReader *reader, const TSttBlkArray **sttBlkArray);
|
||||
|
@ -71,10 +71,10 @@ int32_t tsdbSttFileWriteBlockData(SSttFileWriter *writer, SBlockData *pBlockData
|
|||
int32_t tsdbSttFileWriteTombRecord(SSttFileWriter *writer, const STombRecord *record);
|
||||
bool tsdbSttFileWriterIsOpened(SSttFileWriter *writer);
|
||||
|
||||
int32_t tsdbFileWriteSttBlk(STsdbFD *fd, const TSttBlkArray *sttBlkArray, SFDataPtr *ptr, int64_t *fileSize,
|
||||
int32_t encryptAlgorithm, char* encryptKey);
|
||||
int32_t tsdbFileWriteSttFooter(STsdbFD *fd, const SSttFooter *footer, int64_t *fileSize, int32_t encryptAlgorithm,
|
||||
char* encryptKey);
|
||||
int32_t tsdbFileWriteSttBlk(STsdbFD *fd, const TSttBlkArray *sttBlkArray, SFDataPtr *ptr, int64_t *fileSize,
|
||||
int32_t encryptAlgorithm, char *encryptKey);
|
||||
int32_t tsdbFileWriteSttFooter(STsdbFD *fd, const SSttFooter *footer, int64_t *fileSize, int32_t encryptAlgorithm,
|
||||
char *encryptKey);
|
||||
|
||||
struct SSttFileWriterConfig {
|
||||
STsdb *tsdb;
|
||||
|
|
|
@ -23,8 +23,6 @@
|
|||
#include "tsdbDataFileRW.h"
|
||||
#include "tsdbFS2.h"
|
||||
#include "tsdbSttFileRW.h"
|
||||
// extern int32_t save_fs(const TFileSetArray *arr, const char *fname);
|
||||
// extern int32_t current_fname(STsdb *pTsdb, char *fname, EFCurrentT ftype);
|
||||
|
||||
static int32_t tsdbUpgradeHead(STsdb *tsdb, SDFileSet *pDFileSet, SDataFReader *reader, STFileSet *fset) {
|
||||
int32_t code = 0;
|
||||
|
@ -79,7 +77,7 @@ static int32_t tsdbUpgradeHead(STsdb *tsdb, SDFileSet *pDFileSet, SDataFReader *
|
|||
|
||||
// open fd
|
||||
char fname[TSDB_FILENAME_LEN];
|
||||
(void)tsdbTFileName(tsdb, &file, fname);
|
||||
tsdbTFileName(tsdb, &file, fname);
|
||||
|
||||
TAOS_CHECK_GOTO(tsdbOpenFile(fname, tsdb, TD_FILE_READ | TD_FILE_WRITE, &ctx->fd, 0), &lino, _exit);
|
||||
|
||||
|
@ -167,7 +165,7 @@ _exit:
|
|||
tsdbError("vgId:%d %s failed at %s:%d since %s", TD_VID(tsdb->pVnode), __func__, __FILE__, lino, tstrerror(code));
|
||||
}
|
||||
TARRAY2_DESTROY(ctx->brinBlkArray, NULL);
|
||||
(void)tBrinBlockDestroy(ctx->brinBlock);
|
||||
tBrinBlockDestroy(ctx->brinBlock);
|
||||
tBlockDataDestroy(ctx->blockData);
|
||||
tMapDataClear(ctx->mDataBlk);
|
||||
taosArrayDestroy(ctx->aBlockIdx);
|
||||
|
@ -321,7 +319,7 @@ static int32_t tsdbUpgradeStt(STsdb *tsdb, SDFileSet *pDFileSet, SDataFReader *r
|
|||
if (TARRAY2_SIZE(lvl->fobjArr) > 0) {
|
||||
TAOS_CHECK_GOTO(TARRAY2_APPEND(fset->lvlArr, lvl), &lino, _exit);
|
||||
} else {
|
||||
(void)tsdbSttLvlClear(&lvl);
|
||||
tsdbSttLvlClear(&lvl);
|
||||
}
|
||||
|
||||
_exit:
|
||||
|
@ -358,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);
|
||||
|
||||
|
@ -570,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;
|
||||
}
|
||||
|
@ -612,7 +610,7 @@ static int32_t tsdbUpgradeFileSystem(STsdb *tsdb, int8_t rollback) {
|
|||
|
||||
// save new file system
|
||||
char fname[TSDB_FILENAME_LEN];
|
||||
(void)current_fname(tsdb, fname, TSDB_FCURRENT);
|
||||
current_fname(tsdb, fname, TSDB_FCURRENT);
|
||||
TAOS_CHECK_GOTO(save_fs(fileSetArray, fname), &lino, _exit);
|
||||
|
||||
_exit:
|
||||
|
@ -632,6 +630,6 @@ int32_t tsdbCheckAndUpgradeFileSystem(STsdb *tsdb, int8_t rollback) {
|
|||
|
||||
TAOS_CHECK_RETURN(tsdbUpgradeFileSystem(tsdb, rollback));
|
||||
|
||||
(void)taosRemoveFile(fname);
|
||||
tsdbRemoveFile(fname);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -84,12 +84,12 @@ int32_t tStatisBlockInit(STbStatisBlock *statisBlock) {
|
|||
|
||||
_exit:
|
||||
if (code) {
|
||||
TAOS_UNUSED(tStatisBlockDestroy(statisBlock));
|
||||
tStatisBlockDestroy(statisBlock);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t tStatisBlockDestroy(STbStatisBlock *statisBlock) {
|
||||
void tStatisBlockDestroy(STbStatisBlock *statisBlock) {
|
||||
statisBlock->numOfPKs = 0;
|
||||
statisBlock->numOfRecords = 0;
|
||||
for (int32_t i = 0; i < ARRAY_SIZE(statisBlock->buffers); ++i) {
|
||||
|
@ -99,7 +99,6 @@ int32_t tStatisBlockDestroy(STbStatisBlock *statisBlock) {
|
|||
TAOS_UNUSED(tValueColumnDestroy(&statisBlock->firstKeyPKs[i]));
|
||||
TAOS_UNUSED(tValueColumnDestroy(&statisBlock->lastKeyPKs[i]));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t tStatisBlockClear(STbStatisBlock *statisBlock) {
|
||||
|
@ -244,12 +243,12 @@ int32_t tBrinBlockInit(SBrinBlock *brinBlock) {
|
|||
|
||||
_exit:
|
||||
if (code) {
|
||||
(void)tBrinBlockDestroy(brinBlock);
|
||||
tBrinBlockDestroy(brinBlock);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t tBrinBlockDestroy(SBrinBlock *brinBlock) {
|
||||
void tBrinBlockDestroy(SBrinBlock *brinBlock) {
|
||||
brinBlock->numOfPKs = 0;
|
||||
brinBlock->numOfRecords = 0;
|
||||
for (int32_t i = 0; i < ARRAY_SIZE(brinBlock->buffers); ++i) {
|
||||
|
@ -259,10 +258,9 @@ int32_t tBrinBlockDestroy(SBrinBlock *brinBlock) {
|
|||
TAOS_UNUSED(tValueColumnDestroy(&brinBlock->firstKeyPKs[i]));
|
||||
TAOS_UNUSED(tValueColumnDestroy(&brinBlock->lastKeyPKs[i]));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t tBrinBlockClear(SBrinBlock *brinBlock) {
|
||||
void tBrinBlockClear(SBrinBlock *brinBlock) {
|
||||
brinBlock->numOfPKs = 0;
|
||||
brinBlock->numOfRecords = 0;
|
||||
for (int32_t i = 0; i < ARRAY_SIZE(brinBlock->buffers); ++i) {
|
||||
|
@ -272,7 +270,6 @@ int32_t tBrinBlockClear(SBrinBlock *brinBlock) {
|
|||
TAOS_UNUSED(tValueColumnClear(&brinBlock->firstKeyPKs[i]));
|
||||
TAOS_UNUSED(tValueColumnClear(&brinBlock->lastKeyPKs[i]));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t tBrinBlockPut(SBrinBlock *brinBlock, const SBrinRecord *record) {
|
||||
|
|
|
@ -112,7 +112,7 @@ typedef struct {
|
|||
#define STATIS_BLOCK_SIZE(db) ((db)->numOfRecords)
|
||||
|
||||
int32_t tStatisBlockInit(STbStatisBlock *statisBlock);
|
||||
int32_t tStatisBlockDestroy(STbStatisBlock *statisBlock);
|
||||
void tStatisBlockDestroy(STbStatisBlock *statisBlock);
|
||||
int32_t tStatisBlockClear(STbStatisBlock *statisBlock);
|
||||
int32_t tStatisBlockPut(STbStatisBlock *statisBlock, SRowInfo *row, int32_t maxRecords);
|
||||
int32_t tStatisBlockGet(STbStatisBlock *statisBlock, int32_t idx, STbStatisRecord *record);
|
||||
|
@ -179,8 +179,8 @@ typedef TARRAY2(SBrinBlk) TBrinBlkArray;
|
|||
#define BRIN_BLOCK_SIZE(db) ((db)->numOfRecords)
|
||||
|
||||
int32_t tBrinBlockInit(SBrinBlock *brinBlock);
|
||||
int32_t tBrinBlockDestroy(SBrinBlock *brinBlock);
|
||||
int32_t tBrinBlockClear(SBrinBlock *brinBlock);
|
||||
void tBrinBlockDestroy(SBrinBlock *brinBlock);
|
||||
void tBrinBlockClear(SBrinBlock *brinBlock);
|
||||
int32_t tBrinBlockPut(SBrinBlock *brinBlock, const SBrinRecord *record);
|
||||
int32_t tBrinBlockGet(SBrinBlock *brinBlock, int32_t idx, SBrinRecord *record);
|
||||
|
||||
|
|
|
@ -122,7 +122,7 @@ SVAsync *vnodeAsyncs[3];
|
|||
#define MIN_ASYNC_ID 1
|
||||
#define MAX_ASYNC_ID (sizeof(vnodeAsyncs) / sizeof(vnodeAsyncs[0]) - 1)
|
||||
|
||||
static int32_t vnodeAsyncTaskDone(SVAsync *async, SVATask *task) {
|
||||
static void vnodeAsyncTaskDone(SVAsync *async, SVATask *task) {
|
||||
int32_t ret;
|
||||
|
||||
if (task->channel != NULL && task->channel->scheduled == task) {
|
||||
|
@ -176,10 +176,9 @@ static int32_t vnodeAsyncTaskDone(SVAsync *async, SVATask *task) {
|
|||
} else {
|
||||
(void)taosThreadCondBroadcast(&task->waitCond);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t vnodeAsyncCancelAllTasks(SVAsync *async, SArray *cancelArray) {
|
||||
static void vnodeAsyncCancelAllTasks(SVAsync *async, SArray *cancelArray) {
|
||||
while (async->queue[0].next != &async->queue[0] || async->queue[1].next != &async->queue[1] ||
|
||||
async->queue[2].next != &async->queue[2]) {
|
||||
for (int32_t i = 0; i < EVA_PRIORITY_MAX; i++) {
|
||||
|
@ -193,11 +192,10 @@ static int32_t vnodeAsyncCancelAllTasks(SVAsync *async, SArray *cancelArray) {
|
|||
.arg = task->arg,
|
||||
}));
|
||||
}
|
||||
(void)vnodeAsyncTaskDone(async, task);
|
||||
vnodeAsyncTaskDone(async, task);
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void *vnodeAsyncLoop(void *arg) {
|
||||
|
@ -215,14 +213,14 @@ static void *vnodeAsyncLoop(void *arg) {
|
|||
|
||||
// finish last running task
|
||||
if (worker->runningTask != NULL) {
|
||||
(void)vnodeAsyncTaskDone(async, worker->runningTask);
|
||||
vnodeAsyncTaskDone(async, worker->runningTask);
|
||||
worker->runningTask = NULL;
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
if (async->stop || worker->workerId >= async->numWorkers) {
|
||||
if (async->stop) { // cancel all tasks
|
||||
(void)vnodeAsyncCancelAllTasks(async, cancelArray);
|
||||
vnodeAsyncCancelAllTasks(async, cancelArray);
|
||||
}
|
||||
worker->state = EVA_WORKER_STATE_STOP;
|
||||
async->numLaunchWorkers--;
|
||||
|
@ -269,7 +267,8 @@ static void *vnodeAsyncLoop(void *arg) {
|
|||
(void)taosThreadMutexUnlock(&async->mutex);
|
||||
|
||||
// do run the task
|
||||
(void)worker->runningTask->execute(worker->runningTask->arg);
|
||||
int32_t code = worker->runningTask->execute(worker->runningTask->arg);
|
||||
TAOS_UNUSED(code);
|
||||
}
|
||||
|
||||
_exit:
|
||||
|
@ -369,7 +368,7 @@ static int32_t vnodeAsyncInit(SVAsync **async, const char *label) {
|
|||
}
|
||||
ret = vHashInit(&(*async)->taskTable, vnodeAsyncTaskHash, vnodeAsyncTaskCompare);
|
||||
if (ret != 0) {
|
||||
(void)vHashDestroy(&(*async)->channelTable);
|
||||
vHashDestroy(&(*async)->channelTable);
|
||||
(void)taosThreadMutexDestroy(&(*async)->mutex);
|
||||
(void)taosThreadCondDestroy(&(*async)->hasTask);
|
||||
taosMemoryFree(*async);
|
||||
|
@ -418,29 +417,32 @@ static int32_t vnodeAsyncDestroy(SVAsync **async) {
|
|||
(void)taosThreadMutexDestroy(&(*async)->mutex);
|
||||
(void)taosThreadCondDestroy(&(*async)->hasTask);
|
||||
|
||||
(void)vHashDestroy(&(*async)->channelTable);
|
||||
(void)vHashDestroy(&(*async)->taskTable);
|
||||
vHashDestroy(&(*async)->channelTable);
|
||||
vHashDestroy(&(*async)->taskTable);
|
||||
taosMemoryFree(*async);
|
||||
*async = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t vnodeAsyncLaunchWorker(SVAsync *async) {
|
||||
static void vnodeAsyncLaunchWorker(SVAsync *async) {
|
||||
for (int32_t i = 0; i < async->numWorkers; i++) {
|
||||
if (async->workers[i].state == EVA_WORKER_STATE_ACTIVE) {
|
||||
continue;
|
||||
} else if (async->workers[i].state == EVA_WORKER_STATE_STOP) {
|
||||
(void)taosThreadJoin(async->workers[i].thread, NULL);
|
||||
TAOS_UNUSED(taosThreadJoin(async->workers[i].thread, NULL));
|
||||
async->workers[i].state = EVA_WORKER_STATE_UINIT;
|
||||
}
|
||||
|
||||
(void)taosThreadCreate(&async->workers[i].thread, NULL, vnodeAsyncLoop, &async->workers[i]);
|
||||
async->workers[i].state = EVA_WORKER_STATE_ACTIVE;
|
||||
async->numLaunchWorkers++;
|
||||
int32_t ret = taosThreadCreate(&async->workers[i].thread, NULL, vnodeAsyncLoop, &async->workers[i]);
|
||||
if (ret) {
|
||||
vError("failed to create worker thread since %s", tstrerror(ret));
|
||||
} else {
|
||||
async->workers[i].state = EVA_WORKER_STATE_ACTIVE;
|
||||
async->numLaunchWorkers++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t vnodeAsyncOpen(int32_t numOfThreads) {
|
||||
|
@ -450,21 +452,25 @@ int32_t vnodeAsyncOpen(int32_t numOfThreads) {
|
|||
// vnode-commit
|
||||
code = vnodeAsyncInit(&vnodeAsyncs[1], "vnode-commit");
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
(void)vnodeAsyncSetWorkers(1, numOfThreads);
|
||||
|
||||
code = vnodeAsyncSetWorkers(1, numOfThreads);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
// vnode-merge
|
||||
code = vnodeAsyncInit(&vnodeAsyncs[2], "vnode-merge");
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
(void)vnodeAsyncSetWorkers(2, numOfThreads);
|
||||
|
||||
code = vnodeAsyncSetWorkers(2, numOfThreads);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
_exit:
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t vnodeAsyncClose() {
|
||||
(void)vnodeAsyncDestroy(&vnodeAsyncs[1]);
|
||||
(void)vnodeAsyncDestroy(&vnodeAsyncs[2]);
|
||||
return 0;
|
||||
void vnodeAsyncClose() {
|
||||
int32_t ret;
|
||||
ret = vnodeAsyncDestroy(&vnodeAsyncs[1]);
|
||||
ret = vnodeAsyncDestroy(&vnodeAsyncs[2]);
|
||||
}
|
||||
|
||||
int32_t vnodeAsync(SVAChannelID *channelID, EVAPriority priority, int32_t (*execute)(void *), void (*cancel)(void *),
|
||||
|
@ -474,6 +480,7 @@ int32_t vnodeAsync(SVAChannelID *channelID, EVAPriority priority, int32_t (*exec
|
|||
return TSDB_CODE_INVALID_PARA;
|
||||
}
|
||||
|
||||
int32_t ret;
|
||||
int64_t id;
|
||||
SVAsync *async = vnodeAsyncs[channelID->async];
|
||||
|
||||
|
@ -501,7 +508,8 @@ int32_t vnodeAsync(SVAChannelID *channelID, EVAPriority priority, int32_t (*exec
|
|||
SVAChannel channel = {
|
||||
.channelId = channelID->id,
|
||||
};
|
||||
(void)vHashGet(async->channelTable, &channel, (void **)&task->channel);
|
||||
ret = vHashGet(async->channelTable, &channel, (void **)&task->channel);
|
||||
TAOS_UNUSED(ret);
|
||||
if (task->channel == NULL) {
|
||||
(void)taosThreadMutexUnlock(&async->mutex);
|
||||
(void)taosThreadCondDestroy(&task->waitCond);
|
||||
|
@ -513,7 +521,7 @@ int32_t vnodeAsync(SVAChannelID *channelID, EVAPriority priority, int32_t (*exec
|
|||
task->taskId = id = ++async->nextTaskId;
|
||||
|
||||
// add task to hash table
|
||||
int32_t ret = vHashPut(async->taskTable, task);
|
||||
ret = vHashPut(async->taskTable, task);
|
||||
if (ret != 0) {
|
||||
(void)taosThreadMutexUnlock(&async->mutex);
|
||||
(void)taosThreadCondDestroy(&task->waitCond);
|
||||
|
@ -539,7 +547,7 @@ int32_t vnodeAsync(SVAChannelID *channelID, EVAPriority priority, int32_t (*exec
|
|||
if (async->numIdleWorkers > 0) {
|
||||
(void)taosThreadCondSignal(&(async->hasTask));
|
||||
} else if (async->numLaunchWorkers < async->numWorkers) {
|
||||
(void)vnodeAsyncLaunchWorker(async);
|
||||
vnodeAsyncLaunchWorker(async);
|
||||
}
|
||||
} else if (task->channel->scheduled->state == EVA_TASK_STATE_RUNNING ||
|
||||
priority >= VATASK_PIORITY(task->channel->scheduled)) {
|
||||
|
@ -579,9 +587,9 @@ int32_t vnodeAsync(SVAChannelID *channelID, EVAPriority priority, int32_t (*exec
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32_t vnodeAWait(SVATaskID *taskID) {
|
||||
void vnodeAWait(SVATaskID *taskID) {
|
||||
if (taskID == NULL || taskID->async < MIN_ASYNC_ID || taskID->async > MAX_ASYNC_ID || taskID->id <= 0) {
|
||||
return TSDB_CODE_INVALID_PARA;
|
||||
return;
|
||||
}
|
||||
|
||||
SVAsync *async = vnodeAsyncs[taskID->async];
|
||||
|
@ -592,7 +600,7 @@ int32_t vnodeAWait(SVATaskID *taskID) {
|
|||
|
||||
(void)taosThreadMutexLock(&async->mutex);
|
||||
|
||||
(void)vHashGet(async->taskTable, &task2, (void **)&task);
|
||||
int32_t ret = vHashGet(async->taskTable, &task2, (void **)&task);
|
||||
if (task) {
|
||||
task->numWait++;
|
||||
(void)taosThreadCondWait(&task->waitCond, &async->mutex);
|
||||
|
@ -605,8 +613,6 @@ int32_t vnodeAWait(SVATaskID *taskID) {
|
|||
}
|
||||
|
||||
(void)taosThreadMutexUnlock(&async->mutex);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t vnodeACancel(SVATaskID *taskID) {
|
||||
|
@ -625,14 +631,14 @@ int32_t vnodeACancel(SVATaskID *taskID) {
|
|||
|
||||
(void)taosThreadMutexLock(&async->mutex);
|
||||
|
||||
(void)vHashGet(async->taskTable, &task2, (void **)&task);
|
||||
ret = vHashGet(async->taskTable, &task2, (void **)&task);
|
||||
if (task) {
|
||||
if (task->state == EVA_TASK_STATE_WAITTING) {
|
||||
cancel = task->cancel;
|
||||
arg = task->arg;
|
||||
task->next->prev = task->prev;
|
||||
task->prev->next = task->next;
|
||||
(void)vnodeAsyncTaskDone(async, task);
|
||||
vnodeAsyncTaskDone(async, task);
|
||||
} else {
|
||||
ret = TSDB_CODE_FAILED;
|
||||
}
|
||||
|
@ -651,6 +657,7 @@ int32_t vnodeAsyncSetWorkers(int64_t asyncID, int32_t numWorkers) {
|
|||
if (asyncID < MIN_ASYNC_ID || asyncID > MAX_ASYNC_ID || numWorkers <= 0 || numWorkers > VNODE_ASYNC_MAX_WORKERS) {
|
||||
return TSDB_CODE_INVALID_PARA;
|
||||
}
|
||||
int32_t ret;
|
||||
SVAsync *async = vnodeAsyncs[asyncID];
|
||||
(void)taosThreadMutexLock(&async->mutex);
|
||||
async->numWorkers = numWorkers;
|
||||
|
@ -725,12 +732,13 @@ int32_t vnodeAChannelDestroy(SVAChannelID *channelID, bool waitRunning) {
|
|||
|
||||
(void)taosThreadMutexLock(&async->mutex);
|
||||
|
||||
(void)vHashGet(async->channelTable, &channel2, (void **)&channel);
|
||||
int32_t ret = vHashGet(async->channelTable, &channel2, (void **)&channel);
|
||||
TAOS_UNUSED(ret);
|
||||
if (channel) {
|
||||
// unregister channel
|
||||
channel->next->prev = channel->prev;
|
||||
channel->prev->next = channel->next;
|
||||
(void)vHashDrop(async->channelTable, channel);
|
||||
ret = vHashDrop(async->channelTable, channel);
|
||||
async->numChannels--;
|
||||
|
||||
// cancel all waiting tasks
|
||||
|
@ -745,7 +753,7 @@ int32_t vnodeAChannelDestroy(SVAChannelID *channelID, bool waitRunning) {
|
|||
.arg = task->arg,
|
||||
}));
|
||||
}
|
||||
(void)vnodeAsyncTaskDone(async, task);
|
||||
vnodeAsyncTaskDone(async, task);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -760,7 +768,7 @@ int32_t vnodeAChannelDestroy(SVAChannelID *channelID, bool waitRunning) {
|
|||
.arg = channel->scheduled->arg,
|
||||
}));
|
||||
}
|
||||
(void)vnodeAsyncTaskDone(async, channel->scheduled);
|
||||
vnodeAsyncTaskDone(async, channel->scheduled);
|
||||
}
|
||||
taosMemoryFree(channel);
|
||||
} else {
|
||||
|
|
|
@ -58,7 +58,7 @@ static int32_t vnodeBufPoolCreate(SVnode *pVnode, int32_t id, int64_t size, SVBu
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int vnodeBufPoolDestroy(SVBufPool *pPool) {
|
||||
static void vnodeBufPoolDestroy(SVBufPool *pPool) {
|
||||
vnodeBufPoolReset(pPool);
|
||||
if (pPool->lock) {
|
||||
(void)taosThreadSpinDestroy(pPool->lock);
|
||||
|
@ -66,7 +66,6 @@ static int vnodeBufPoolDestroy(SVBufPool *pPool) {
|
|||
}
|
||||
(void)taosThreadMutexDestroy(&pPool->mutex);
|
||||
taosMemoryFree(pPool);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int vnodeOpenBufPool(SVnode *pVnode) {
|
||||
|
@ -77,7 +76,7 @@ int vnodeOpenBufPool(SVnode *pVnode) {
|
|||
int32_t code;
|
||||
if ((code = vnodeBufPoolCreate(pVnode, i, size, &pVnode->aBufPool[i]))) {
|
||||
vError("vgId:%d, failed to open vnode buffer pool since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||
(void)vnodeCloseBufPool(pVnode);
|
||||
vnodeCloseBufPool(pVnode);
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -90,16 +89,15 @@ int vnodeOpenBufPool(SVnode *pVnode) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int vnodeCloseBufPool(SVnode *pVnode) {
|
||||
void vnodeCloseBufPool(SVnode *pVnode) {
|
||||
for (int32_t i = 0; i < VNODE_BUFPOOL_SEGMENTS; i++) {
|
||||
if (pVnode->aBufPool[i]) {
|
||||
(void)vnodeBufPoolDestroy(pVnode->aBufPool[i]);
|
||||
vnodeBufPoolDestroy(pVnode->aBufPool[i]);
|
||||
pVnode->aBufPool[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
vDebug("vgId:%d, vnode buffer pool is closed", TD_VID(pVnode));
|
||||
return 0;
|
||||
}
|
||||
|
||||
void vnodeBufPoolReset(SVBufPool *pPool) {
|
||||
|
@ -234,7 +232,7 @@ void vnodeBufPoolAddToFreeList(SVBufPool *pPool) {
|
|||
vInfo("vgId:%d, buffer pool of id %d size changed from %" PRId64 " to %" PRId64, TD_VID(pVnode), pPool->id,
|
||||
pPool->node.size, size);
|
||||
|
||||
(void)vnodeBufPoolDestroy(pPool);
|
||||
vnodeBufPoolDestroy(pPool);
|
||||
pPool = pNewPool;
|
||||
pVnode->aBufPool[pPool->id] = pPool;
|
||||
}
|
||||
|
@ -286,7 +284,7 @@ _exit:
|
|||
return;
|
||||
}
|
||||
|
||||
int32_t vnodeBufPoolRegisterQuery(SVBufPool *pPool, SQueryNode *pQNode) {
|
||||
void vnodeBufPoolRegisterQuery(SVBufPool *pPool, SQueryNode *pQNode) {
|
||||
(void)taosThreadMutexLock(&pPool->mutex);
|
||||
|
||||
pQNode->pNext = pPool->qList.pNext;
|
||||
|
@ -296,7 +294,6 @@ int32_t vnodeBufPoolRegisterQuery(SVBufPool *pPool, SQueryNode *pQNode) {
|
|||
pPool->nQuery++;
|
||||
|
||||
(void)taosThreadMutexUnlock(&pPool->mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void vnodeBufPoolDeregisterQuery(SVBufPool *pPool, SQueryNode *pQNode, bool proactive) {
|
||||
|
|
|
@ -351,7 +351,7 @@ int vnodeDecodeConfig(const SJson *pJson, void *pObj) {
|
|||
if (info == NULL) return -1;
|
||||
tjsonGetNumberValue(info, "nodePort", pNode->nodePort, code);
|
||||
if (code) return code;
|
||||
(void)tjsonGetStringValue(info, "nodeFqdn", pNode->nodeFqdn);
|
||||
code = tjsonGetStringValue(info, "nodeFqdn", pNode->nodeFqdn);
|
||||
tjsonGetNumberValue(info, "nodeId", pNode->nodeId, code);
|
||||
if (code) return code;
|
||||
tjsonGetNumberValue(info, "clusterId", pNode->clusterId, code);
|
||||
|
|
|
@ -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';
|
||||
|
@ -272,7 +272,7 @@ static int32_t vnodePrepareCommit(SVnode *pVnode, SCommitInfo *pInfo) {
|
|||
int64_t lastCommitted = pInfo->info.state.committed;
|
||||
|
||||
// wait last commit task
|
||||
(void)vnodeAWait(&pVnode->commitTask);
|
||||
vnodeAWait(&pVnode->commitTask);
|
||||
|
||||
code = syncNodeGetConfig(pVnode->sync, &pVnode->config.syncCfg);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
@ -287,13 +287,14 @@ static int32_t vnodePrepareCommit(SVnode *pVnode, SCommitInfo *pInfo) {
|
|||
pInfo->txn = metaGetTxn(pVnode->pMeta);
|
||||
|
||||
// save info
|
||||
(void)vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, dir, TSDB_FILENAME_LEN);
|
||||
vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, dir, TSDB_FILENAME_LEN);
|
||||
|
||||
vDebug("vgId:%d, save config while prepare commit", TD_VID(pVnode));
|
||||
code = vnodeSaveInfo(dir, &pInfo->info);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
(void)tsdbPreCommit(pVnode->pTsdb);
|
||||
code = tsdbPreCommit(pVnode->pTsdb);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
code = metaPrepareAsyncCommit(pVnode->pMeta);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
@ -395,10 +396,15 @@ _exit:
|
|||
return code;
|
||||
}
|
||||
|
||||
int vnodeSyncCommit(SVnode *pVnode) {
|
||||
(void)vnodeAsyncCommit(pVnode);
|
||||
(void)vnodeAWait(&pVnode->commitTask);
|
||||
return 0;
|
||||
int32_t vnodeSyncCommit(SVnode *pVnode) {
|
||||
int32_t lino;
|
||||
int32_t code = vnodeAsyncCommit(pVnode);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
vnodeAWait(&pVnode->commitTask);
|
||||
|
||||
_exit:
|
||||
vError("vgId:%d, %s failed at line %d since %s", TD_VID(pVnode), __func__, lino, tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
||||
static int vnodeCommitImpl(SCommitInfo *pInfo) {
|
||||
|
@ -417,9 +423,10 @@ static int vnodeCommitImpl(SCommitInfo *pInfo) {
|
|||
return code;
|
||||
}
|
||||
|
||||
(void)vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, dir, TSDB_FILENAME_LEN);
|
||||
vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, dir, TSDB_FILENAME_LEN);
|
||||
|
||||
(void)syncBeginSnapshot(pVnode->sync, pInfo->info.state.committed);
|
||||
code = syncBeginSnapshot(pVnode->sync, pInfo->info.state.committed);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
code = tsdbCommitBegin(pVnode->pTsdb, pInfo);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
@ -456,7 +463,8 @@ static int vnodeCommitImpl(SCommitInfo *pInfo) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
(void)syncEndSnapshot(pVnode->sync);
|
||||
code = syncEndSnapshot(pVnode->sync);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
_exit:
|
||||
if (code) {
|
||||
|
@ -471,7 +479,7 @@ bool vnodeShouldRollback(SVnode *pVnode) {
|
|||
char tFName[TSDB_FILENAME_LEN] = {0};
|
||||
int32_t offset = 0;
|
||||
|
||||
(void)vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, tFName, TSDB_FILENAME_LEN);
|
||||
vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, tFName, TSDB_FILENAME_LEN);
|
||||
offset = strlen(tFName);
|
||||
snprintf(tFName + offset, TSDB_FILENAME_LEN - offset - 1, "%s%s", TD_DIRSEP, VND_INFO_FNAME_TMP);
|
||||
|
||||
|
@ -482,7 +490,7 @@ void vnodeRollback(SVnode *pVnode) {
|
|||
char tFName[TSDB_FILENAME_LEN] = {0};
|
||||
int32_t offset = 0;
|
||||
|
||||
(void)vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, tFName, TSDB_FILENAME_LEN);
|
||||
vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, tFName, TSDB_FILENAME_LEN);
|
||||
offset = strlen(tFName);
|
||||
snprintf(tFName + offset, TSDB_FILENAME_LEN - offset - 1, "%s%s", TD_DIRSEP, VND_INFO_FNAME_TMP);
|
||||
|
||||
|
|
|
@ -71,9 +71,9 @@ int32_t vHashInit(SVHashTable** ht, uint32_t (*hash)(const void*), int32_t (*com
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32_t vHashDestroy(SVHashTable** ht) {
|
||||
void vHashDestroy(SVHashTable** ht) {
|
||||
if (ht == NULL) {
|
||||
return TSDB_CODE_INVALID_PARA;
|
||||
return;
|
||||
}
|
||||
|
||||
if (*ht) {
|
||||
|
@ -81,7 +81,6 @@ int32_t vHashDestroy(SVHashTable** ht) {
|
|||
taosMemoryFree(*ht);
|
||||
(*ht) = NULL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t vHashPut(SVHashTable* ht, void* obj) {
|
||||
|
|
|
@ -34,7 +34,7 @@ int vnodeInit(int nthreads, StopDnodeFp stopDnodeFp) {
|
|||
|
||||
void vnodeCleanup() {
|
||||
if (atomic_val_compare_exchange_32(&VINIT, 1, 0) == 0) return;
|
||||
(void)vnodeAsyncClose();
|
||||
vnodeAsyncClose();
|
||||
walCleanUp();
|
||||
smaCleanUp();
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#include "tsdb.h"
|
||||
#include "vnd.h"
|
||||
|
||||
int32_t vnodeGetPrimaryDir(const char *relPath, int32_t diskPrimary, STfs *pTfs, char *buf, size_t bufLen) {
|
||||
void vnodeGetPrimaryDir(const char *relPath, int32_t diskPrimary, STfs *pTfs, char *buf, size_t bufLen) {
|
||||
if (pTfs) {
|
||||
SDiskID diskId = {0};
|
||||
diskId.id = diskPrimary;
|
||||
|
@ -27,7 +27,6 @@ int32_t vnodeGetPrimaryDir(const char *relPath, int32_t diskPrimary, STfs *pTfs,
|
|||
snprintf(buf, bufLen - 1, "%s", relPath);
|
||||
}
|
||||
buf[bufLen - 1] = '\0';
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t vnodeMkDir(STfs *pTfs, const char *path) {
|
||||
|
@ -54,7 +53,7 @@ int32_t vnodeCreate(const char *path, SVnodeCfg *pCfg, int32_t diskPrimary, STfs
|
|||
vError("vgId:%d, failed to prepare vnode dir since %s, path: %s", pCfg->vgId, strerror(errno), path);
|
||||
return TAOS_SYSTEM_ERROR(errno);
|
||||
}
|
||||
(void)vnodeGetPrimaryDir(path, diskPrimary, pTfs, dir, TSDB_FILENAME_LEN);
|
||||
vnodeGetPrimaryDir(path, diskPrimary, pTfs, dir, TSDB_FILENAME_LEN);
|
||||
|
||||
if (pCfg) {
|
||||
info.config = *pCfg;
|
||||
|
@ -89,7 +88,7 @@ int32_t vnodeAlterReplica(const char *path, SAlterVnodeReplicaReq *pReq, int32_t
|
|||
char dir[TSDB_FILENAME_LEN] = {0};
|
||||
int32_t ret = 0;
|
||||
|
||||
(void)vnodeGetPrimaryDir(path, diskPrimary, pTfs, dir, TSDB_FILENAME_LEN);
|
||||
vnodeGetPrimaryDir(path, diskPrimary, pTfs, dir, TSDB_FILENAME_LEN);
|
||||
|
||||
ret = vnodeLoadInfo(dir, &info);
|
||||
if (ret < 0) {
|
||||
|
@ -222,7 +221,7 @@ int32_t vnodeAlterHashRange(const char *srcPath, const char *dstPath, SAlterVnod
|
|||
char dir[TSDB_FILENAME_LEN] = {0};
|
||||
int32_t ret = 0;
|
||||
|
||||
(void)vnodeGetPrimaryDir(srcPath, diskPrimary, pTfs, dir, TSDB_FILENAME_LEN);
|
||||
vnodeGetPrimaryDir(srcPath, diskPrimary, pTfs, dir, TSDB_FILENAME_LEN);
|
||||
|
||||
ret = vnodeLoadInfo(dir, &info);
|
||||
if (ret < 0) {
|
||||
|
@ -284,7 +283,7 @@ int32_t vnodeRestoreVgroupId(const char *srcPath, const char *dstPath, int32_t s
|
|||
char dir[TSDB_FILENAME_LEN] = {0};
|
||||
int32_t code = 0;
|
||||
|
||||
(void)vnodeGetPrimaryDir(dstPath, diskPrimary, pTfs, dir, TSDB_FILENAME_LEN);
|
||||
vnodeGetPrimaryDir(dstPath, diskPrimary, pTfs, dir, TSDB_FILENAME_LEN);
|
||||
if (vnodeLoadInfo(dir, &info) == 0) {
|
||||
if (info.config.vgId != dstVgId) {
|
||||
vError("vgId:%d, unexpected vnode config.vgId:%d", dstVgId, info.config.vgId);
|
||||
|
@ -293,7 +292,7 @@ int32_t vnodeRestoreVgroupId(const char *srcPath, const char *dstPath, int32_t s
|
|||
return dstVgId;
|
||||
}
|
||||
|
||||
(void)vnodeGetPrimaryDir(srcPath, diskPrimary, pTfs, dir, TSDB_FILENAME_LEN);
|
||||
vnodeGetPrimaryDir(srcPath, diskPrimary, pTfs, dir, TSDB_FILENAME_LEN);
|
||||
if ((code = vnodeLoadInfo(dir, &info)) < 0) {
|
||||
vError("vgId:%d, failed to read vnode config from %s since %s", srcVgId, srcPath, tstrerror(terrno));
|
||||
return code;
|
||||
|
@ -352,7 +351,7 @@ SVnode *vnodeOpen(const char *path, int32_t diskPrimary, STfs *pTfs, SMsgCb msgC
|
|||
vError("failed to open vnode from %s since %s. diskPrimary:%d", path, terrstr(), diskPrimary);
|
||||
return NULL;
|
||||
}
|
||||
(void)vnodeGetPrimaryDir(path, diskPrimary, pTfs, dir, TSDB_FILENAME_LEN);
|
||||
vnodeGetPrimaryDir(path, diskPrimary, pTfs, dir, TSDB_FILENAME_LEN);
|
||||
|
||||
info.config = vnodeCfgDefault;
|
||||
|
||||
|
@ -503,7 +502,7 @@ _err:
|
|||
if (pVnode->pTsdb) (void)tsdbClose(&pVnode->pTsdb);
|
||||
if (pVnode->pSma) (void)smaClose(pVnode->pSma);
|
||||
if (pVnode->pMeta) (void)metaClose(&pVnode->pMeta);
|
||||
if (pVnode->freeList) (void)vnodeCloseBufPool(pVnode);
|
||||
if (pVnode->freeList) vnodeCloseBufPool(pVnode);
|
||||
|
||||
taosMemoryFree(pVnode);
|
||||
return NULL;
|
||||
|
@ -518,7 +517,7 @@ void vnodePostClose(SVnode *pVnode) { vnodeSyncPostClose(pVnode); }
|
|||
|
||||
void vnodeClose(SVnode *pVnode) {
|
||||
if (pVnode) {
|
||||
(void)vnodeAWait(&pVnode->commitTask);
|
||||
vnodeAWait(&pVnode->commitTask);
|
||||
(void)vnodeAChannelDestroy(&pVnode->commitChannel, true);
|
||||
vnodeSyncClose(pVnode);
|
||||
vnodeQueryClose(pVnode);
|
||||
|
@ -527,7 +526,7 @@ void vnodeClose(SVnode *pVnode) {
|
|||
if (pVnode->pTsdb) tsdbClose(&pVnode->pTsdb);
|
||||
(void)smaClose(pVnode->pSma);
|
||||
if (pVnode->pMeta) metaClose(&pVnode->pMeta);
|
||||
(void)vnodeCloseBufPool(pVnode);
|
||||
vnodeCloseBufPool(pVnode);
|
||||
|
||||
// destroy handle
|
||||
(void)tsem_destroy(&pVnode->syncSem);
|
||||
|
|
|
@ -210,7 +210,7 @@ static void vnodeSnapReaderDestroyTsdbRanges(SVSnapReader *pReader) {
|
|||
for (int32_t j = 0; j < TSDB_RETENTION_MAX; ++j) {
|
||||
TFileSetRangeArray **ppRanges = vnodeSnapReaderGetTsdbRanges(pReader, tsdbTyps[j]);
|
||||
if (ppRanges == NULL) continue;
|
||||
(void)tsdbTFileSetRangeArrayDestroy(ppRanges);
|
||||
tsdbTFileSetRangeArrayDestroy(ppRanges);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -261,20 +261,21 @@ int32_t vnodeSnapRead(SVSnapReader *pReader, uint8_t **ppData, uint32_t *nData)
|
|||
char fName[TSDB_FILENAME_LEN];
|
||||
int32_t offset = 0;
|
||||
|
||||
(void)vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, fName, TSDB_FILENAME_LEN);
|
||||
vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, fName, TSDB_FILENAME_LEN);
|
||||
offset = strlen(fName);
|
||||
snprintf(fName + offset, TSDB_FILENAME_LEN - offset - 1, "%s%s", TD_DIRSEP, VND_INFO_FNAME);
|
||||
|
||||
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);
|
||||
|
@ -586,7 +587,7 @@ _exit:
|
|||
}
|
||||
|
||||
extern int32_t tsdbDisableAndCancelAllBgTask(STsdb *pTsdb);
|
||||
extern int32_t tsdbEnableBgTask(STsdb *pTsdb);
|
||||
extern void tsdbEnableBgTask(STsdb *pTsdb);
|
||||
|
||||
static int32_t vnodeCancelAndDisableAllBgTask(SVnode *pVnode) {
|
||||
(void)tsdbDisableAndCancelAllBgTask(pVnode->pTsdb);
|
||||
|
@ -596,7 +597,7 @@ static int32_t vnodeCancelAndDisableAllBgTask(SVnode *pVnode) {
|
|||
}
|
||||
|
||||
static int32_t vnodeEnableBgTask(SVnode *pVnode) {
|
||||
(void)tsdbEnableBgTask(pVnode->pTsdb);
|
||||
tsdbEnableBgTask(pVnode->pTsdb);
|
||||
(void)vnodeAChannelInit(1, &pVnode->commitChannel);
|
||||
return 0;
|
||||
}
|
||||
|
@ -648,7 +649,7 @@ static void vnodeSnapWriterDestroyTsdbRanges(SVSnapWriter *pWriter) {
|
|||
for (int32_t j = 0; j < TSDB_RETENTION_MAX; ++j) {
|
||||
TFileSetRangeArray **ppRanges = vnodeSnapWriterGetTsdbRanges(pWriter, tsdbTyps[j]);
|
||||
if (ppRanges == NULL) continue;
|
||||
(void)tsdbTFileSetRangeArrayDestroy(ppRanges);
|
||||
tsdbTFileSetRangeArrayDestroy(ppRanges);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -682,7 +683,7 @@ int32_t vnodeSnapWriterClose(SVSnapWriter *pWriter, int8_t rollback, SSnapshot *
|
|||
.applyTerm = pWriter->info.state.commitTerm};
|
||||
pVnode->statis = pWriter->info.statis;
|
||||
char dir[TSDB_FILENAME_LEN] = {0};
|
||||
(void)vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, dir, TSDB_FILENAME_LEN);
|
||||
vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, dir, TSDB_FILENAME_LEN);
|
||||
|
||||
code = vnodeCommitInfo(dir);
|
||||
if (code) goto _exit;
|
||||
|
@ -773,7 +774,7 @@ static int32_t vnodeSnapWriteInfo(SVSnapWriter *pWriter, uint8_t *pData, uint32_
|
|||
|
||||
// modify info as needed
|
||||
char dir[TSDB_FILENAME_LEN] = {0};
|
||||
(void)vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, dir, TSDB_FILENAME_LEN);
|
||||
vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, dir, TSDB_FILENAME_LEN);
|
||||
|
||||
SVnodeStats vndStats = pWriter->info.config.vndStats;
|
||||
pWriter->info.config = pVnode->config;
|
||||
|
|
|
@ -754,8 +754,7 @@ int32_t vnodePreprocessQueryMsg(SVnode *pVnode, SRpcMsg *pMsg) {
|
|||
|
||||
int32_t vnodeProcessQueryMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo) {
|
||||
vTrace("message in vnode query queue is processing");
|
||||
if ((pMsg->msgType == TDMT_SCH_QUERY || pMsg->msgType == TDMT_VND_TMQ_CONSUME) &&
|
||||
!syncIsReadyForRead(pVnode->sync)) {
|
||||
if ((pMsg->msgType == TDMT_SCH_QUERY || pMsg->msgType == TDMT_VND_TMQ_CONSUME) && !syncIsReadyForRead(pVnode->sync)) {
|
||||
vnodeRedirectRpcMsg(pVnode, pMsg, terrno);
|
||||
return 0;
|
||||
}
|
||||
|
@ -1477,7 +1476,8 @@ static int32_t vnodeDebugPrintSingleSubmitMsg(SMeta *pMeta, SSubmitBlk *pBlock,
|
|||
tInitSubmitBlkIter(msgIter, pBlock, &blkIter);
|
||||
if (blkIter.row == NULL) return 0;
|
||||
|
||||
int32_t code = metaGetTbTSchemaNotNull(pMeta, msgIter->suid, TD_ROW_SVER(blkIter.row), 1, &pSchema); // TODO: use the real schema
|
||||
int32_t code = metaGetTbTSchemaNotNull(pMeta, msgIter->suid, TD_ROW_SVER(blkIter.row), 1,
|
||||
&pSchema); // TODO: use the real schema
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
printf("%s:%d no valid schema\n", tags, __LINE__);
|
||||
return code;
|
||||
|
@ -1511,7 +1511,7 @@ typedef struct SSubmitReqConvertCxt {
|
|||
static int32_t vnodeResetTableCxt(SMeta *pMeta, SSubmitReqConvertCxt *pCxt) {
|
||||
taosMemoryFreeClear(pCxt->pTbSchema);
|
||||
int32_t code = metaGetTbTSchemaNotNull(pMeta, pCxt->msgIter.suid > 0 ? pCxt->msgIter.suid : pCxt->msgIter.uid,
|
||||
pCxt->msgIter.sversion, 1, &pCxt->pTbSchema);
|
||||
pCxt->msgIter.sversion, 1, &pCxt->pTbSchema);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
}
|
||||
|
@ -2041,7 +2041,7 @@ _exit:
|
|||
}
|
||||
|
||||
extern int32_t tsdbDisableAndCancelAllBgTask(STsdb *pTsdb);
|
||||
extern int32_t tsdbEnableBgTask(STsdb *pTsdb);
|
||||
extern void tsdbEnableBgTask(STsdb *pTsdb);
|
||||
|
||||
static int32_t vnodeProcessAlterConfigReq(SVnode *pVnode, int64_t ver, void *pReq, int32_t len, SRpcMsg *pRsp) {
|
||||
bool walChanged = false;
|
||||
|
@ -2143,10 +2143,10 @@ static int32_t vnodeProcessAlterConfigReq(SVnode *pVnode, int64_t ver, void *pRe
|
|||
if (req.sttTrigger > 1 && pVnode->config.sttTrigger > 1) {
|
||||
pVnode->config.sttTrigger = req.sttTrigger;
|
||||
} else {
|
||||
(void)vnodeAWait(&pVnode->commitTask);
|
||||
vnodeAWait(&pVnode->commitTask);
|
||||
(void)tsdbDisableAndCancelAllBgTask(pVnode->pTsdb);
|
||||
pVnode->config.sttTrigger = req.sttTrigger;
|
||||
(void)tsdbEnableBgTask(pVnode->pTsdb);
|
||||
tsdbEnableBgTask(pVnode->pTsdb);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2166,7 +2166,7 @@ static int32_t vnodeProcessAlterConfigReq(SVnode *pVnode, int64_t ver, void *pRe
|
|||
}
|
||||
|
||||
if (tsdbChanged) {
|
||||
(void)tsdbSetKeepCfg(pVnode->pTsdb, &pVnode->config.tsdbCfg);
|
||||
tsdbSetKeepCfg(pVnode->pTsdb, &pVnode->config.tsdbCfg);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -587,7 +587,10 @@ static void vnodeRestoreFinish(const SSyncFSM *pFsm, const SyncIndex commitIdx)
|
|||
streamMetaWUnLock(pMeta);
|
||||
|
||||
tqInfo("vgId:%d stream task already loaded, start them", vgId);
|
||||
(void)streamTaskSchedTask(&pVnode->msgCb, TD_VID(pVnode), 0, 0, STREAM_EXEC_T_START_ALL_TASKS);
|
||||
int32_t code = streamTaskSchedTask(&pVnode->msgCb, TD_VID(pVnode), 0, 0, STREAM_EXEC_T_START_ALL_TASKS);
|
||||
if (code != 0) {
|
||||
tqError("vgId:%d failed to sched stream task, code:%s", vgId, tstrerror(code));
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -661,10 +661,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]);
|
||||
|
@ -675,6 +671,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);
|
||||
}
|
||||
|
||||
|
@ -870,12 +872,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;
|
||||
}
|
||||
|
||||
|
|
|
@ -1241,6 +1241,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 +1273,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 +1284,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 +1297,6 @@ static int32_t groupSeqTableScan(SOperatorInfo* pOperator, SSDataBlock** pResBlo
|
|||
}
|
||||
}
|
||||
|
||||
pResult = NULL;
|
||||
code = doGroupedTableScan(pOperator, &pResult);
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
|
||||
|
@ -1305,7 +1321,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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -6036,9 +6036,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);
|
||||
|
|
|
@ -43,7 +43,7 @@ int32_t doMakePointFunc(double x, double y, unsigned char **output) {
|
|||
|
||||
*output = taosMemoryCalloc(1, size + VARSTR_HEADER_SIZE);
|
||||
if (*output == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ int32_t doGeomFromTextFunc(const char *input, unsigned char **output) {
|
|||
// make a zero ending string
|
||||
inputGeom = taosMemoryCalloc(1, varDataLen(input) + 1);
|
||||
if (inputGeom == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto _exit;
|
||||
}
|
||||
(void)memcpy(inputGeom, varDataVal(input), varDataLen(input));
|
||||
|
@ -83,7 +83,7 @@ int32_t doGeomFromTextFunc(const char *input, unsigned char **output) {
|
|||
|
||||
*output = taosMemoryCalloc(1, size + VARSTR_HEADER_SIZE);
|
||||
if (*output == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
|
@ -114,7 +114,7 @@ int32_t doAsTextFunc(unsigned char *input, char **output) {
|
|||
size_t size = strlen(outputWKT);
|
||||
*output = taosMemoryCalloc(1, size + VARSTR_HEADER_SIZE);
|
||||
if (*output == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ static int32_t initWktRegex(pcre2_code **ppRegex, pcre2_match_data **ppMatchData
|
|||
int32_t code = 0;
|
||||
char *wktPatternWithSpace = taosMemoryCalloc(4, 1024);
|
||||
if (NULL == wktPatternWithSpace) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
(void)sprintf(
|
||||
|
|
|
@ -112,7 +112,7 @@ int32_t indexOpen(SIndexOpts* opts, const char* path, SIndex** index) {
|
|||
int code = TSDB_CODE_SUCCESS;
|
||||
SIndex* idx = taosMemoryCalloc(1, sizeof(SIndex));
|
||||
if (idx == NULL) {
|
||||
TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, END);
|
||||
TAOS_CHECK_GOTO(terrno, NULL, END);
|
||||
}
|
||||
|
||||
idx->lru = taosLRUCacheInit(opts->cacheSize, -1, .5);
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue