From 124b8b6645c5150344bc968e8c6de3cef26a882f Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Fri, 22 Apr 2022 17:44:53 +0800 Subject: [PATCH 01/11] enh(rpc): fix hb problem --- include/libs/transport/trpc.h | 1 + source/dnode/mgmt/implement/src/dmExec.c | 2 +- source/dnode/mgmt/implement/src/dmTransport.c | 11 +- source/dnode/mgmt/implement/src/dmWorker.c | 4 +- source/dnode/mgmt/interface/src/dmInt.c | 2 +- source/libs/qworker/inc/qworkerInt.h | 249 +++++++++++------- source/libs/scheduler/src/scheduler.c | 26 +- source/libs/transport/src/transSrv.c | 173 +++++++++--- 8 files changed, 310 insertions(+), 158 deletions(-) diff --git a/include/libs/transport/trpc.h b/include/libs/transport/trpc.h index ab26cfc155..2e50a51d4d 100644 --- a/include/libs/transport/trpc.h +++ b/include/libs/transport/trpc.h @@ -43,6 +43,7 @@ typedef struct SRpcMsg { int32_t code; void * handle; // rpc handle returned to app void * ahandle; // app handle set by client + int64_t refId; // int noResp; // has response or not(default 0, 0: resp, 1: no resp); int persistHandle; // persist handle or not diff --git a/source/dnode/mgmt/implement/src/dmExec.c b/source/dnode/mgmt/implement/src/dmExec.c index c0b85ed705..e14996120b 100644 --- a/source/dnode/mgmt/implement/src/dmExec.c +++ b/source/dnode/mgmt/implement/src/dmExec.c @@ -275,7 +275,7 @@ static void dmCloseNodes(SDnode *pDnode) { static void dmProcessProcHandle(void *handle) { dWarn("handle:%p, the child process dies and send an offline rsp", handle); - SRpcMsg rpcMsg = {.handle = handle, .code = TSDB_CODE_NODE_OFFLINE}; + SRpcMsg rpcMsg = {.handle = handle, .code = TSDB_CODE_NODE_OFFLINE, .refId = -1}; rpcSendResponse(&rpcMsg); } diff --git a/source/dnode/mgmt/implement/src/dmTransport.c b/source/dnode/mgmt/implement/src/dmTransport.c index a574d802f9..eebbfea224 100644 --- a/source/dnode/mgmt/implement/src/dmTransport.c +++ b/source/dnode/mgmt/implement/src/dmTransport.c @@ -134,7 +134,8 @@ static void dmProcessMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet) { if (pDnode->status != DND_STAT_RUNNING) { dError("msg:%s ignored since dnode not running, handle:%p app:%p", TMSG_INFO(msgType), pMsg->handle, pMsg->ahandle); if (isReq) { - SRpcMsg rspMsg = {.handle = pMsg->handle, .code = TSDB_CODE_APP_NOT_READY, .ahandle = pMsg->ahandle}; + SRpcMsg rspMsg = { + .handle = pMsg->handle, .code = TSDB_CODE_APP_NOT_READY, .ahandle = pMsg->ahandle, .refId = pMsg->refId}; rpcSendResponse(&rspMsg); } rpcFreeCont(pMsg->pCont); @@ -143,7 +144,8 @@ static void dmProcessMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet) { if (isReq && pMsg->pCont == NULL) { dError("req:%s not processed since its empty, handle:%p app:%p", TMSG_INFO(msgType), pMsg->handle, pMsg->ahandle); - SRpcMsg rspMsg = {.handle = pMsg->handle, .code = TSDB_CODE_INVALID_MSG_LEN, .ahandle = pMsg->ahandle}; + SRpcMsg rspMsg = { + .handle = pMsg->handle, .code = TSDB_CODE_INVALID_MSG_LEN, .ahandle = pMsg->ahandle, .refId = pMsg->refId}; rpcSendResponse(&rspMsg); return; } @@ -151,7 +153,8 @@ static void dmProcessMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet) { if (pWrapper == NULL) { dError("msg:%s not processed since no handle, handle:%p app:%p", TMSG_INFO(msgType), pMsg->handle, pMsg->ahandle); if (isReq) { - SRpcMsg rspMsg = {.handle = pMsg->handle, .code = TSDB_CODE_MSG_NOT_PROCESSED, .ahandle = pMsg->ahandle}; + SRpcMsg rspMsg = { + .handle = pMsg->handle, .code = TSDB_CODE_MSG_NOT_PROCESSED, .ahandle = pMsg->ahandle, .refId = pMsg->refId}; rpcSendResponse(&rspMsg); } rpcFreeCont(pMsg->pCont); @@ -317,7 +320,7 @@ static void dmConsumeChildQueue(SMgmtWrapper *pWrapper, SNodeMsg *pMsg, int16_t if (code != 0) { dError("msg:%p, failed to process since code:0x%04x:%s", pMsg, code & 0XFFFF, tstrerror(code)); if (pRpc->msgType & 1U) { - SRpcMsg rsp = {.handle = pRpc->handle, .ahandle = pRpc->ahandle, .code = terrno}; + SRpcMsg rsp = {.handle = pRpc->handle, .ahandle = pRpc->ahandle, .code = terrno, .refId = pRpc->refId}; dmSendRsp(pWrapper, &rsp); } diff --git a/source/dnode/mgmt/implement/src/dmWorker.c b/source/dnode/mgmt/implement/src/dmWorker.c index 505efeb8c6..b19c2ab36b 100644 --- a/source/dnode/mgmt/implement/src/dmWorker.c +++ b/source/dnode/mgmt/implement/src/dmWorker.c @@ -105,7 +105,7 @@ void dmStopMonitorThread(SDnode *pDnode) { } static void dmProcessMgmtQueue(SQueueInfo *pInfo, SNodeMsg *pMsg) { - SDnode *pDnode = pInfo->ahandle; + SDnode * pDnode = pInfo->ahandle; SRpcMsg *pRpc = &pMsg->rpcMsg; int32_t code = -1; dTrace("msg:%p, will be processed in dnode-mgmt queue", pMsg); @@ -150,7 +150,7 @@ static void dmProcessMgmtQueue(SQueueInfo *pInfo, SNodeMsg *pMsg) { if (pRpc->msgType & 1u) { if (code != 0) code = terrno; - SRpcMsg rsp = {.handle = pRpc->handle, .ahandle = pRpc->ahandle, .code = code}; + SRpcMsg rsp = {.handle = pRpc->handle, .ahandle = pRpc->ahandle, .code = code, .refId = pRpc->refId}; rpcSendResponse(&rsp); } diff --git a/source/dnode/mgmt/interface/src/dmInt.c b/source/dnode/mgmt/interface/src/dmInt.c index 00abbd0199..bab84effe5 100644 --- a/source/dnode/mgmt/interface/src/dmInt.c +++ b/source/dnode/mgmt/interface/src/dmInt.c @@ -177,7 +177,7 @@ void dmProcessServerStatusReq(SDnode *pDnode, SRpcMsg *pReq) { SServerStatusRsp statusRsp = {0}; dmGetServerStatus(pDnode, &statusRsp); - SRpcMsg rspMsg = {.handle = pReq->handle, .ahandle = pReq->ahandle}; + SRpcMsg rspMsg = {.handle = pReq->handle, .ahandle = pReq->ahandle, .refId = pReq->refId}; int32_t rspLen = tSerializeSServerStatusRsp(NULL, 0, &statusRsp); if (rspLen < 0) { rspMsg.code = TSDB_CODE_OUT_OF_MEMORY; diff --git a/source/libs/qworker/inc/qworkerInt.h b/source/libs/qworker/inc/qworkerInt.h index d62f9f04b8..c4736f75f1 100644 --- a/source/libs/qworker/inc/qworkerInt.h +++ b/source/libs/qworker/inc/qworkerInt.h @@ -25,10 +25,10 @@ extern "C" { #include "ttimer.h" #define QW_DEFAULT_SCHEDULER_NUMBER 10000 -#define QW_DEFAULT_TASK_NUMBER 10000 -#define QW_DEFAULT_SCH_TASK_NUMBER 10000 -#define QW_DEFAULT_SHORT_RUN_TIMES 2 -#define QW_DEFAULT_HEARTBEAT_MSEC 3000 +#define QW_DEFAULT_TASK_NUMBER 10000 +#define QW_DEFAULT_SCH_TASK_NUMBER 10000 +#define QW_DEFAULT_SHORT_RUN_TIMES 2 +#define QW_DEFAULT_HEARTBEAT_MSEC 3000 enum { QW_PHASE_PRE_QUERY = 1, @@ -60,7 +60,6 @@ enum { QW_WRITE, }; - enum { QW_NOT_EXIST_RET_ERR = 1, QW_NOT_EXIST_ADD, @@ -73,65 +72,65 @@ typedef struct SQWDebug { } SQWDebug; typedef struct SQWConnInfo { - void *handle; - void *ahandle; + void * handle; + void * ahandle; + int64_t refId; } SQWConnInfo; typedef struct SQWMsg { - void *node; - int32_t code; - char *msg; - int32_t msgLen; - SQWConnInfo connInfo; + void * node; + int32_t code; + char * msg; + int32_t msgLen; + SQWConnInfo connInfo; } SQWMsg; typedef struct SQWHbInfo { - SSchedulerHbRsp rsp; - SQWConnInfo connInfo; + SSchedulerHbRsp rsp; + SQWConnInfo connInfo; } SQWHbInfo; typedef struct SQWPhaseInput { - int32_t code; + int32_t code; } SQWPhaseInput; typedef struct SQWPhaseOutput { } SQWPhaseOutput; - -typedef struct SQWTaskStatus { - int64_t refId; // job's refId - int32_t code; - int8_t status; +typedef struct SQWTaskStatus { + int64_t refId; // job's refId + int32_t code; + int8_t status; } SQWTaskStatus; typedef struct SQWTaskCtx { - SRWLatch lock; - int8_t phase; - int8_t taskType; - int8_t explain; - - bool queryFetched; - bool queryEnd; - bool queryContinue; - bool queryInQueue; - int32_t rspCode; + SRWLatch lock; + int8_t phase; + int8_t taskType; + int8_t explain; - SQWConnInfo ctrlConnInfo; - SQWConnInfo dataConnInfo; + bool queryFetched; + bool queryEnd; + bool queryContinue; + bool queryInQueue; + int32_t rspCode; - int8_t events[QW_EVENT_MAX]; - - qTaskInfo_t taskHandle; - DataSinkHandle sinkHandle; + SQWConnInfo ctrlConnInfo; + SQWConnInfo dataConnInfo; + + int8_t events[QW_EVENT_MAX]; + + qTaskInfo_t taskHandle; + DataSinkHandle sinkHandle; } SQWTaskCtx; typedef struct SQWSchStatus { - int32_t lastAccessTs; // timestamp in second + int32_t lastAccessTs; // timestamp in second SRWLatch hbConnLock; SQWConnInfo hbConnInfo; - SQueryNodeEpId hbEpId; + SQueryNodeEpId hbEpId; SRWLatch tasksLock; - SHashObj *tasksHash; // key:queryId+taskId, value: SQWTaskStatus + SHashObj * tasksHash; // key:queryId+taskId, value: SQWTaskStatus } SQWSchStatus; // Qnode/Vnode level task management @@ -139,100 +138,146 @@ typedef struct SQWorkerMgmt { SQWorkerCfg cfg; int8_t nodeType; int32_t nodeId; - void *timer; + void * timer; tmr_h hbTimer; SRWLatch schLock; // SRWLatch ctxLock; - SHashObj *schHash; // key: schedulerId, value: SQWSchStatus - SHashObj *ctxHash; // key: queryId+taskId, value: SQWTaskCtx - SMsgCb msgCb; + SHashObj *schHash; // key: schedulerId, value: SQWSchStatus + SHashObj *ctxHash; // key: queryId+taskId, value: SQWTaskCtx + SMsgCb msgCb; } SQWorkerMgmt; #define QW_FPARAMS_DEF SQWorkerMgmt *mgmt, uint64_t sId, uint64_t qId, uint64_t tId, int64_t rId -#define QW_IDS() sId, qId, tId, rId -#define QW_FPARAMS() mgmt, QW_IDS() +#define QW_IDS() sId, qId, tId, rId +#define QW_FPARAMS() mgmt, QW_IDS() #define QW_GET_EVENT_VALUE(ctx, event) atomic_load_8(&(ctx)->events[event]) -#define QW_IS_EVENT_RECEIVED(ctx, event) (atomic_load_8(&(ctx)->events[event]) == QW_EVENT_RECEIVED) -#define QW_IS_EVENT_PROCESSED(ctx, event) (atomic_load_8(&(ctx)->events[event]) == QW_EVENT_PROCESSED) -#define QW_SET_EVENT_RECEIVED(ctx, event) atomic_store_8(&(ctx)->events[event], QW_EVENT_RECEIVED) +#define QW_IS_EVENT_RECEIVED(ctx, event) (atomic_load_8(&(ctx)->events[event]) == QW_EVENT_RECEIVED) +#define QW_IS_EVENT_PROCESSED(ctx, event) (atomic_load_8(&(ctx)->events[event]) == QW_EVENT_PROCESSED) +#define QW_SET_EVENT_RECEIVED(ctx, event) atomic_store_8(&(ctx)->events[event], QW_EVENT_RECEIVED) #define QW_SET_EVENT_PROCESSED(ctx, event) atomic_store_8(&(ctx)->events[event], QW_EVENT_PROCESSED) #define QW_GET_PHASE(ctx) atomic_load_8(&(ctx)->phase) -#define QW_SET_RSP_CODE(ctx, code) atomic_store_32(&(ctx)->rspCode, code) +#define QW_SET_RSP_CODE(ctx, code) atomic_store_32(&(ctx)->rspCode, code) #define QW_UPDATE_RSP_CODE(ctx, code) atomic_val_compare_exchange_32(&(ctx)->rspCode, 0, code) #define QW_IS_QUERY_RUNNING(ctx) (QW_GET_PHASE(ctx) == QW_PHASE_PRE_QUERY || QW_GET_PHASE(ctx) == QW_PHASE_PRE_CQUERY) -#define QW_TASK_NOT_EXIST(code) (TSDB_CODE_QRY_SCH_NOT_EXIST == (code) || TSDB_CODE_QRY_TASK_NOT_EXIST == (code)) +#define QW_TASK_NOT_EXIST(code) (TSDB_CODE_QRY_SCH_NOT_EXIST == (code) || TSDB_CODE_QRY_TASK_NOT_EXIST == (code)) #define QW_TASK_ALREADY_EXIST(code) (TSDB_CODE_QRY_TASK_ALREADY_EXIST == (code)) -#define QW_TASK_READY(status) (status == JOB_TASK_STATUS_SUCCEED || status == JOB_TASK_STATUS_FAILED || status == JOB_TASK_STATUS_CANCELLED || status == JOB_TASK_STATUS_PARTIAL_SUCCEED) -#define QW_SET_QTID(id, qId, tId) do { *(uint64_t *)(id) = (qId); *(uint64_t *)((char *)(id) + sizeof(qId)) = (tId); } while (0) -#define QW_GET_QTID(id, qId, tId) do { (qId) = *(uint64_t *)(id); (tId) = *(uint64_t *)((char *)(id) + sizeof(qId)); } while (0) +#define QW_TASK_READY(status) \ + (status == JOB_TASK_STATUS_SUCCEED || status == JOB_TASK_STATUS_FAILED || status == JOB_TASK_STATUS_CANCELLED || \ + status == JOB_TASK_STATUS_PARTIAL_SUCCEED) +#define QW_SET_QTID(id, qId, tId) \ + do { \ + *(uint64_t *)(id) = (qId); \ + *(uint64_t *)((char *)(id) + sizeof(qId)) = (tId); \ + } while (0) +#define QW_GET_QTID(id, qId, tId) \ + do { \ + (qId) = *(uint64_t *)(id); \ + (tId) = *(uint64_t *)((char *)(id) + sizeof(qId)); \ + } while (0) -#define QW_ERR_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; return _code; } } while (0) -#define QW_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; } return _code; } while (0) -#define QW_ERR_JRET(c) do { code = c; if (code != TSDB_CODE_SUCCESS) { terrno = code; goto _return; } } while (0) +#define QW_ERR_RET(c) \ + do { \ + int32_t _code = c; \ + if (_code != TSDB_CODE_SUCCESS) { \ + terrno = _code; \ + return _code; \ + } \ + } while (0) +#define QW_RET(c) \ + do { \ + int32_t _code = c; \ + if (_code != TSDB_CODE_SUCCESS) { \ + terrno = _code; \ + } \ + return _code; \ + } while (0) +#define QW_ERR_JRET(c) \ + do { \ + code = c; \ + if (code != TSDB_CODE_SUCCESS) { \ + terrno = code; \ + goto _return; \ + } \ + } while (0) #define QW_ELOG(param, ...) qError("QW:%p " param, mgmt, __VA_ARGS__) #define QW_DLOG(param, ...) qDebug("QW:%p " param, mgmt, __VA_ARGS__) -#define QW_DUMP(param, ...) do { if (gQWDebug.dumpEnable) { qDebug("QW:%p " param, mgmt, __VA_ARGS__); } } while (0) +#define QW_DUMP(param, ...) \ + do { \ + if (gQWDebug.dumpEnable) { \ + qDebug("QW:%p " param, mgmt, __VA_ARGS__); \ + } \ + } while (0) +#define QW_SCH_ELOG(param, ...) qError("QW:%p SID:%" PRIx64 " " param, mgmt, sId, __VA_ARGS__) +#define QW_SCH_DLOG(param, ...) qDebug("QW:%p SID:%" PRIx64 " " param, mgmt, sId, __VA_ARGS__) -#define QW_SCH_ELOG(param, ...) qError("QW:%p SID:%"PRIx64" " param, mgmt, sId, __VA_ARGS__) -#define QW_SCH_DLOG(param, ...) qDebug("QW:%p SID:%"PRIx64" " param, mgmt, sId, __VA_ARGS__) +#define QW_TASK_ELOG(param, ...) qError("QW:%p QID:0x%" PRIx64 ",TID:0x%" PRIx64 " " param, mgmt, qId, tId, __VA_ARGS__) +#define QW_TASK_WLOG(param, ...) qWarn("QW:%p QID:0x%" PRIx64 ",TID:0x%" PRIx64 " " param, mgmt, qId, tId, __VA_ARGS__) +#define QW_TASK_DLOG(param, ...) qDebug("QW:%p QID:0x%" PRIx64 ",TID:0x%" PRIx64 " " param, mgmt, qId, tId, __VA_ARGS__) +#define QW_TASK_DLOGL(param, ...) \ + qDebugL("QW:%p QID:0x%" PRIx64 ",TID:0x%" PRIx64 " " param, mgmt, qId, tId, __VA_ARGS__) -#define QW_TASK_ELOG(param, ...) qError("QW:%p QID:0x%"PRIx64",TID:0x%"PRIx64" " param, mgmt, qId, tId, __VA_ARGS__) -#define QW_TASK_WLOG(param, ...) qWarn("QW:%p QID:0x%"PRIx64",TID:0x%"PRIx64" " param, mgmt, qId, tId, __VA_ARGS__) -#define QW_TASK_DLOG(param, ...) qDebug("QW:%p QID:0x%"PRIx64",TID:0x%"PRIx64" " param, mgmt, qId, tId, __VA_ARGS__) -#define QW_TASK_DLOGL(param, ...) qDebugL("QW:%p QID:0x%"PRIx64",TID:0x%"PRIx64" " param, mgmt, qId, tId, __VA_ARGS__) +#define QW_TASK_ELOG_E(param) qError("QW:%p QID:0x%" PRIx64 ",TID:0x%" PRIx64 " " param, mgmt, qId, tId) +#define QW_TASK_WLOG_E(param) qWarn("QW:%p QID:0x%" PRIx64 ",TID:0x%" PRIx64 " " param, mgmt, qId, tId) +#define QW_TASK_DLOG_E(param) qDebug("QW:%p QID:0x%" PRIx64 ",TID:0x%" PRIx64 " " param, mgmt, qId, tId) -#define QW_TASK_ELOG_E(param) qError("QW:%p QID:0x%"PRIx64",TID:0x%"PRIx64" " param, mgmt, qId, tId) -#define QW_TASK_WLOG_E(param) qWarn("QW:%p QID:0x%"PRIx64",TID:0x%"PRIx64" " param, mgmt, qId, tId) -#define QW_TASK_DLOG_E(param) qDebug("QW:%p QID:0x%"PRIx64",TID:0x%"PRIx64" " param, mgmt, qId, tId) +#define QW_SCH_TASK_ELOG(param, ...) \ + qError("QW:%p SID:0x%" PRIx64 ",QID:0x%" PRIx64 ",TID:0x%" PRIx64 " " param, mgmt, sId, qId, tId, __VA_ARGS__) +#define QW_SCH_TASK_WLOG(param, ...) \ + qWarn("QW:%p SID:0x%" PRIx64 ",QID:0x%" PRIx64 ",TID:0x%" PRIx64 " " param, mgmt, sId, qId, tId, __VA_ARGS__) +#define QW_SCH_TASK_DLOG(param, ...) \ + qDebug("QW:%p SID:0x%" PRIx64 ",QID:0x%" PRIx64 ",TID:0x%" PRIx64 " " param, mgmt, sId, qId, tId, __VA_ARGS__) -#define QW_SCH_TASK_ELOG(param, ...) qError("QW:%p SID:0x%"PRIx64",QID:0x%"PRIx64",TID:0x%"PRIx64" " param, mgmt, sId, qId, tId, __VA_ARGS__) -#define QW_SCH_TASK_WLOG(param, ...) qWarn("QW:%p SID:0x%"PRIx64",QID:0x%"PRIx64",TID:0x%"PRIx64" " param, mgmt, sId, qId, tId, __VA_ARGS__) -#define QW_SCH_TASK_DLOG(param, ...) qDebug("QW:%p SID:0x%"PRIx64",QID:0x%"PRIx64",TID:0x%"PRIx64" " param, mgmt, sId, qId, tId, __VA_ARGS__) - -#define QW_LOCK_DEBUG(...) do { if (gQWDebug.lockEnable) { qDebug(__VA_ARGS__); } } while (0) +#define QW_LOCK_DEBUG(...) \ + do { \ + if (gQWDebug.lockEnable) { \ + qDebug(__VA_ARGS__); \ + } \ + } while (0) #define TD_RWLATCH_WRITE_FLAG_COPY 0x40000000 -#define QW_LOCK(type, _lock) do { \ - if (QW_READ == (type)) { \ - assert(atomic_load_32((_lock)) >= 0); \ - QW_LOCK_DEBUG("QW RLOCK%p:%d, %s:%d B", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ - taosRLockLatch(_lock); \ - QW_LOCK_DEBUG("QW RLOCK%p:%d, %s:%d E", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ - assert(atomic_load_32((_lock)) > 0); \ - } else { \ - assert(atomic_load_32((_lock)) >= 0); \ - QW_LOCK_DEBUG("QW WLOCK%p:%d, %s:%d B", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ - taosWLockLatch(_lock); \ - QW_LOCK_DEBUG("QW WLOCK%p:%d, %s:%d E", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ - assert(atomic_load_32((_lock)) == TD_RWLATCH_WRITE_FLAG_COPY); \ - } \ -} while (0) - -#define QW_UNLOCK(type, _lock) do { \ - if (QW_READ == (type)) { \ - assert(atomic_load_32((_lock)) > 0); \ - QW_LOCK_DEBUG("QW RULOCK%p:%d, %s:%d B", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ - taosRUnLockLatch(_lock); \ - QW_LOCK_DEBUG("QW RULOCK%p:%d, %s:%d E", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ - assert(atomic_load_32((_lock)) >= 0); \ - } else { \ - assert(atomic_load_32((_lock)) == TD_RWLATCH_WRITE_FLAG_COPY); \ - QW_LOCK_DEBUG("QW WULOCK%p:%d, %s:%d B", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ - taosWUnLockLatch(_lock); \ - QW_LOCK_DEBUG("QW WULOCK%p:%d, %s:%d E", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ - assert(atomic_load_32((_lock)) >= 0); \ - } \ -} while (0) +#define QW_LOCK(type, _lock) \ + do { \ + if (QW_READ == (type)) { \ + assert(atomic_load_32((_lock)) >= 0); \ + QW_LOCK_DEBUG("QW RLOCK%p:%d, %s:%d B", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ + taosRLockLatch(_lock); \ + QW_LOCK_DEBUG("QW RLOCK%p:%d, %s:%d E", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ + assert(atomic_load_32((_lock)) > 0); \ + } else { \ + assert(atomic_load_32((_lock)) >= 0); \ + QW_LOCK_DEBUG("QW WLOCK%p:%d, %s:%d B", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ + taosWLockLatch(_lock); \ + QW_LOCK_DEBUG("QW WLOCK%p:%d, %s:%d E", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ + assert(atomic_load_32((_lock)) == TD_RWLATCH_WRITE_FLAG_COPY); \ + } \ + } while (0) + +#define QW_UNLOCK(type, _lock) \ + do { \ + if (QW_READ == (type)) { \ + assert(atomic_load_32((_lock)) > 0); \ + QW_LOCK_DEBUG("QW RULOCK%p:%d, %s:%d B", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ + taosRUnLockLatch(_lock); \ + QW_LOCK_DEBUG("QW RULOCK%p:%d, %s:%d E", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ + assert(atomic_load_32((_lock)) >= 0); \ + } else { \ + assert(atomic_load_32((_lock)) == TD_RWLATCH_WRITE_FLAG_COPY); \ + QW_LOCK_DEBUG("QW WULOCK%p:%d, %s:%d B", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ + taosWUnLockLatch(_lock); \ + QW_LOCK_DEBUG("QW WULOCK%p:%d, %s:%d E", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ + assert(atomic_load_32((_lock)) >= 0); \ + } \ + } while (0) #ifdef __cplusplus } diff --git a/source/libs/scheduler/src/scheduler.c b/source/libs/scheduler/src/scheduler.c index c0b3ae7055..1aff0951e1 100644 --- a/source/libs/scheduler/src/scheduler.c +++ b/source/libs/scheduler/src/scheduler.c @@ -369,7 +369,7 @@ int32_t schBuildTaskRalation(SSchJob *pJob, SHashObj *planToTask) { } for (int32_t n = 0; n < childNum; ++n) { - SSubplan *child = (SSubplan *)nodesListGetNode(pPlan->pChildren, n); + SSubplan * child = (SSubplan *)nodesListGetNode(pPlan->pChildren, n); SSchTask **childTask = taosHashGet(planToTask, &child, POINTER_BYTES); if (NULL == childTask || NULL == *childTask) { SCH_TASK_ELOG("subplan children relationship error, level:%d, taskIdx:%d, childIdx:%d", i, m, n); @@ -401,7 +401,7 @@ int32_t schBuildTaskRalation(SSchJob *pJob, SHashObj *planToTask) { } for (int32_t n = 0; n < parentNum; ++n) { - SSubplan *parent = (SSubplan *)nodesListGetNode(pPlan->pParents, n); + SSubplan * parent = (SSubplan *)nodesListGetNode(pPlan->pParents, n); SSchTask **parentTask = taosHashGet(planToTask, &parent, POINTER_BYTES); if (NULL == parentTask || NULL == *parentTask) { SCH_TASK_ELOG("subplan parent relationship error, level:%d, taskIdx:%d, childIdx:%d", i, m, n); @@ -491,7 +491,7 @@ int32_t schValidateAndBuildJob(SQueryPlan *pDag, SSchJob *pJob) { SSchLevel level = {0}; SNodeListNode *plans = NULL; int32_t taskNum = 0; - SSchLevel *pLevel = NULL; + SSchLevel * pLevel = NULL; level.status = JOB_TASK_STATUS_NOT_START; @@ -1267,7 +1267,7 @@ int32_t schUpdateTaskExecNodeHandle(SSchTask *pTask, void *handle, int32_t rspCo int32_t schHandleCallback(void *param, const SDataBuf *pMsg, int32_t msgType, int32_t rspCode) { int32_t code = 0; SSchTaskCallbackParam *pParam = (SSchTaskCallbackParam *)param; - SSchTask *pTask = NULL; + SSchTask * pTask = NULL; SSchJob *pJob = schAcquireJob(pParam->refId); if (NULL == pJob) { @@ -1617,8 +1617,8 @@ _return: int32_t schMakeHbRpcCtx(SSchJob *pJob, SSchTask *pTask, SRpcCtx *pCtx) { int32_t code = 0; SSchHbCallbackParam *param = NULL; - SMsgSendInfo *pMsgSendInfo = NULL; - SQueryNodeAddr *addr = taosArrayGet(pTask->candidateAddrs, pTask->candidateIdx); + SMsgSendInfo * pMsgSendInfo = NULL; + SQueryNodeAddr * addr = taosArrayGet(pTask->candidateAddrs, pTask->candidateIdx); SQueryNodeEpId epId = {0}; epId.nodeId = addr->nodeId; @@ -1759,10 +1759,10 @@ int32_t schCloneHbRpcCtx(SRpcCtx *pSrc, SRpcCtx *pDst) { } SRpcCtxVal dst = {0}; - void *pIter = taosHashIterate(pSrc->args, NULL); + void * pIter = taosHashIterate(pSrc->args, NULL); while (pIter) { SRpcCtxVal *pVal = (SRpcCtxVal *)pIter; - int32_t *msgType = taosHashGetKey(pIter, NULL); + int32_t * msgType = taosHashGetKey(pIter, NULL); dst = *pVal; dst.val = NULL; @@ -1916,7 +1916,7 @@ _return: int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr, int32_t msgType) { uint32_t msgSize = 0; - void *msg = NULL; + void * msg = NULL; int32_t code = 0; bool isCandidateAddr = false; bool persistHandle = false; @@ -2673,7 +2673,7 @@ int32_t schedulerGetTasksStatus(int64_t job, SArray *pSub) { SSchLevel *pLevel = taosArrayGet(pJob->levels, i); for (int32_t m = 0; m < pLevel->taskNum; ++m) { - SSchTask *pTask = taosArrayGet(pLevel->subTasks, m); + SSchTask * pTask = taosArrayGet(pLevel->subTasks, m); SQuerySubDesc subDesc = {.tid = pTask->taskId, .status = pTask->status}; taosArrayPush(pSub, &subDesc); @@ -2734,7 +2734,7 @@ void schedulerFreeTaskList(SArray *taskList) { void schedulerDestroy(void) { if (schMgmt.jobRef) { SSchJob *pJob = taosIterateRef(schMgmt.jobRef, 0); - int64_t refId = 0; + int64_t refId = 0; while (pJob) { refId = pJob->refId; @@ -2751,12 +2751,12 @@ void schedulerDestroy(void) { } if (schMgmt.hbConnections) { - void *pIter = taosHashIterate(schMgmt.hbConnections, NULL); + void *pIter = taosHashIterate(schMgmt.hbConnections, NULL); while (pIter != NULL) { SSchHbTrans *hb = pIter; schFreeRpcCtx(&hb->rpcCtx); pIter = taosHashIterate(schMgmt.hbConnections, pIter); - } + } taosHashCleanup(schMgmt.hbConnections); schMgmt.hbConnections = NULL; } diff --git a/source/libs/transport/src/transSrv.c b/source/libs/transport/src/transSrv.c index 59a30051ef..a3ed8cb519 100644 --- a/source/libs/transport/src/transSrv.c +++ b/source/libs/transport/src/transSrv.c @@ -45,11 +45,12 @@ typedef struct SSrvConn { struct sockaddr_in addr; struct sockaddr_in locaddr; - int spi; - char info[64]; - char user[TSDB_UNI_LEN]; // user ID for the link - char secret[TSDB_PASSWORD_LEN]; - char ckey[TSDB_PASSWORD_LEN]; // ciphering key + int64_t refId; + int spi; + char info[64]; + char user[TSDB_UNI_LEN]; // user ID for the link + char secret[TSDB_PASSWORD_LEN]; + char ckey[TSDB_PASSWORD_LEN]; // ciphering key } SSrvConn; typedef struct SSrvMsg { @@ -89,6 +90,13 @@ typedef struct SServerObj { uv_async_t* pAcceptAsync; // just to quit from from accept thread } SServerObj; +// handle +typedef struct SExHandle { + void* handle; + int64_t refId; + SWorkThrdObj* pThrd; +} SExHandle; + static const char* notify = "a"; static void uvAllocConnBufferCb(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf); @@ -130,6 +138,15 @@ static void uvHandleRegister(SSrvMsg* msg, SWorkThrdObj* thrd); static void (*transAsyncHandle[])(SSrvMsg* msg, SWorkThrdObj* thrd) = {uvHandleResp, uvHandleQuit, uvHandleRelease, uvHandleRegister}; +static int exHandlesMgt; + +void uvOpenExHandleMgt(int size); +int64_t uvAddExHandle(void* p); +int32_t uvRemoveExHandle(int64_t refId); +int32_t uvReleaseExHandle(int64_t refId); +void uvDestoryExHandle(void* handle); +SExHandle* uvAcquireExHandle(int64_t refId); + static void uvDestroyConn(uv_handle_t* handle); // server and worker thread @@ -168,6 +185,25 @@ static bool addHandleToAcceptloop(void* arg); uv_loop_close(loop); \ } while (0); +#define ASYNC_ERR_JRET(thrd) \ + do { \ + if (thrd->quit) { \ + tTrace("worker thread already quit, ignore msg"); \ + goto _return; \ + } \ + } while (0) + +#define ASYNC_CHECK_HANDLE(exh1, refId) \ + do { \ + if (refId != -1) { \ + SExHandle* exh2 = uvAcquireExHandle(refId); \ + if (exh2 == NULL || exh1 != exh2) { \ + tTrace("server conn %p except, may already freed, ignore msg", exh2 ? exh2->handle : NULL); \ + goto _return; \ + } \ + } \ + } while (0) + void uvAllocRecvBufferCb(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf) { SSrvConn* conn = handle->data; SConnBuffer* pBuf = &conn->readBuf; @@ -233,7 +269,11 @@ static void uvHandleReq(SSrvConn* pConn) { // 1. server application should not send resp on handle // 2. once send out data, cli conn released to conn pool immediately // 3. not mixed with persist - transMsg.handle = pConn; + transMsg.handle = (void*)uvAcquireExHandle(pConn->refId); + if (pHead->noResp == 1) { + // transMsg.refId = -1; + } + uvReleaseExHandle(pConn->refId); STrans* pTransInst = pConn->pTransInst; (*pTransInst->cfp)(pTransInst->parent, &transMsg, NULL); @@ -436,6 +476,18 @@ void uvWorkerAsyncCb(uv_async_t* handle) { tError("unexcept occurred, continue"); continue; } + // release handle to rpc init + STransMsg transMsg = msg->msg; + SExHandle* exh1 = transMsg.handle; + int64_t refId = transMsg.refId; + SExHandle* exh2 = uvAcquireExHandle(refId); + if (exh2 == NULL || exh1 != exh2) { + uvReleaseExHandle(refId); + destroySmsg(msg); + continue; + } + + msg->pConn = exh1->handle; (*transAsyncHandle[msg->type])(msg, pThrd); } } @@ -658,6 +710,13 @@ static SSrvConn* createConn(void* hThrd) { pConn->broken = false; pConn->status = ConnNormal; + SExHandle* exh = taosMemoryMalloc(sizeof(SExHandle)); + exh->handle = pConn; + exh->pThrd = pThrd; + exh->refId = uvAddExHandle(exh); + uvAcquireExHandle(exh->refId); + + pConn->refId = exh->refId; transRefSrvHandle(pConn); tTrace("server conn %p created", pConn); return pConn; @@ -667,6 +726,9 @@ static void destroyConn(SSrvConn* conn, bool clear) { if (conn == NULL) { return; } + uvReleaseExHandle(conn->refId); + uvRemoveExHandle(conn->refId); + transDestroyBuffer(&conn->readBuf); if (clear) { tTrace("server conn %p to be destroyed", conn); @@ -705,6 +767,8 @@ void* transInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads, srv->port = port; uv_loop_init(srv->loop); + uvOpenExHandleMgt(10000); + for (int i = 0; i < srv->numOfThreads; i++) { SWorkThrdObj* thrd = (SWorkThrdObj*)taosMemoryCalloc(1, sizeof(SWorkThrdObj)); thrd->quit = false; @@ -749,6 +813,35 @@ End: transCloseServer(srv); return NULL; } +void uvOpenExHandleMgt(int size) { + // added into once later + exHandlesMgt = taosOpenRef(size, uvDestoryExHandle); +} +int64_t uvAddExHandle(void* p) { + // acquire extern handle + return taosAddRef(exHandlesMgt, p); +} +int32_t uvRemoveExHandle(int64_t refId) { + // acquire extern handle + return taosRemoveRef(exHandlesMgt, refId); +} + +SExHandle* uvAcquireExHandle(int64_t refId) { + // acquire extern handle + return (SExHandle*)taosAcquireRef(exHandlesMgt, refId); +} + +int32_t uvReleaseExHandle(int64_t refId) { + // release extern handle + return taosReleaseRef(exHandlesMgt, refId); +} +void uvDestoryExHandle(void* handle) { + if (handle == NULL) { + return; + } + taosMemoryFree(handle); +} + void uvHandleQuit(SSrvMsg* msg, SWorkThrdObj* thrd) { thrd->quit = true; if (QUEUE_IS_EMPTY(&thrd->conn)) { @@ -759,7 +852,6 @@ void uvHandleQuit(SSrvMsg* msg, SWorkThrdObj* thrd) { taosMemoryFree(msg); } void uvHandleRelease(SSrvMsg* msg, SWorkThrdObj* thrd) { - // release handle to rpc init SSrvConn* conn = msg->pConn; if (conn->status == ConnAcquire) { if (!transQueuePush(&conn->srvMsgs, msg)) { @@ -862,55 +954,66 @@ void transUnrefSrvHandle(void* handle) { } void transReleaseSrvHandle(void* handle) { - if (handle == NULL) { - return; - } - SSrvConn* pConn = handle; - SWorkThrdObj* pThrd = pConn->hostThrd; + SExHandle* exh = handle; + // TODO(yihaoDeng): not safy here, + int64_t refId = exh->refId; + ASYNC_CHECK_HANDLE(exh, refId); - STransMsg tmsg = {.code = 0, .handle = handle, .ahandle = NULL}; + SWorkThrdObj* pThrd = exh->pThrd; + ASYNC_ERR_JRET(pThrd); + + STransMsg tmsg = {.code = 0, .handle = exh, .ahandle = NULL, .refId = exh->refId}; SSrvMsg* srvMsg = taosMemoryCalloc(1, sizeof(SSrvMsg)); srvMsg->msg = tmsg; srvMsg->type = Release; - srvMsg->pConn = pConn; - tTrace("server conn %p start to release", pConn); + tTrace("server conn %p start to release", exh->handle); transSendAsync(pThrd->asyncPool, &srvMsg->q); + uvReleaseExHandle(refId); + return; +_return: + uvReleaseExHandle(refId); } -void transSendResponse(const STransMsg* pMsg) { - if (pMsg->handle == NULL) { - return; - } - SSrvConn* pConn = pMsg->handle; - SWorkThrdObj* pThrd = pConn->hostThrd; - if (pThrd->quit) { - return; - } +void transSendResponse(const STransMsg* msg) { + SExHandle* exh = msg->handle; + int64_t refId = msg->refId; + ASYNC_CHECK_HANDLE(exh, refId); + + SWorkThrdObj* pThrd = exh->pThrd; + ASYNC_ERR_JRET(pThrd); SSrvMsg* srvMsg = taosMemoryCalloc(1, sizeof(SSrvMsg)); - srvMsg->pConn = pConn; - srvMsg->msg = *pMsg; + srvMsg->msg = *msg; srvMsg->type = Normal; - tTrace("server conn %p start to send resp (1/2)", pConn); + tTrace("server conn %p start to send resp (1/2)", exh->handle); transSendAsync(pThrd->asyncPool, &srvMsg->q); + uvReleaseExHandle(refId); + return; +_return: + uvReleaseExHandle(refId); } void transRegisterMsg(const STransMsg* msg) { - if (msg->handle == NULL) { - return; - } - SSrvConn* pConn = msg->handle; - SWorkThrdObj* pThrd = pConn->hostThrd; + SExHandle* exh = NULL; + int64_t refId = msg->refId; + ASYNC_CHECK_HANDLE(exh, refId); + + SWorkThrdObj* pThrd = exh->pThrd; + ASYNC_ERR_JRET(pThrd); SSrvMsg* srvMsg = taosMemoryCalloc(1, sizeof(SSrvMsg)); - srvMsg->pConn = pConn; srvMsg->msg = *msg; srvMsg->type = Register; - tTrace("server conn %p start to register brokenlink callback", pConn); + tTrace("server conn %p start to register brokenlink callback", exh->handle); transSendAsync(pThrd->asyncPool, &srvMsg->q); + uvReleaseExHandle(refId); + return; +_return: + uvReleaseExHandle(refId); } int transGetConnInfo(void* thandle, STransHandleInfo* pInfo) { - SSrvConn* pConn = thandle; + SExHandle* ex = thandle; + SSrvConn* pConn = ex->handle; struct sockaddr_in addr = pConn->addr; pInfo->clientIp = (uint32_t)(addr.sin_addr.s_addr); From fefd25067b465f4c1ec5468620b2800c7bd47e01 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Fri, 22 Apr 2022 23:58:34 +0800 Subject: [PATCH 02/11] fix rpc bug --- source/dnode/mgmt/implement/src/dmExec.c | 2 +- source/dnode/mgmt/mgmt_bnode/src/bmWorker.c | 5 +- source/dnode/mgmt/mgmt_mnode/src/mmWorker.c | 1 + source/dnode/mgmt/mgmt_qnode/src/qmWorker.c | 1 + source/dnode/mgmt/mgmt_snode/src/smWorker.c | 9 +- source/dnode/mgmt/mgmt_vnode/src/vmWorker.c | 18 +- source/dnode/mnode/impl/inc/mndDef.h | 1 + source/dnode/mnode/impl/src/mndTrans.c | 27 +- .../mnode/impl/test/profile/.profile.cpp.swo | Bin 0 -> 16384 bytes source/dnode/vnode/inc/log | 586 ++++++++++++++++++ source/libs/qworker/inc/qworkerInt.h | 4 +- source/libs/qworker/src/qworkerMsg.c | 270 ++++---- source/libs/transport/inc/transComm.h | 4 + source/libs/transport/src/transComm.c | 9 +- source/libs/transport/src/transSrv.c | 145 +++-- 15 files changed, 884 insertions(+), 198 deletions(-) create mode 100644 source/dnode/mnode/impl/test/profile/.profile.cpp.swo create mode 100644 source/dnode/vnode/inc/log diff --git a/source/dnode/mgmt/implement/src/dmExec.c b/source/dnode/mgmt/implement/src/dmExec.c index e14996120b..c0b85ed705 100644 --- a/source/dnode/mgmt/implement/src/dmExec.c +++ b/source/dnode/mgmt/implement/src/dmExec.c @@ -275,7 +275,7 @@ static void dmCloseNodes(SDnode *pDnode) { static void dmProcessProcHandle(void *handle) { dWarn("handle:%p, the child process dies and send an offline rsp", handle); - SRpcMsg rpcMsg = {.handle = handle, .code = TSDB_CODE_NODE_OFFLINE, .refId = -1}; + SRpcMsg rpcMsg = {.handle = handle, .code = TSDB_CODE_NODE_OFFLINE}; rpcSendResponse(&rpcMsg); } diff --git a/source/dnode/mgmt/mgmt_bnode/src/bmWorker.c b/source/dnode/mgmt/mgmt_bnode/src/bmWorker.c index 3481078d51..0b7bf69b0d 100644 --- a/source/dnode/mgmt/mgmt_bnode/src/bmWorker.c +++ b/source/dnode/mgmt/mgmt_bnode/src/bmWorker.c @@ -38,6 +38,7 @@ static void bmSendErrorRsps(STaosQall *qall, int32_t numOfMsgs, int32_t code) { static inline void bmSendRsp(SNodeMsg *pMsg, int32_t code) { SRpcMsg rsp = {.handle = pMsg->rpcMsg.handle, .ahandle = pMsg->rpcMsg.ahandle, + .refId = pMsg->rpcMsg.refId, .code = code, .pCont = pMsg->pRsp, .contLen = pMsg->rspLen}; @@ -101,7 +102,7 @@ static void bmProcessWriteQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numO } int32_t bmProcessWriteMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) { - SBnodeMgmt *pMgmt = pWrapper->pMgmt; + SBnodeMgmt * pMgmt = pWrapper->pMgmt; SMultiWorker *pWorker = &pMgmt->writeWorker; dTrace("msg:%p, put into worker:%s", pMsg, pWorker->name); @@ -110,7 +111,7 @@ int32_t bmProcessWriteMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) { } int32_t bmProcessMonitorMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) { - SBnodeMgmt *pMgmt = pWrapper->pMgmt; + SBnodeMgmt * pMgmt = pWrapper->pMgmt; SSingleWorker *pWorker = &pMgmt->monitorWorker; dTrace("msg:%p, put into worker:%s", pMsg, pWorker->name); diff --git a/source/dnode/mgmt/mgmt_mnode/src/mmWorker.c b/source/dnode/mgmt/mgmt_mnode/src/mmWorker.c index e9c40fdd0f..1f27b314e2 100644 --- a/source/dnode/mgmt/mgmt_mnode/src/mmWorker.c +++ b/source/dnode/mgmt/mgmt_mnode/src/mmWorker.c @@ -19,6 +19,7 @@ static inline void mmSendRsp(SNodeMsg *pMsg, int32_t code) { SRpcMsg rsp = {.handle = pMsg->rpcMsg.handle, .ahandle = pMsg->rpcMsg.ahandle, + .refId = pMsg->rpcMsg.refId, .code = code, .pCont = pMsg->pRsp, .contLen = pMsg->rspLen}; diff --git a/source/dnode/mgmt/mgmt_qnode/src/qmWorker.c b/source/dnode/mgmt/mgmt_qnode/src/qmWorker.c index 6b27af4fbd..da85ee64a8 100644 --- a/source/dnode/mgmt/mgmt_qnode/src/qmWorker.c +++ b/source/dnode/mgmt/mgmt_qnode/src/qmWorker.c @@ -19,6 +19,7 @@ static inline void qmSendRsp(SNodeMsg *pMsg, int32_t code) { SRpcMsg rsp = {.handle = pMsg->rpcMsg.handle, .ahandle = pMsg->rpcMsg.ahandle, + .refId = pMsg->rpcMsg.refId, .code = code, .pCont = pMsg->pRsp, .contLen = pMsg->rspLen}; diff --git a/source/dnode/mgmt/mgmt_snode/src/smWorker.c b/source/dnode/mgmt/mgmt_snode/src/smWorker.c index cf343423b7..25872aec55 100644 --- a/source/dnode/mgmt/mgmt_snode/src/smWorker.c +++ b/source/dnode/mgmt/mgmt_snode/src/smWorker.c @@ -19,6 +19,7 @@ static inline void smSendRsp(SNodeMsg *pMsg, int32_t code) { SRpcMsg rsp = {.handle = pMsg->rpcMsg.handle, .ahandle = pMsg->rpcMsg.ahandle, + .refId = pMsg->rpcMsg.refId, .code = code, .pCont = pMsg->pRsp, .contLen = pMsg->rspLen}; @@ -149,7 +150,7 @@ static FORCE_INLINE int32_t smGetSWTypeFromMsg(SRpcMsg *pMsg) { } int32_t smProcessMgmtMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) { - SSnodeMgmt *pMgmt = pWrapper->pMgmt; + SSnodeMgmt * pMgmt = pWrapper->pMgmt; SMultiWorker *pWorker = taosArrayGetP(pMgmt->uniqueWorkers, 0); if (pWorker == NULL) { terrno = TSDB_CODE_INVALID_MSG; @@ -162,7 +163,7 @@ int32_t smProcessMgmtMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) { } int32_t smProcessMonitorMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) { - SSnodeMgmt *pMgmt = pWrapper->pMgmt; + SSnodeMgmt * pMgmt = pWrapper->pMgmt; SSingleWorker *pWorker = &pMgmt->monitorWorker; dTrace("msg:%p, put into worker:%s", pMsg, pWorker->name); @@ -171,7 +172,7 @@ int32_t smProcessMonitorMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) { } int32_t smProcessUniqueMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) { - SSnodeMgmt *pMgmt = pWrapper->pMgmt; + SSnodeMgmt * pMgmt = pWrapper->pMgmt; int32_t index = smGetSWIdFromMsg(&pMsg->rpcMsg); SMultiWorker *pWorker = taosArrayGetP(pMgmt->uniqueWorkers, index); if (pWorker == NULL) { @@ -185,7 +186,7 @@ int32_t smProcessUniqueMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) { } int32_t smProcessSharedMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) { - SSnodeMgmt *pMgmt = pWrapper->pMgmt; + SSnodeMgmt * pMgmt = pWrapper->pMgmt; SSingleWorker *pWorker = &pMgmt->sharedWorker; dTrace("msg:%p, put into worker:%s", pMsg, pWorker->name); diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c b/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c index dce5f1b422..7d70e6feb1 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c @@ -19,6 +19,7 @@ static inline void vmSendRsp(SMgmtWrapper *pWrapper, SNodeMsg *pMsg, int32_t code) { SRpcMsg rsp = {.handle = pMsg->rpcMsg.handle, .ahandle = pMsg->rpcMsg.ahandle, + .refId = pMsg->rpcMsg.refId, .code = code, .pCont = pMsg->pRsp, .contLen = pMsg->rspLen}; @@ -112,7 +113,7 @@ static void vmProcessWriteQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numO numOfMsgs = taosArrayGetSize(pArray); for (int32_t i = 0; i < numOfMsgs; i++) { SNodeMsg *pMsg = *(SNodeMsg **)taosArrayGet(pArray, i); - SRpcMsg *pRpc = &pMsg->rpcMsg; + SRpcMsg * pRpc = &pMsg->rpcMsg; SRpcMsg rsp; rsp.pCont = NULL; @@ -120,6 +121,7 @@ static void vmProcessWriteQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numO rsp.code = 0; rsp.handle = pRpc->handle; rsp.ahandle = pRpc->ahandle; + rsp.refId = pRpc->refId; int32_t code = vnodeProcessWriteReq(pVnode->pImpl, pRpc, version++, &rsp); tmsgSendRsp(&rsp); @@ -147,7 +149,7 @@ static void vmProcessWriteQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numO static void vmProcessApplyQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) { SVnodeObj *pVnode = pInfo->ahandle; - SNodeMsg *pMsg = NULL; + SNodeMsg * pMsg = NULL; for (int32_t i = 0; i < numOfMsgs; ++i) { taosGetQitem(qall, (void **)&pMsg); @@ -160,7 +162,7 @@ static void vmProcessApplyQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numO static void vmProcessSyncQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) { SVnodeObj *pVnode = pInfo->ahandle; - SNodeMsg *pMsg = NULL; + SNodeMsg * pMsg = NULL; for (int32_t i = 0; i < numOfMsgs; ++i) { taosGetQitem(qall, (void **)&pMsg); @@ -173,7 +175,7 @@ static void vmProcessSyncQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numOf static void vmProcessMergeQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) { SVnodeObj *pVnode = pInfo->ahandle; - SNodeMsg *pMsg = NULL; + SNodeMsg * pMsg = NULL; for (int32_t i = 0; i < numOfMsgs; ++i) { taosGetQitem(qall, (void **)&pMsg); @@ -190,7 +192,7 @@ static void vmProcessMergeQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numO } static int32_t vmPutNodeMsgToQueue(SVnodesMgmt *pMgmt, SNodeMsg *pMsg, EQueueType qtype) { - SRpcMsg *pRpc = &pMsg->rpcMsg; + SRpcMsg * pRpc = &pMsg->rpcMsg; SMsgHead *pHead = pRpc->pCont; pHead->contLen = ntohl(pHead->contLen); pHead->vgId = ntohl(pHead->vgId); @@ -259,7 +261,7 @@ int32_t vmProcessMergeMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) { } int32_t vmProcessMgmtMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) { - SVnodesMgmt *pMgmt = pWrapper->pMgmt; + SVnodesMgmt * pMgmt = pWrapper->pMgmt; SSingleWorker *pWorker = &pMgmt->mgmtWorker; dTrace("msg:%p, will be written to vnode-mgmt queue, worker:%s", pMsg, pWorker->name); taosWriteQitem(pWorker->queue, pMsg); @@ -267,7 +269,7 @@ int32_t vmProcessMgmtMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) { } int32_t vmProcessMonitorMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) { - SVnodesMgmt *pMgmt = pWrapper->pMgmt; + SVnodesMgmt * pMgmt = pWrapper->pMgmt; SSingleWorker *pWorker = &pMgmt->monitorWorker; dTrace("msg:%p, put into worker:%s", pMsg, pWorker->name); @@ -277,7 +279,7 @@ int32_t vmProcessMonitorMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) { static int32_t vmPutRpcMsgToQueue(SMgmtWrapper *pWrapper, SRpcMsg *pRpc, EQueueType qtype) { SVnodesMgmt *pMgmt = pWrapper->pMgmt; - SMsgHead *pHead = pRpc->pCont; + SMsgHead * pHead = pRpc->pCont; SVnodeObj *pVnode = vmAcquireVnode(pMgmt, pHead->vgId); if (pVnode == NULL) return -1; diff --git a/source/dnode/mnode/impl/inc/mndDef.h b/source/dnode/mnode/impl/inc/mndDef.h index 984e9f917f..3e2e1107f2 100644 --- a/source/dnode/mnode/impl/inc/mndDef.h +++ b/source/dnode/mnode/impl/inc/mndDef.h @@ -135,6 +135,7 @@ typedef struct { int32_t failedTimes; void* rpcHandle; void* rpcAHandle; + int64_t rpcRefId; void* rpcRsp; int32_t rpcRspLen; SArray* redoLogs; diff --git a/source/dnode/mnode/impl/src/mndTrans.c b/source/dnode/mnode/impl/src/mndTrans.c index 59fe7d16b9..9e9a8b56c9 100644 --- a/source/dnode/mnode/impl/src/mndTrans.c +++ b/source/dnode/mnode/impl/src/mndTrans.c @@ -193,9 +193,9 @@ TRANS_ENCODE_OVER: static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) { terrno = TSDB_CODE_OUT_OF_MEMORY; - SSdbRow *pRow = NULL; - STrans *pTrans = NULL; - char *pData = NULL; + SSdbRow * pRow = NULL; + STrans * pTrans = NULL; + char * pData = NULL; int32_t dataLen = 0; int8_t sver = 0; int32_t redoLogNum = 0; @@ -456,7 +456,7 @@ static int32_t mndTransActionUpdate(SSdb *pSdb, STrans *pOld, STrans *pNew) { } static STrans *mndAcquireTrans(SMnode *pMnode, int32_t transId) { - SSdb *pSdb = pMnode->pSdb; + SSdb * pSdb = pMnode->pSdb; STrans *pTrans = sdbAcquire(pSdb, SDB_TRANS, &transId); if (pTrans == NULL) { terrno = TSDB_CODE_MND_TRANS_NOT_EXIST; @@ -484,6 +484,7 @@ STrans *mndTransCreate(SMnode *pMnode, ETrnPolicy policy, ETrnType type, const S pTrans->createdTime = taosGetTimestampMs(); pTrans->rpcHandle = pReq->handle; pTrans->rpcAHandle = pReq->ahandle; + pTrans->rpcRefId = pReq->refId; pTrans->redoLogs = taosArrayInit(MND_TRANS_ARRAY_SIZE, sizeof(void *)); pTrans->undoLogs = taosArrayInit(MND_TRANS_ARRAY_SIZE, sizeof(void *)); pTrans->commitLogs = taosArrayInit(MND_TRANS_ARRAY_SIZE, sizeof(void *)); @@ -625,7 +626,7 @@ static int32_t mndCheckTransCanBeStartedInParallel(SMnode *pMnode, STrans *pNewT if (mndIsBasicTrans(pNewTrans)) return 0; STrans *pTrans = NULL; - void *pIter = NULL; + void * pIter = NULL; int32_t code = 0; while (1) { @@ -703,6 +704,7 @@ int32_t mndTransPrepare(SMnode *pMnode, STrans *pTrans) { pNew->rpcHandle = pTrans->rpcHandle; pNew->rpcAHandle = pTrans->rpcAHandle; + pNew->rpcRefId = pTrans->rpcRefId; pNew->rpcRsp = pTrans->rpcRsp; pNew->rpcRspLen = pTrans->rpcRspLen; pTrans->rpcRsp = NULL; @@ -767,6 +769,7 @@ static void mndTransSendRpcRsp(SMnode *pMnode, STrans *pTrans) { SRpcMsg rspMsg = {.handle = pTrans->rpcHandle, .code = pTrans->code, .ahandle = pTrans->rpcAHandle, + .refId = pTrans->rpcRefId, .pCont = rpcCont, .contLen = pTrans->rpcRspLen}; tmsgSendRsp(&rspMsg); @@ -827,7 +830,7 @@ HANDLE_ACTION_RSP_OVER: } static int32_t mndTransExecuteLogs(SMnode *pMnode, SArray *pArray) { - SSdb *pSdb = pMnode->pSdb; + SSdb * pSdb = pMnode->pSdb; int32_t arraySize = taosArrayGetSize(pArray); if (arraySize == 0) return 0; @@ -1202,11 +1205,11 @@ static int32_t mndKillTrans(SMnode *pMnode, STrans *pTrans) { } static int32_t mndProcessKillTransReq(SNodeMsg *pReq) { - SMnode *pMnode = pReq->pNode; + SMnode * pMnode = pReq->pNode; SKillTransReq killReq = {0}; int32_t code = -1; - SUserObj *pUser = NULL; - STrans *pTrans = NULL; + SUserObj * pUser = NULL; + STrans * pTrans = NULL; if (tDeserializeSKillTransReq(pReq->rpcMsg.pCont, pReq->rpcMsg.contLen, &killReq) != 0) { terrno = TSDB_CODE_INVALID_MSG; @@ -1246,7 +1249,7 @@ KILL_OVER: void mndTransPullup(SMnode *pMnode) { STrans *pTrans = NULL; - void *pIter = NULL; + void * pIter = NULL; while (1) { pIter = sdbFetch(pMnode->pSdb, SDB_TRANS, pIter, (void **)&pTrans); @@ -1261,11 +1264,11 @@ void mndTransPullup(SMnode *pMnode) { static int32_t mndRetrieveTrans(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) { SMnode *pMnode = pReq->pNode; - SSdb *pSdb = pMnode->pSdb; + SSdb * pSdb = pMnode->pSdb; int32_t numOfRows = 0; STrans *pTrans = NULL; int32_t cols = 0; - char *pWrite; + char * pWrite; while (numOfRows < rows) { pShow->pIter = sdbFetch(pSdb, SDB_TRANS, pShow->pIter, (void **)&pTrans); diff --git a/source/dnode/mnode/impl/test/profile/.profile.cpp.swo b/source/dnode/mnode/impl/test/profile/.profile.cpp.swo new file mode 100644 index 0000000000000000000000000000000000000000..004b23f8f98327c311baaa89f32bcfab92866a8c GIT binary patch literal 16384 zcmeI3U2Ggz700I}rJ<0tfK&oV^s+(GthL@V#A+1;c`qjowwd)GVi zcxF6v$7U0iO7sD>LI|1yqVNO{h<*sf1D{2G;Ohb2ka$6A0YyLo5kT-n`1s#DA3L+_ zwMkS2LSyCU_1t^r-gD1A_ue^YHqGMsg=I38ACvHNwe+bA&V zvV!ecZQY>ZXI``I-TFxDQVXOO*uerGYmZJHlqSZ)0M|HJtI z#$A&1Yw$977CZ&EfD3A11uTLOfN3xV4uBhnBOW+~!esB={@GX+`1Mn%(1?RyC$b#Rz89IWez>{DeX`U=_R@ybJscbNMp(0{A?50-Of#1h)e|*ZV;9L&$8sUa2*d%30aHoFm2T zNr@2MWW>Ep?juaK+*!v_yJsk?>zAqQxON`6LX4HEOC4P`P*X1%IyKpRb53Pir{>zS zz3i@yp0Z1p$#TTM(D3&XHFM-B+7L|)+(uA?j;|CSJ1Ievo_1jiEgEVW)Kx2@s~j;s z!?2m-w_CF{^gkjx<^#bOO7eATwrX@!Zj_fB%5t@=%vWY>jk(HfBS)HEJ4cv7P27%t zS$)XBaC;<*aWutf>89v(%hFpTgz&b|rQA0*x;c_{pp|MEmd33j2i*yKPmC)}^v{*u zrSs~!r6m|3*)>-tmcbXXjED$SHu!rsGgr)S|}^!IWe2D zHH{XBt!Y&8sn~H%^8vz4*m5uvITEOZ#$mzu!t#d%895;crw>fSCzAV3xT?7rdQC3j zUh}bl!4cp23k$||PjbZsWo8kF_08DlE> zSMB(8?$lhX2?5>20@hnft2sV=C)>;v^uG)QiD?lQj3 z!rh!N@n8(A7?`5TvWK%~N?{|}Xr#=+E-d?(@aw^mYaP`|7GDxRwF>8XaHUpOmMYbU z!!<^T5ciwA#EUaritBHihh}JvtXgt8#SD& zF%fFlDa%vay;OWS-`;HDAk5$_P>qh|22<8spJLnUJy6Y7R-OsGP8>Bf}Y z#Qxol=~lKQ?i>GWy9#s){R3{%tPAn-rUi(KIY2aC-Y;BuzmRMWVar71?SNQV=KlliCtaEmMmF+bRU7O(x(`72t zH6Ahe`h@*QHIX7g$5Dl7KJ1)J)jge2balmFKqZ5!riZ>y60S|qQBSEIZV}I9nF8Ce z{V$Uz53g|7q5@Yev!x97TO*A~VDvBbk}udh6!e%na|4p8!X6Q!_kRDdT!9 z-^suXBL#qe-uFOH9gGB|vwC>Sk{jTVoK`(Sw&4`XC3Uli9( zN2hJFT*Y$|*|1ukLAlQS`|!d#t`Jf^*0FFF8f%_v650Pe9iDGEk~XqJPTUsUF1|)z z7#Wdx{C_`UO&+82_`ezih1U?vzW|;CUjmPV61WfWc>gf?8{+s^!7Jc%U=y4KJkI|M z;`X0{Z-7sOtKezyF`$A+!F#|B#PF|zm%wL$0oK7$Z~*)kG5l-btKb=6fH`mvxQ6)s zE8sHdf(9spL*O;U?cW8T1%1PPAe84QteS}2Q9BNi>(Vj5#{VQER>!??ItCL>aOr(DK5 zM)mq8G7{bOQW?FD@T?YGU^<#1#j3X!?jK`yU5Xr}H;8D1^AqvEYN%lwK z!{m}7_@ETG93PpVv|cRX2Kp`d~A`1S3qx zJPOYrl<}upWa5xC@xyt7>>N)R`qmGOiP`Qj66`a8&U0!uTs$G&Av=YWK=OMvG{_7C9fMjwR?t;-=`Bw_|NI>4)kO~A|KV5edKwWV0gmWxf_)3DRH0q}!y!U+OgRQip7~YeQ4dClY7cfAC4 +802e2d77c00 include/tkv/tkv.h (Hongze Cheng 2021-09-22 13:21:07 +0800 3) * +802e2d77c00 include/tkv/tkv.h (Hongze Cheng 2021-09-22 13:21:07 +0800 4) * This program is free software: you can use, redistribute, and/or modify +802e2d77c00 include/tkv/tkv.h (Hongze Cheng 2021-09-22 13:21:07 +0800 5) * it under the terms of the GNU Affero General Public License, version 3 +802e2d77c00 include/tkv/tkv.h (Hongze Cheng 2021-09-22 13:21:07 +0800 6) * or later ("AGPL"), as published by the Free Software Foundation. +802e2d77c00 include/tkv/tkv.h (Hongze Cheng 2021-09-22 13:21:07 +0800 7) * +802e2d77c00 include/tkv/tkv.h (Hongze Cheng 2021-09-22 13:21:07 +0800 8) * This program is distributed in the hope that it will be useful, but WITHOUT +802e2d77c00 include/tkv/tkv.h (Hongze Cheng 2021-09-22 13:21:07 +0800 9) * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +802e2d77c00 include/tkv/tkv.h (Hongze Cheng 2021-09-22 13:21:07 +0800 10) * FITNESS FOR A PARTICULAR PURPOSE. +802e2d77c00 include/tkv/tkv.h (Hongze Cheng 2021-09-22 13:21:07 +0800 11) * +802e2d77c00 include/tkv/tkv.h (Hongze Cheng 2021-09-22 13:21:07 +0800 12) * You should have received a copy of the GNU Affero General Public License +802e2d77c00 include/tkv/tkv.h (Hongze Cheng 2021-09-22 13:21:07 +0800 13) * along with this program. If not, see . +ce7a1600eb4 include/server/vnode/vnode.h (Shengliang Guan 2021-09-22 20:29:24 +0800 14) */ +ce7a1600eb4 include/server/vnode/vnode.h (Shengliang Guan 2021-09-22 20:29:24 +0800 15) +ce7a1600eb4 include/server/vnode/vnode.h (Shengliang Guan 2021-09-22 20:29:24 +0800 16) #ifndef _TD_VNODE_H_ +ce7a1600eb4 include/server/vnode/vnode.h (Shengliang Guan 2021-09-22 20:29:24 +0800 17) #define _TD_VNODE_H_ +ce7a1600eb4 include/server/vnode/vnode.h (Shengliang Guan 2021-09-22 20:29:24 +0800 18) +79e5aeaa093 include/server/vnode/vnode.h (Hongze Cheng 2021-11-09 13:24:22 +0800 19) #include "os.h" +220fdfabe29 source/dnode/vnode/inc/vnode.h (Shengliang Guan 2022-03-21 19:08:25 +0800 20) #include "tmsgcb.h" +a9ad7ebd100 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-29 18:58:15 +0800 21) #include "tqueue.h" +a9ad7ebd100 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-29 18:58:15 +0800 22) #include "trpc.h" +79e5aeaa093 include/server/vnode/vnode.h (Hongze Cheng 2021-11-09 13:24:22 +0800 23) +7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 24) #include "tarray.h" +cc5563716c5 source/dnode/vnode/inc/vnode.h (Shengliang Guan 2022-01-18 22:04:01 -0800 25) #include "tfs.h" +2b5e0592c4d include/dnode/vnode/vnode.h (Hongze Cheng 2021-11-24 16:29:02 +0800 26) #include "wal.h" +2f36662750f include/server/vnode/vnode.h (Shengliang Guan 2021-11-01 19:49:44 +0800 27) +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 28) #include "tmallocator.h" +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 29) #include "tmsg.h" +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 30) #include "trow.h" +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 31) #include "tmallocator.h" +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 32) #include "tcommon.h" +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 33) #include "tfs.h" +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 34) +ce7a1600eb4 include/server/vnode/vnode.h (Shengliang Guan 2021-09-22 20:29:24 +0800 35) #ifdef __cplusplus +ce7a1600eb4 include/server/vnode/vnode.h (Shengliang Guan 2021-09-22 20:29:24 +0800 36) extern "C" { +ce7a1600eb4 include/server/vnode/vnode.h (Shengliang Guan 2021-09-22 20:29:24 +0800 37) #endif +ce7a1600eb4 include/server/vnode/vnode.h (Shengliang Guan 2021-09-22 20:29:24 +0800 38) +993d28df0f6 include/server/vnode/vnode.h (Hongze Cheng 2021-11-07 15:58:32 +0800 39) /* ------------------------ TYPES EXPOSED ------------------------ */ +5832b6772c1 source/dnode/vnode/inc/vnode.h (Shengliang Guan 2022-03-16 21:18:54 +0800 40) typedef struct SMgmtWrapper SMgmtWrapper; +5832b6772c1 source/dnode/vnode/inc/vnode.h (Shengliang Guan 2022-03-16 21:18:54 +0800 41) typedef struct SVnode SVnode; +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 42) +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 43) #define META_SUPER_TABLE TD_SUPER_TABLE +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 44) #define META_CHILD_TABLE TD_CHILD_TABLE +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 45) #define META_NORMAL_TABLE TD_NORMAL_TABLE +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 46) +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 47) // Types exported +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 48) typedef struct SMeta SMeta; +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 49) +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 50) typedef struct SMetaCfg { +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 51) /// LRU cache size +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 52) uint64_t lruSize; +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 53) } SMetaCfg; +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 54) +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 55) typedef struct SMTbCursor SMTbCursor; +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 56) typedef struct SMCtbCursor SMCtbCursor; +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 57) typedef struct SMSmaCursor SMSmaCursor; +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 58) +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 59) typedef SVCreateTbReq STbCfg; +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 60) typedef SVCreateTSmaReq SSmaCfg; +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 61) +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 62) typedef struct SDataStatis { +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 63) int16_t colId; +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 64) int16_t maxIndex; +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 65) int16_t minIndex; +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 66) int16_t numOfNull; +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 67) int64_t sum; +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 68) int64_t max; +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 69) int64_t min; +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 70) } SDataStatis; +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 71) +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 72) typedef struct STsdbQueryCond { +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 73) STimeWindow twindow; +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 74) int32_t order; // desc|asc order to iterate the data block +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 75) int32_t numOfCols; +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 76) SColumnInfo *colList; +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 77) bool loadExternalRows; // load external rows or not +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 78) int32_t type; // data block load type: +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 79) } STsdbQueryCond; +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 80) +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 81) typedef struct { +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 82) TSKEY lastKey; +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 83) uint64_t uid; +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 84) } STableKeyInfo; +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 85) +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 86) +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 87) typedef struct STable { +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 88) uint64_t tid; +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 89) uint64_t uid; +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 90) STSchema *pSchema; +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 91) } STable; +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 92) +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 93) #define BLOCK_LOAD_OFFSET_SEQ_ORDER 1 +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 94) #define BLOCK_LOAD_TABLE_SEQ_ORDER 2 +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 95) #define BLOCK_LOAD_TABLE_RR_ORDER 3 +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 96) +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 97) #define TABLE_TID(t) (t)->tid +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 98) #define TABLE_UID(t) (t)->uid +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 99) +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 100) // TYPES EXPOSED +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 101) typedef struct STsdb STsdb; +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 102) +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 103) typedef struct STsdbCfg { +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 104) int8_t precision; +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 105) int8_t update; +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 106) int8_t compression; +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 107) int32_t daysPerFile; +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 108) int32_t minRowsPerFileBlock; +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 109) int32_t maxRowsPerFileBlock; +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 110) int32_t keep; +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 111) int32_t keep1; +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 112) int32_t keep2; +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 113) uint64_t lruCacheSize; +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 114) SArray *retentions; +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 115) } STsdbCfg; +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 116) +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 117) +a038c466075 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-02-15 10:11:34 +0800 118) typedef struct { +35749cb3742 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-21 16:12:02 +0800 119) // TODO +35749cb3742 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-21 16:12:02 +0800 120) int32_t reserved; +35749cb3742 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-21 16:12:02 +0800 121) } STqCfg; +35749cb3742 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-21 16:12:02 +0800 122) +a038c466075 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-02-15 10:11:34 +0800 123) typedef struct { +7dbc861b4c1 source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-01-13 08:57:18 +0000 124) int32_t vgId; +5f2dc1401fe source/dnode/vnode/inc/vnode.h (dapan1121 2022-02-11 19:52:07 +0800 125) uint64_t dbId; +ed9709c3f0a source/dnode/vnode/inc/vnode.h (Shengliang Guan 2022-01-18 21:39:32 -0800 126) STfs *pTfs; +7dbc861b4c1 source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-01-13 08:57:18 +0000 127) uint64_t wsize; +7dbc861b4c1 source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-01-13 08:57:18 +0000 128) uint64_t ssize; +7dbc861b4c1 source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-01-13 08:57:18 +0000 129) uint64_t lsize; +7dbc861b4c1 source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-01-13 08:57:18 +0000 130) bool isHeapAllocator; +2ae35c3404c include/dnode/vnode/vnode.h (Hongze Cheng 2021-11-26 13:43:38 +0800 131) uint32_t ttl; +2ae35c3404c include/dnode/vnode/vnode.h (Hongze Cheng 2021-11-26 13:43:38 +0800 132) uint32_t keep; +82bcecc4ff5 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-02-18 16:59:33 +0800 133) int8_t streamMode; +7dbc861b4c1 source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-01-13 08:57:18 +0000 134) bool isWeak; +2ae35c3404c include/dnode/vnode/vnode.h (Hongze Cheng 2021-11-26 13:43:38 +0800 135) STsdbCfg tsdbCfg; +2ae35c3404c include/dnode/vnode/vnode.h (Hongze Cheng 2021-11-26 13:43:38 +0800 136) SMetaCfg metaCfg; +7dbc861b4c1 source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-01-13 08:57:18 +0000 137) STqCfg tqCfg; +7dbc861b4c1 source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-01-13 08:57:18 +0000 138) SWalCfg walCfg; +220fdfabe29 source/dnode/vnode/inc/vnode.h (Shengliang Guan 2022-03-21 19:08:25 +0800 139) SMsgCb msgCb; +09e6462c5fa source/dnode/vnode/inc/vnode.h (dapan1121 2022-03-03 09:09:11 +0800 140) uint32_t hashBegin; +09e6462c5fa source/dnode/vnode/inc/vnode.h (dapan1121 2022-03-03 09:09:11 +0800 141) uint32_t hashEnd; +913e8d70d87 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-09 10:49:42 +0800 142) int8_t hashMethod; +2ae35c3404c include/dnode/vnode/vnode.h (Hongze Cheng 2021-11-26 13:43:38 +0800 143) } SVnodeCfg; +993d28df0f6 include/server/vnode/vnode.h (Hongze Cheng 2021-11-07 15:58:32 +0800 144) +a038c466075 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-02-15 10:11:34 +0800 145) typedef struct { +5bb010ef4af source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-28 15:24:09 +0800 146) int64_t ver; +a038c466075 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-02-15 10:11:34 +0800 147) int64_t tbUid; +5bb010ef4af source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-28 15:24:09 +0800 148) SHashObj *tbIdHash; +246311d4fcf source/dnode/vnode/inc/vnode.h (Shengliang Guan 2022-02-16 15:27:19 +0800 149) const SSubmitReq *pMsg; +5bb010ef4af source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-28 15:24:09 +0800 150) SSubmitBlk *pBlock; +5bb010ef4af source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-28 15:24:09 +0800 151) SSubmitMsgIter msgIter; +5bb010ef4af source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-28 15:24:09 +0800 152) SSubmitBlkIter blkIter; +5bb010ef4af source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-28 15:24:09 +0800 153) SMeta *pVnodeMeta; +5bb010ef4af source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-28 15:24:09 +0800 154) SArray *pColIdList; // SArray +5bb010ef4af source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-28 15:24:09 +0800 155) int32_t sver; +5bb010ef4af source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-28 15:24:09 +0800 156) SSchemaWrapper *pSchemaWrapper; +5bb010ef4af source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-28 15:24:09 +0800 157) STSchema *pSchema; +35749cb3742 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-21 16:12:02 +0800 158) } STqReadHandle; +35749cb3742 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-21 16:12:02 +0800 159) +993d28df0f6 include/server/vnode/vnode.h (Hongze Cheng 2021-11-07 15:58:32 +0800 160) /* ------------------------ SVnode ------------------------ */ +757dea61705 include/dnode/vnode/vnode.h (Hongze Cheng 2021-11-29 14:06:16 +0800 161) /** +757dea61705 include/dnode/vnode/vnode.h (Hongze Cheng 2021-11-29 14:06:16 +0800 162) * @brief Initialize the vnode module +018661e1779 include/dnode/vnode/vnode.h (Hongze Cheng 2021-11-29 15:42:17 +0800 163) * +757dea61705 include/dnode/vnode/vnode.h (Hongze Cheng 2021-11-29 14:06:16 +0800 164) * @return int 0 for success and -1 for failure +757dea61705 include/dnode/vnode/vnode.h (Hongze Cheng 2021-11-29 14:06:16 +0800 165) */ +220fdfabe29 source/dnode/vnode/inc/vnode.h (Shengliang Guan 2022-03-21 19:08:25 +0800 166) int vnodeInit(); +757dea61705 include/dnode/vnode/vnode.h (Hongze Cheng 2021-11-29 14:06:16 +0800 167) +757dea61705 include/dnode/vnode/vnode.h (Hongze Cheng 2021-11-29 14:06:16 +0800 168) /** +0b6d32a3d92 include/dnode/vnode/vnode.h (Shengliang Guan 2022-01-11 19:35:40 -0800 169) * @brief Cleanup the vnode module +018661e1779 include/dnode/vnode/vnode.h (Hongze Cheng 2021-11-29 15:42:17 +0800 170) * +757dea61705 include/dnode/vnode/vnode.h (Hongze Cheng 2021-11-29 14:06:16 +0800 171) */ +0b6d32a3d92 include/dnode/vnode/vnode.h (Shengliang Guan 2022-01-11 19:35:40 -0800 172) void vnodeCleanup(); +757dea61705 include/dnode/vnode/vnode.h (Hongze Cheng 2021-11-29 14:06:16 +0800 173) +7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 174) /** +7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 175) * @brief Open a VNODE. +7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 176) * +7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 177) * @param path path of the vnode +3906f6a7073 include/dnode/vnode/vnode.h (Hongze Cheng 2021-11-22 15:39:05 +0800 178) * @param pVnodeCfg options of the vnode +7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 179) * @return SVnode* The vnode object +7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 180) */ +ab3378e0901 include/dnode/vnode/vnode.h (Shengliang Guan 2022-01-11 16:44:11 -0800 181) SVnode *vnodeOpen(const char *path, const SVnodeCfg *pVnodeCfg); +7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 182) +7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 183) /** +7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 184) * @brief Close a VNODE +7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 185) * +baac49c75b2 include/dnode/vnode/vnode.h (Hongze Cheng 2021-11-12 17:50:46 +0800 186) * @param pVnode The vnode object to close +7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 187) */ +7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 188) void vnodeClose(SVnode *pVnode); +7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 189) +7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 190) /** +7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 191) * @brief Destroy a VNODE. +7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 192) * +7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 193) * @param path Path of the VNODE. +7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 194) */ +7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 195) void vnodeDestroy(const char *path); +7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 196) +7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 197) /** +7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 198) * @brief Process an array of write messages. +7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 199) * +7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 200) * @param pVnode The vnode object. +7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 201) * @param pMsgs The array of SRpcMsg +7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 202) */ +50229512d32 source/dnode/vnode/inc/vnode.h (Shengliang Guan 2022-03-21 14:39:35 +0800 203) void vnodeProcessWMsgs(SVnode *pVnode, SArray *pMsgs); +7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 204) +7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 205) /** +7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 206) * @brief Apply a write request message. +7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 207) * +7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 208) * @param pVnode The vnode object. +7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 209) * @param pMsg The request message +15d9a46600d include/server/vnode/vnode.h (Hongze Cheng 2021-11-12 10:53:52 +0800 210) * @param pRsp The response message +7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 211) * @return int 0 for success, -1 for failure +7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 212) */ +7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 213) int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp); +7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 214) +6beee204d82 include/dnode/vnode/vnode.h (Liu Jicong 2021-12-21 20:07:32 +0800 215) /** +6beee204d82 include/dnode/vnode/vnode.h (Liu Jicong 2021-12-21 20:07:32 +0800 216) * @brief Process a consume message. +6beee204d82 include/dnode/vnode/vnode.h (Liu Jicong 2021-12-21 20:07:32 +0800 217) * +6beee204d82 include/dnode/vnode/vnode.h (Liu Jicong 2021-12-21 20:07:32 +0800 218) * @param pVnode The vnode object. +6beee204d82 include/dnode/vnode/vnode.h (Liu Jicong 2021-12-21 20:07:32 +0800 219) * @param pMsg The request message +6beee204d82 include/dnode/vnode/vnode.h (Liu Jicong 2021-12-21 20:07:32 +0800 220) * @param pRsp The response message +6beee204d82 include/dnode/vnode/vnode.h (Liu Jicong 2021-12-21 20:07:32 +0800 221) * @return int 0 for success, -1 for failure +6beee204d82 include/dnode/vnode/vnode.h (Liu Jicong 2021-12-21 20:07:32 +0800 222) */ +6beee204d82 include/dnode/vnode/vnode.h (Liu Jicong 2021-12-21 20:07:32 +0800 223) int vnodeProcessCMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp); +6beee204d82 include/dnode/vnode/vnode.h (Liu Jicong 2021-12-21 20:07:32 +0800 224) +7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 225) /** +7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 226) * @brief Process the sync request +7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 227) * +7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 228) * @param pVnode +7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 229) * @param pMsg +7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 230) * @param pRsp +7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 231) * @return int +7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 232) */ +7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 233) int vnodeProcessSyncReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp); +993d28df0f6 include/server/vnode/vnode.h (Hongze Cheng 2021-11-07 15:58:32 +0800 234) +293ad0bb066 include/dnode/vnode/vnode.h (Shengliang Guan 2021-12-21 16:15:38 +0800 235) /** +293ad0bb066 include/dnode/vnode/vnode.h (Shengliang Guan 2021-12-21 16:15:38 +0800 236) * @brief Process a query message. +293ad0bb066 include/dnode/vnode/vnode.h (Shengliang Guan 2021-12-21 16:15:38 +0800 237) * +293ad0bb066 include/dnode/vnode/vnode.h (Shengliang Guan 2021-12-21 16:15:38 +0800 238) * @param pVnode The vnode object. +293ad0bb066 include/dnode/vnode/vnode.h (Shengliang Guan 2021-12-21 16:15:38 +0800 239) * @param pMsg The request message +293ad0bb066 include/dnode/vnode/vnode.h (Shengliang Guan 2021-12-21 16:15:38 +0800 240) * @return int 0 for success, -1 for failure +293ad0bb066 include/dnode/vnode/vnode.h (Shengliang Guan 2021-12-21 16:15:38 +0800 241) */ +808efe80698 source/dnode/vnode/inc/vnode.h (Shengliang 2022-01-25 14:20:52 +0800 242) int vnodeProcessQueryMsg(SVnode *pVnode, SRpcMsg *pMsg); +293ad0bb066 include/dnode/vnode/vnode.h (Shengliang Guan 2021-12-21 16:15:38 +0800 243) +293ad0bb066 include/dnode/vnode/vnode.h (Shengliang Guan 2021-12-21 16:15:38 +0800 244) /** +293ad0bb066 include/dnode/vnode/vnode.h (Shengliang Guan 2021-12-21 16:15:38 +0800 245) * @brief Process a fetch message. +293ad0bb066 include/dnode/vnode/vnode.h (Shengliang Guan 2021-12-21 16:15:38 +0800 246) * +293ad0bb066 include/dnode/vnode/vnode.h (Shengliang Guan 2021-12-21 16:15:38 +0800 247) * @param pVnode The vnode object. +293ad0bb066 include/dnode/vnode/vnode.h (Shengliang Guan 2021-12-21 16:15:38 +0800 248) * @param pMsg The request message +293ad0bb066 include/dnode/vnode/vnode.h (Shengliang Guan 2021-12-21 16:15:38 +0800 249) * @return int 0 for success, -1 for failure +293ad0bb066 include/dnode/vnode/vnode.h (Shengliang Guan 2021-12-21 16:15:38 +0800 250) */ +a9ad7ebd100 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-29 18:58:15 +0800 251) int vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo); +293ad0bb066 include/dnode/vnode/vnode.h (Shengliang Guan 2021-12-21 16:15:38 +0800 252) +9001468b212 include/dnode/vnode/vnode.h (Hongze Cheng 2021-11-22 15:02:53 +0800 253) /* ------------------------ SVnodeCfg ------------------------ */ +7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 254) /** +7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 255) * @brief Initialize VNODE options. +7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 256) * +7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 257) * @param pOptions The options object to be initialized. It should not be NULL. +7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 258) */ +9001468b212 include/dnode/vnode/vnode.h (Hongze Cheng 2021-11-22 15:02:53 +0800 259) void vnodeOptionsInit(SVnodeCfg *pOptions); +7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 260) +7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 261) /** +7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 262) * @brief Clear VNODE options. +7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 263) * +7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 264) * @param pOptions Options to clear. +7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 265) */ +9001468b212 include/dnode/vnode/vnode.h (Hongze Cheng 2021-11-22 15:02:53 +0800 266) void vnodeOptionsClear(SVnodeCfg *pOptions); +993d28df0f6 include/server/vnode/vnode.h (Hongze Cheng 2021-11-07 15:58:32 +0800 267) +260aad808b4 source/dnode/vnode/inc/vnode.h (dapan1121 2022-03-11 19:45:34 +0800 268) int vnodeValidateTableHash(SVnodeCfg *pVnodeOptions, char *tableFName); +763eccf8aa4 source/dnode/vnode/inc/vnode.h (dapan1121 2022-03-10 19:05:58 +0800 269) +c8ee7ba9a7b include/server/vnode/vnode.h (Hongze Cheng 2021-11-09 14:36:53 +0800 270) /* ------------------------ FOR COMPILE ------------------------ */ +c8ee7ba9a7b include/server/vnode/vnode.h (Hongze Cheng 2021-11-09 14:36:53 +0800 271) +2f36662750f include/server/vnode/vnode.h (Shengliang Guan 2021-11-01 19:49:44 +0800 272) int32_t vnodeAlter(SVnode *pVnode, const SVnodeCfg *pCfg); +2f36662750f include/server/vnode/vnode.h (Shengliang Guan 2021-11-01 19:49:44 +0800 273) int32_t vnodeCompact(SVnode *pVnode); +2f36662750f include/server/vnode/vnode.h (Shengliang Guan 2021-11-01 19:49:44 +0800 274) int32_t vnodeSync(SVnode *pVnode); +dd3281c9d2f include/server/vnode/vnode.h (Shengliang Guan 2021-11-04 18:38:07 +0800 275) int32_t vnodeGetLoad(SVnode *pVnode, SVnodeLoad *pLoad); +2f09d49aa4c include/server/vnode/vnode.h (Shengliang Guan 2021-11-04 14:06:29 +0800 276) +a038c466075 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-02-15 10:11:34 +0800 277) /* ------------------------- TQ READ --------------------------- */ +35749cb3742 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-21 16:12:02 +0800 278) +913e8d70d87 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-09 10:49:42 +0800 279) enum { +913e8d70d87 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-09 10:49:42 +0800 280) TQ_STREAM_TOKEN__DATA = 1, +913e8d70d87 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-09 10:49:42 +0800 281) TQ_STREAM_TOKEN__WATERMARK, +913e8d70d87 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-09 10:49:42 +0800 282) TQ_STREAM_TOKEN__CHECKPOINT, +913e8d70d87 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-09 10:49:42 +0800 283) }; +913e8d70d87 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-09 10:49:42 +0800 284) +913e8d70d87 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-09 10:49:42 +0800 285) typedef struct { +913e8d70d87 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-09 10:49:42 +0800 286) int8_t type; +913e8d70d87 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-09 10:49:42 +0800 287) int8_t reserved[7]; +913e8d70d87 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-09 10:49:42 +0800 288) union { +913e8d70d87 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-09 10:49:42 +0800 289) void *data; +913e8d70d87 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-09 10:49:42 +0800 290) int64_t wmTs; +913e8d70d87 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-09 10:49:42 +0800 291) int64_t checkpointId; +913e8d70d87 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-09 10:49:42 +0800 292) }; +913e8d70d87 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-09 10:49:42 +0800 293) } STqStreamToken; +913e8d70d87 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-09 10:49:42 +0800 294) +5bb010ef4af source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-28 15:24:09 +0800 295) STqReadHandle *tqInitSubmitMsgScanner(SMeta *pMeta); +35749cb3742 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-21 16:12:02 +0800 296) +5bb010ef4af source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-28 15:24:09 +0800 297) static FORCE_INLINE void tqReadHandleSetColIdList(STqReadHandle *pReadHandle, SArray *pColIdList) { +a1c6c94c0b3 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-21 19:00:09 +0800 298) pReadHandle->pColIdList = pColIdList; +a1c6c94c0b3 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-21 19:00:09 +0800 299) } +a1c6c94c0b3 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-21 19:00:09 +0800 300) +a038c466075 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-02-15 10:11:34 +0800 301) // static FORCE_INLINE void tqReadHandleSetTbUid(STqReadHandle* pHandle, int64_t tbUid) { +a038c466075 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-02-15 10:11:34 +0800 302) // pHandle->tbUid = tbUid; +60a1ae8ce4c source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-28 13:31:46 +0800 303) //} +35749cb3742 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-21 16:12:02 +0800 304) +5bb010ef4af source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-28 15:24:09 +0800 305) static FORCE_INLINE int tqReadHandleSetTbUidList(STqReadHandle *pHandle, const SArray *tbUidList) { +b7788aca04f source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-02 16:22:43 +0800 306) if (pHandle->tbIdHash) { +b7788aca04f source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-02 16:22:43 +0800 307) taosHashClear(pHandle->tbIdHash); +b7788aca04f source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-02 16:22:43 +0800 308) } +b7788aca04f source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-02 16:22:43 +0800 309) +a038c466075 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-02-15 10:11:34 +0800 310) pHandle->tbIdHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_NO_LOCK); +963fb9b9f61 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-27 18:05:23 +0800 311) if (pHandle->tbIdHash == NULL) { +36aedfbb7cd source/dnode/vnode/inc/vnode.h (Haojun Liao 2022-02-17 15:24:00 +0800 312) terrno = TSDB_CODE_OUT_OF_MEMORY; +963fb9b9f61 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-27 18:05:23 +0800 313) return -1; +963fb9b9f61 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-27 18:05:23 +0800 314) } +36aedfbb7cd source/dnode/vnode/inc/vnode.h (Haojun Liao 2022-02-17 15:24:00 +0800 315) +963fb9b9f61 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-27 18:05:23 +0800 316) for (int i = 0; i < taosArrayGetSize(tbUidList); i++) { +5bb010ef4af source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-28 15:24:09 +0800 317) int64_t *pKey = (int64_t *)taosArrayGet(tbUidList, i); +963fb9b9f61 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-27 18:05:23 +0800 318) taosHashPut(pHandle->tbIdHash, pKey, sizeof(int64_t), NULL, 0); +963fb9b9f61 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-27 18:05:23 +0800 319) } +36aedfbb7cd source/dnode/vnode/inc/vnode.h (Haojun Liao 2022-02-17 15:24:00 +0800 320) +963fb9b9f61 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-27 18:05:23 +0800 321) return 0; +963fb9b9f61 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-27 18:05:23 +0800 322) } +963fb9b9f61 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-27 18:05:23 +0800 323) +b7788aca04f source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-02 16:22:43 +0800 324) static FORCE_INLINE int tqReadHandleAddTbUidList(STqReadHandle *pHandle, const SArray *tbUidList) { +b7788aca04f source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-02 16:22:43 +0800 325) if (pHandle->tbIdHash == NULL) { +b7788aca04f source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-02 16:22:43 +0800 326) pHandle->tbIdHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_NO_LOCK); +b7788aca04f source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-02 16:22:43 +0800 327) if (pHandle->tbIdHash == NULL) { +b7788aca04f source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-02 16:22:43 +0800 328) terrno = TSDB_CODE_OUT_OF_MEMORY; +b7788aca04f source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-02 16:22:43 +0800 329) return -1; +b7788aca04f source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-02 16:22:43 +0800 330) } +b7788aca04f source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-02 16:22:43 +0800 331) } +b7788aca04f source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-02 16:22:43 +0800 332) +b7788aca04f source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-02 16:22:43 +0800 333) for (int i = 0; i < taosArrayGetSize(tbUidList); i++) { +b7788aca04f source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-02 16:22:43 +0800 334) int64_t *pKey = (int64_t *)taosArrayGet(tbUidList, i); +b7788aca04f source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-02 16:22:43 +0800 335) taosHashPut(pHandle->tbIdHash, pKey, sizeof(int64_t), NULL, 0); +b7788aca04f source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-02 16:22:43 +0800 336) } +b7788aca04f source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-02 16:22:43 +0800 337) +b7788aca04f source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-02 16:22:43 +0800 338) return 0; +b7788aca04f source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-02 16:22:43 +0800 339) } +b7788aca04f source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-02 16:22:43 +0800 340) +7ee6657cf72 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-02-21 10:48:23 +0800 341) int32_t tqReadHandleSetMsg(STqReadHandle *pHandle, SSubmitReq *pMsg, int64_t ver); +7ee6657cf72 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-02-21 10:48:23 +0800 342) bool tqNextDataBlock(STqReadHandle *pHandle); +7ee6657cf72 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-02-21 10:48:23 +0800 343) int tqRetrieveDataBlockInfo(STqReadHandle *pHandle, SDataBlockInfo *pBlockInfo); +35749cb3742 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-21 16:12:02 +0800 344) // return SArray +5bb010ef4af source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-28 15:24:09 +0800 345) SArray *tqRetrieveDataBlock(STqReadHandle *pHandle); +35749cb3742 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-21 16:12:02 +0800 346) +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 347) // meta.h +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 348) SMeta *metaOpen(const char *path, const SMetaCfg *pMetaCfg, SMemAllocatorFactory *pMAF); +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 349) void metaClose(SMeta *pMeta); +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 350) void metaRemove(const char *path); +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 351) int metaCreateTable(SMeta *pMeta, STbCfg *pTbCfg); +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 352) int metaDropTable(SMeta *pMeta, tb_uid_t uid); +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 353) int metaCommit(SMeta *pMeta); +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 354) int32_t metaCreateTSma(SMeta *pMeta, SSmaCfg *pCfg); +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 355) int32_t metaDropTSma(SMeta *pMeta, int64_t indexUid); +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 356) STbCfg *metaGetTbInfoByUid(SMeta *pMeta, tb_uid_t uid); +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 357) STbCfg *metaGetTbInfoByName(SMeta *pMeta, char *tbname, tb_uid_t *uid); +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 358) SSchemaWrapper *metaGetTableSchema(SMeta *pMeta, tb_uid_t uid, int32_t sver, bool isinline); +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 359) STSchema *metaGetTbTSchema(SMeta *pMeta, tb_uid_t uid, int32_t sver); +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 360) STSma *metaGetSmaInfoByIndex(SMeta *pMeta, int64_t indexUid); +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 361) STSmaWrapper *metaGetSmaInfoByTable(SMeta *pMeta, tb_uid_t uid); +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 362) SArray *metaGetSmaTbUids(SMeta *pMeta, bool isDup); +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 363) int metaGetTbNum(SMeta *pMeta); +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 364) SMTbCursor *metaOpenTbCursor(SMeta *pMeta); +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 365) void metaCloseTbCursor(SMTbCursor *pTbCur); +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 366) char *metaTbCursorNext(SMTbCursor *pTbCur); +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 367) SMCtbCursor *metaOpenCtbCursor(SMeta *pMeta, tb_uid_t uid); +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 368) void metaCloseCtbCurosr(SMCtbCursor *pCtbCur); +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 369) tb_uid_t metaCtbCursorNext(SMCtbCursor *pCtbCur); +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 370) +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 371) SMSmaCursor *metaOpenSmaCursor(SMeta *pMeta, tb_uid_t uid); +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 372) void metaCloseSmaCurosr(SMSmaCursor *pSmaCur); +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 373) const char *metaSmaCursorNext(SMSmaCursor *pSmaCur); +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 374) +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 375) // Options +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 376) void metaOptionsInit(SMetaCfg *pMetaCfg); +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 377) void metaOptionsClear(SMetaCfg *pMetaCfg); +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 378) +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 379) // query condition to build multi-table data block iterator +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 380) // STsdb +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 381) STsdb *tsdbOpen(const char *path, int32_t vgId, const STsdbCfg *pTsdbCfg, SMemAllocatorFactory *pMAF, SMeta *pMeta, STfs *pTfs); +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 382) void tsdbClose(STsdb *); +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 383) void tsdbRemove(const char *path); +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 384) int tsdbInsertData(STsdb *pTsdb, SSubmitReq *pMsg, SSubmitRsp *pRsp); +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 385) int tsdbPrepareCommit(STsdb *pTsdb); +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 386) int tsdbCommit(STsdb *pTsdb); +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 387) +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 388) +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 389) int32_t tsdbInitSma(STsdb *pTsdb); +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 390) int32_t tsdbCreateTSma(STsdb *pTsdb, char *pMsg); +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 391) int32_t tsdbDropTSma(STsdb *pTsdb, char *pMsg); +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 392) /** +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 393) * @brief When submit msg received, update the relative expired window synchronously. +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 394) * +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 395) * @param pTsdb +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 396) * @param msg +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 397) * @return int32_t +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 398) */ +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 399) int32_t tsdbUpdateSmaWindow(STsdb *pTsdb, SSubmitReq *pMsg); +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 400) +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 401) /** +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 402) * @brief Insert tSma(Time-range-wise SMA) data from stream computing engine +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 403) * +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 404) * @param pTsdb +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 405) * @param indexUid +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 406) * @param msg +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 407) * @return int32_t +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 408) */ +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 409) int32_t tsdbInsertTSmaData(STsdb *pTsdb, int64_t indexUid, const char *msg); +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 410) +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 411) /** +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 412) * @brief Drop tSma data and local cache. +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 413) * +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 414) * @param pTsdb +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 415) * @param indexUid +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 416) * @return int32_t +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 417) */ +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 418) int32_t tsdbDropTSmaData(STsdb *pTsdb, int64_t indexUid); +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 419) +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 420) /** +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 421) * @brief Insert RSma(Rollup SMA) data. +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 422) * +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 423) * @param pTsdb +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 424) * @param msg +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 425) * @return int32_t +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 426) */ +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 427) int32_t tsdbInsertRSmaData(STsdb *pTsdb, char *msg); +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 428) +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 429) // TODO: This is the basic params, and should wrap the params to a queryHandle. +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 430) /** +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 431) * @brief Get tSma(Time-range-wise SMA) data. +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 432) * +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 433) * @param pTsdb +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 434) * @param pData +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 435) * @param indexUid +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 436) * @param querySKey +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 437) * @param nMaxResult +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 438) * @return int32_t +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 439) */ +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 440) int32_t tsdbGetTSmaData(STsdb *pTsdb, char *pData, int64_t indexUid, TSKEY querySKey, int32_t nMaxResult); +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 441) +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 442) // STsdbCfg +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 443) int tsdbOptionsInit(STsdbCfg *); +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 444) void tsdbOptionsClear(STsdbCfg *); +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 445) +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 446) typedef void* tsdbReaderT; +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 447) +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 448) /** +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 449) * Get the data block iterator, starting from position according to the query condition +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 450) * +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 451) * @param tsdb tsdb handle +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 452) * @param pCond query condition, including time window, result set order, and basic required columns for each block +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 453) * @param tableInfoGroup table object list in the form of set, grouped into different sets according to the +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 454) * group by condition +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 455) * @param qinfo query info handle from query processor +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 456) * @return +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 457) */ +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 458) tsdbReaderT *tsdbQueryTables(STsdb *tsdb, STsdbQueryCond *pCond, STableGroupInfo *tableInfoGroup, uint64_t qId, uint64_t taskId); +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 459) +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 460) /** +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 461) * Get the last row of the given query time window for all the tables in STableGroupInfo object. +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 462) * Note that only one data block with only row will be returned while invoking retrieve data block function for +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 463) * all tables in this group. +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 464) * +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 465) * @param tsdb tsdb handle +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 466) * @param pCond query condition, including time window, result set order, and basic required columns for each block +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 467) * @param tableInfo table list. +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 468) * @return +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 469) */ +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 470) //tsdbReaderT tsdbQueryLastRow(STsdbRepo *tsdb, STsdbQueryCond *pCond, STableGroupInfo *tableInfo, uint64_t qId, +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 471) // SMemRef *pRef); +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 472) +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 473) +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 474) tsdbReaderT tsdbQueryCacheLast(STsdb *tsdb, STsdbQueryCond *pCond, STableGroupInfo *groupList, uint64_t qId, void* pMemRef); +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 475) +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 476) int32_t tsdbGetFileBlocksDistInfo(tsdbReaderT* pReader, STableBlockDistInfo* pTableBlockInfo); +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 477) +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 478) bool isTsdbCacheLastRow(tsdbReaderT* pReader); +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 479) +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 480) /** +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 481) * +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 482) * @param tsdb +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 483) * @param uid +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 484) * @param skey +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 485) * @param pTagCond +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 486) * @param len +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 487) * @param tagNameRelType +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 488) * @param tbnameCond +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 489) * @param pGroupInfo +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 490) * @param pColIndex +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 491) * @param numOfCols +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 492) * @param reqId +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 493) * @return +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 494) */ +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 495) int32_t tsdbQuerySTableByTagCond(void* pMeta, uint64_t uid, TSKEY skey, const char* pTagCond, size_t len, +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 496) int16_t tagNameRelType, const char* tbnameCond, STableGroupInfo* pGroupInfo, +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 497) SColIndex* pColIndex, int32_t numOfCols, uint64_t reqId, uint64_t taskId); +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 498) /** +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 499) * get num of rows in mem table +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 500) * +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 501) * @param pHandle +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 502) * @return row size +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 503) */ +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 504) +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 505) int64_t tsdbGetNumOfRowsInMemTable(tsdbReaderT* pHandle); +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 506) +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 507) /** +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 508) * move to next block if exists +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 509) * +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 510) * @param pTsdbReadHandle +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 511) * @return +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 512) */ +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 513) bool tsdbNextDataBlock(tsdbReaderT pTsdbReadHandle); +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 514) +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 515) /** +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 516) * Get current data block information +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 517) * +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 518) * @param pTsdbReadHandle +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 519) * @param pBlockInfo +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 520) * @return +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 521) */ +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 522) void tsdbRetrieveDataBlockInfo(tsdbReaderT *pTsdbReadHandle, SDataBlockInfo *pBlockInfo); +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 523) +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 524) /** +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 525) * +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 526) * Get the pre-calculated information w.r.t. current data block. +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 527) * +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 528) * In case of data block in cache, the pBlockStatis will always be NULL. +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 529) * If a block is not completed loaded from disk, the pBlockStatis will be NULL. +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 530) +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 531) * @pBlockStatis the pre-calculated value for current data blocks. if the block is a cache block, always return 0 +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 532) * @return +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 533) */ +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 534) int32_t tsdbRetrieveDataBlockStatisInfo(tsdbReaderT *pTsdbReadHandle, SDataStatis **pBlockStatis); +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 535) +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 536) /** +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 537) * +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 538) * The query condition with primary timestamp is passed to iterator during its constructor function, +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 539) * the returned data block must be satisfied with the time window condition in any cases, +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 540) * which means the SData data block is not actually the completed disk data blocks. +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 541) * +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 542) * @param pTsdbReadHandle query handle +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 543) * @param pColumnIdList required data columns id list +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 544) * @return +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 545) */ +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 546) SArray *tsdbRetrieveDataBlock(tsdbReaderT *pTsdbReadHandle, SArray *pColumnIdList); +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 547) +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 548) /** +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 549) * destroy the created table group list, which is generated by tag query +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 550) * @param pGroupList +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 551) */ +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 552) void tsdbDestroyTableGroup(STableGroupInfo *pGroupList); +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 553) +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 554) /** +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 555) * create the table group result including only one table, used to handle the normal table query +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 556) * +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 557) * @param tsdb tsdbHandle +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 558) * @param uid table uid +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 559) * @param pGroupInfo the generated result +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 560) * @return +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 561) */ +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 562) int32_t tsdbGetOneTableGroup(void *pMeta, uint64_t uid, TSKEY startKey, STableGroupInfo *pGroupInfo); +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 563) +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 564) /** +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 565) * +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 566) * @param tsdb +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 567) * @param pTableIdList +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 568) * @param pGroupInfo +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 569) * @return +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 570) */ +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 571) int32_t tsdbGetTableGroupFromIdList(STsdb *tsdb, SArray *pTableIdList, STableGroupInfo *pGroupInfo); +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 572) +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 573) /** +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 574) * clean up the query handle +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 575) * @param queryHandle +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 576) */ +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 577) void tsdbCleanupReadHandle(tsdbReaderT queryHandle); +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 578) +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 579) int32_t tdScanAndConvertSubmitMsg(SSubmitReq *pMsg); +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 580) +6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 581) +ce7a1600eb4 include/server/vnode/vnode.h (Shengliang Guan 2021-09-22 20:29:24 +0800 582) #ifdef __cplusplus +ce7a1600eb4 include/server/vnode/vnode.h (Shengliang Guan 2021-09-22 20:29:24 +0800 583) } +ce7a1600eb4 include/server/vnode/vnode.h (Shengliang Guan 2021-09-22 20:29:24 +0800 584) #endif +ce7a1600eb4 include/server/vnode/vnode.h (Shengliang Guan 2021-09-22 20:29:24 +0800 585) +daafc0feb7f include/server/vnode/vnode.h (Shengliang Guan 2021-09-29 19:26:11 +0800 586) #endif /*_TD_VNODE_H_*/ diff --git a/source/libs/qworker/inc/qworkerInt.h b/source/libs/qworker/inc/qworkerInt.h index c4736f75f1..bee2485f17 100644 --- a/source/libs/qworker/inc/qworkerInt.h +++ b/source/libs/qworker/inc/qworkerInt.h @@ -120,8 +120,8 @@ typedef struct SQWTaskCtx { int8_t events[QW_EVENT_MAX]; - qTaskInfo_t taskHandle; - DataSinkHandle sinkHandle; + void *taskHandle; + void *sinkHandle; } SQWTaskCtx; typedef struct SQWSchStatus { diff --git a/source/libs/qworker/src/qworkerMsg.c b/source/libs/qworker/src/qworkerMsg.c index 15a42d3a31..c795bf9445 100644 --- a/source/libs/qworker/src/qworkerMsg.c +++ b/source/libs/qworker/src/qworkerMsg.c @@ -1,18 +1,17 @@ -#include "qworker.h" -#include "tcommon.h" +#include "qworkerMsg.h" +#include "dataSinkMgt.h" #include "executor.h" #include "planner.h" #include "query.h" +#include "qworker.h" #include "qworkerInt.h" -#include "qworkerMsg.h" +#include "tcommon.h" #include "tmsg.h" #include "tname.h" -#include "dataSinkMgt.h" - int32_t qwMallocFetchRsp(int32_t length, SRetrieveTableRsp **rsp) { int32_t msgSize = sizeof(SRetrieveTableRsp) + length; - + SRetrieveTableRsp *pRsp = (SRetrieveTableRsp *)rpcMallocCont(msgSize); if (NULL == pRsp) { qError("rpcMallocCont %d failed", msgSize); @@ -26,11 +25,9 @@ int32_t qwMallocFetchRsp(int32_t length, SRetrieveTableRsp **rsp) { return TSDB_CODE_SUCCESS; } - - void qwBuildFetchRsp(void *msg, SOutputData *input, int32_t len, bool qComplete) { SRetrieveTableRsp *rsp = (SRetrieveTableRsp *)msg; - + rsp->useconds = htobe64(input->useconds); rsp->completed = qComplete; rsp->precision = input->precision; @@ -39,7 +36,6 @@ void qwBuildFetchRsp(void *msg, SOutputData *input, int32_t len, bool qComplete) rsp->numOfRows = htonl(input->numOfRows); } - void qwFreeFetchRsp(void *msg) { if (msg) { rpcFreeCont(msg); @@ -48,18 +44,19 @@ void qwFreeFetchRsp(void *msg) { int32_t qwBuildAndSendQueryRsp(SQWConnInfo *pConn, int32_t code) { SQueryTableRsp rsp = {.code = code}; - + int32_t contLen = tSerializeSQueryTableRsp(NULL, 0, &rsp); - void *msg = rpcMallocCont(contLen); + void * msg = rpcMallocCont(contLen); tSerializeSQueryTableRsp(msg, contLen, &rsp); SRpcMsg rpcRsp = { - .msgType = TDMT_VND_QUERY_RSP, - .handle = pConn->handle, - .ahandle = pConn->ahandle, - .pCont = msg, - .contLen = contLen, - .code = code, + .msgType = TDMT_VND_QUERY_RSP, + .handle = pConn->handle, + .ahandle = pConn->ahandle, + .refId = pConn->refId, + .pCont = msg, + .contLen = contLen, + .code = code, }; tmsgSendRsp(&rpcRsp); @@ -72,12 +69,13 @@ int32_t qwBuildAndSendReadyRsp(SQWConnInfo *pConn, int32_t code) { pRsp->code = code; SRpcMsg rpcRsp = { - .msgType = TDMT_VND_RES_READY_RSP, - .handle = pConn->handle, - .ahandle = NULL, - .pCont = pRsp, - .contLen = sizeof(*pRsp), - .code = code, + .msgType = TDMT_VND_RES_READY_RSP, + .handle = pConn->handle, + .refId = pConn->refId, + .ahandle = NULL, + .pCont = pRsp, + .contLen = sizeof(*pRsp), + .code = code, }; tmsgSendRsp(&rpcRsp); @@ -85,20 +83,21 @@ int32_t qwBuildAndSendReadyRsp(SQWConnInfo *pConn, int32_t code) { return TSDB_CODE_SUCCESS; } -int32_t qwBuildAndSendExplainRsp(SQWConnInfo *pConn, SExplainExecInfo *execInfo, int32_t num) { +int32_t qwBuildAndSendExplainRsp(SQWConnInfo *pConn, SExplainExecInfo *execInfo, int32_t num) { SExplainRsp rsp = {.numOfPlans = num, .subplanInfo = execInfo}; int32_t contLen = tSerializeSExplainRsp(NULL, 0, &rsp); - void *pRsp = rpcMallocCont(contLen); + void * pRsp = rpcMallocCont(contLen); tSerializeSExplainRsp(pRsp, contLen, &rsp); SRpcMsg rpcRsp = { - .msgType = TDMT_VND_EXPLAIN_RSP, - .handle = pConn->handle, - .ahandle = pConn->ahandle, - .pCont = pRsp, - .contLen = contLen, - .code = 0, + .msgType = TDMT_VND_EXPLAIN_RSP, + .handle = pConn->handle, + .ahandle = pConn->ahandle, + .refId = pConn->refId, + .pCont = pRsp, + .contLen = contLen, + .code = 0, }; tmsgSendRsp(&rpcRsp); @@ -108,16 +107,17 @@ int32_t qwBuildAndSendExplainRsp(SQWConnInfo *pConn, SExplainExecInfo *execInfo, int32_t qwBuildAndSendHbRsp(SQWConnInfo *pConn, SSchedulerHbRsp *pStatus, int32_t code) { int32_t contLen = tSerializeSSchedulerHbRsp(NULL, 0, pStatus); - void *pRsp = rpcMallocCont(contLen); + void * pRsp = rpcMallocCont(contLen); tSerializeSSchedulerHbRsp(pRsp, contLen, pStatus); SRpcMsg rpcRsp = { - .msgType = TDMT_VND_QUERY_HEARTBEAT_RSP, - .handle = pConn->handle, - .ahandle = pConn->ahandle, - .pCont = pRsp, - .contLen = contLen, - .code = code, + .msgType = TDMT_VND_QUERY_HEARTBEAT_RSP, + .handle = pConn->handle, + .ahandle = pConn->ahandle, + .refId = pConn->refId, + .pCont = pRsp, + .contLen = contLen, + .code = code, }; tmsgSendRsp(&rpcRsp); @@ -133,12 +133,13 @@ int32_t qwBuildAndSendFetchRsp(SQWConnInfo *pConn, SRetrieveTableRsp *pRsp, int3 } SRpcMsg rpcRsp = { - .msgType = TDMT_VND_FETCH_RSP, - .handle = pConn->handle, - .ahandle = pConn->ahandle, - .pCont = pRsp, - .contLen = sizeof(*pRsp) + dataLength, - .code = code, + .msgType = TDMT_VND_FETCH_RSP, + .handle = pConn->handle, + .ahandle = pConn->ahandle, + .refId = pConn->refId, + .pCont = pRsp, + .contLen = sizeof(*pRsp) + dataLength, + .code = code, }; tmsgSendRsp(&rpcRsp); @@ -151,12 +152,13 @@ int32_t qwBuildAndSendCancelRsp(SQWConnInfo *pConn, int32_t code) { pRsp->code = code; SRpcMsg rpcRsp = { - .msgType = TDMT_VND_CANCEL_TASK_RSP, - .handle = pConn->handle, - .ahandle = pConn->ahandle, - .pCont = pRsp, - .contLen = sizeof(*pRsp), - .code = code, + .msgType = TDMT_VND_CANCEL_TASK_RSP, + .handle = pConn->handle, + .ahandle = pConn->ahandle, + .refId = pConn->refId, + .pCont = pRsp, + .contLen = sizeof(*pRsp), + .code = code, }; tmsgSendRsp(&rpcRsp); @@ -168,12 +170,13 @@ int32_t qwBuildAndSendDropRsp(SQWConnInfo *pConn, int32_t code) { pRsp->code = code; SRpcMsg rpcRsp = { - .msgType = TDMT_VND_DROP_TASK_RSP, - .handle = pConn->handle, - .ahandle = pConn->ahandle, - .pCont = pRsp, - .contLen = sizeof(*pRsp), - .code = code, + .msgType = TDMT_VND_DROP_TASK_RSP, + .handle = pConn->handle, + .ahandle = pConn->ahandle, + .refId = pConn->refId, + .pCont = pRsp, + .contLen = sizeof(*pRsp), + .code = code, }; tmsgSendRsp(&rpcRsp); @@ -191,7 +194,7 @@ int32_t qwBuildAndSendShowRsp(SRpcMsg *pMsg, int32_t code) { return -1; } - col_id_t cols = 0; + col_id_t cols = 0; SSchema *pSchema = showRsp.tableMeta.pSchemas; const SSchema *s = tGetTbnameColumnSchema(); @@ -220,12 +223,13 @@ int32_t qwBuildAndSendShowRsp(SRpcMsg *pMsg, int32_t code) { showRsp.tableMeta.numOfColumns = cols; int32_t bufLen = tSerializeSShowRsp(NULL, 0, &showRsp); - void *pBuf = rpcMallocCont(bufLen); + void * pBuf = rpcMallocCont(bufLen); tSerializeSShowRsp(pBuf, bufLen, &showRsp); SRpcMsg rpcMsg = { .handle = pMsg->handle, .ahandle = pMsg->ahandle, + .refId = pMsg->refId, .pCont = pBuf, .contLen = bufLen, .code = code, @@ -235,17 +239,18 @@ int32_t qwBuildAndSendShowRsp(SRpcMsg *pMsg, int32_t code) { return TSDB_CODE_SUCCESS; } -int32_t qwBuildAndSendShowFetchRsp(SRpcMsg *pMsg, SVShowTablesFetchReq* pFetchReq) { +int32_t qwBuildAndSendShowFetchRsp(SRpcMsg *pMsg, SVShowTablesFetchReq *pFetchReq) { SVShowTablesFetchRsp *pRsp = (SVShowTablesFetchRsp *)rpcMallocCont(sizeof(SVShowTablesFetchRsp)); - int32_t handle = htonl(pFetchReq->id); + int32_t handle = htonl(pFetchReq->id); pRsp->numOfRows = 0; SRpcMsg rpcMsg = { - .handle = pMsg->handle, + .handle = pMsg->handle, .ahandle = pMsg->ahandle, - .pCont = pRsp, + .refId = pMsg->refId, + .pCont = pRsp, .contLen = sizeof(*pRsp), - .code = 0, + .code = 0, }; tmsgSendRsp(&rpcMsg); @@ -253,7 +258,7 @@ int32_t qwBuildAndSendShowFetchRsp(SRpcMsg *pMsg, SVShowTablesFetchReq* pFetchRe } int32_t qwBuildAndSendCQueryMsg(QW_FPARAMS_DEF, SQWConnInfo *pConn) { - SQueryContinueReq * req = (SQueryContinueReq *)rpcMallocCont(sizeof(SQueryContinueReq)); + SQueryContinueReq *req = (SQueryContinueReq *)rpcMallocCont(sizeof(SQueryContinueReq)); if (NULL == req) { QW_SCH_TASK_ELOG("rpcMallocCont %d failed", (int32_t)sizeof(SQueryContinueReq)); QW_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); @@ -265,12 +270,13 @@ int32_t qwBuildAndSendCQueryMsg(QW_FPARAMS_DEF, SQWConnInfo *pConn) { req->taskId = tId; SRpcMsg pNewMsg = { - .handle = pConn->handle, - .ahandle = pConn->ahandle, - .msgType = TDMT_VND_QUERY_CONTINUE, - .pCont = req, - .contLen = sizeof(SQueryContinueReq), - .code = 0, + .handle = pConn->handle, + .ahandle = pConn->ahandle, + .msgType = TDMT_VND_QUERY_CONTINUE, + .refId = pConn->refId, + .pCont = req, + .contLen = sizeof(SQueryContinueReq), + .code = 0, }; int32_t code = tmsgPutToQueue(&mgmt->msgCb, QUERY_QUEUE, &pNewMsg); @@ -285,55 +291,54 @@ int32_t qwBuildAndSendCQueryMsg(QW_FPARAMS_DEF, SQWConnInfo *pConn) { return TSDB_CODE_SUCCESS; } - int32_t qwRegisterBrokenLinkArg(QW_FPARAMS_DEF, SQWConnInfo *pConn) { - STaskDropReq * req = (STaskDropReq *)rpcMallocCont(sizeof(STaskDropReq)); + STaskDropReq *req = (STaskDropReq *)rpcMallocCont(sizeof(STaskDropReq)); if (NULL == req) { QW_SCH_TASK_ELOG("rpcMallocCont %d failed", (int32_t)sizeof(STaskDropReq)); QW_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); - } + } req->header.vgId = htonl(mgmt->nodeId); req->sId = htobe64(sId); req->queryId = htobe64(qId); req->taskId = htobe64(tId); req->refId = htobe64(rId); - + SRpcMsg pMsg = { - .handle = pConn->handle, - .ahandle = pConn->ahandle, - .msgType = TDMT_VND_DROP_TASK, - .pCont = req, - .contLen = sizeof(STaskDropReq), - .code = TSDB_CODE_RPC_NETWORK_UNAVAIL, + .handle = pConn->handle, + .ahandle = pConn->ahandle, + .refId = pConn->refId, + .msgType = TDMT_VND_DROP_TASK, + .pCont = req, + .contLen = sizeof(STaskDropReq), + .code = TSDB_CODE_RPC_NETWORK_UNAVAIL, }; - + tmsgRegisterBrokenLinkArg(&mgmt->msgCb, &pMsg); return TSDB_CODE_SUCCESS; } - int32_t qWorkerProcessQueryMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg) { if (NULL == node || NULL == qWorkerMgmt || NULL == pMsg) { QW_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); } - int32_t code = 0; + int32_t code = 0; SSubQueryMsg *msg = pMsg->pCont; SQWorkerMgmt *mgmt = (SQWorkerMgmt *)qWorkerMgmt; - + if (NULL == msg || pMsg->contLen <= sizeof(*msg)) { QW_ELOG("invalid query msg, msg:%p, msgLen:%d", msg, pMsg->contLen); QW_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); } - msg->sId = be64toh(msg->sId); + msg->sId = be64toh(msg->sId); msg->queryId = be64toh(msg->queryId); - msg->taskId = be64toh(msg->taskId); - msg->refId = be64toh(msg->refId); - msg->phyLen = ntohl(msg->phyLen); - msg->sqlLen = ntohl(msg->sqlLen); + msg->taskId = be64toh(msg->taskId); + msg->refId = be64toh(msg->refId); + msg->phyLen = ntohl(msg->phyLen); + msg->sqlLen = ntohl(msg->sqlLen); uint64_t sId = msg->sId; uint64_t qId = msg->queryId; @@ -343,8 +348,9 @@ int32_t qWorkerProcessQueryMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg) { SQWMsg qwMsg = {.node = node, .msg = msg->msg + msg->sqlLen, .msgLen = msg->phyLen}; qwMsg.connInfo.handle = pMsg->handle; qwMsg.connInfo.ahandle = pMsg->ahandle; + qwMsg.connInfo.refId = pMsg->refId; - char* sql = strndup(msg->msg, msg->sqlLen); + char *sql = strndup(msg->msg, msg->sqlLen); QW_SCH_TASK_DLOG("processQuery start, node:%p, handle:%p, sql:%s", node, pMsg->handle, sql); taosMemoryFreeClear(sql); @@ -352,17 +358,17 @@ int32_t qWorkerProcessQueryMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg) { QW_SCH_TASK_DLOG("processQuery end, node:%p", node); - return TSDB_CODE_SUCCESS; + return TSDB_CODE_SUCCESS; } int32_t qWorkerProcessCQueryMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg) { - int32_t code = 0; - int8_t status = 0; - bool queryDone = false; + int32_t code = 0; + int8_t status = 0; + bool queryDone = false; SQueryContinueReq *msg = (SQueryContinueReq *)pMsg->pCont; - bool needStop = false; - SQWTaskCtx *handles = NULL; - SQWorkerMgmt *mgmt = (SQWorkerMgmt *)qWorkerMgmt; + bool needStop = false; + SQWTaskCtx * handles = NULL; + SQWorkerMgmt * mgmt = (SQWorkerMgmt *)qWorkerMgmt; if (NULL == msg || pMsg->contLen < sizeof(*msg)) { QW_ELOG("invalid cquery msg, msg:%p, msgLen:%d", msg, pMsg->contLen); @@ -372,11 +378,12 @@ int32_t qWorkerProcessCQueryMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg) { uint64_t sId = msg->sId; uint64_t qId = msg->queryId; uint64_t tId = msg->taskId; - int64_t rId = 0; + int64_t rId = 0; SQWMsg qwMsg = {.node = node, .msg = NULL, .msgLen = 0}; qwMsg.connInfo.handle = pMsg->handle; qwMsg.connInfo.ahandle = pMsg->ahandle; + qwMsg.connInfo.refId = pMsg->refId; QW_SCH_TASK_DLOG("processCQuery start, node:%p, handle:%p", node, pMsg->handle); @@ -384,10 +391,10 @@ int32_t qWorkerProcessCQueryMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg) { QW_SCH_TASK_DLOG("processCQuery end, node:%p", node); - return TSDB_CODE_SUCCESS; + return TSDB_CODE_SUCCESS; } -int32_t qWorkerProcessReadyMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg){ +int32_t qWorkerProcessReadyMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg) { if (NULL == node || NULL == qWorkerMgmt || NULL == pMsg) { return TSDB_CODE_QRY_INVALID_INPUT; } @@ -397,7 +404,7 @@ int32_t qWorkerProcessReadyMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg){ if (NULL == msg || pMsg->contLen < sizeof(*msg)) { QW_ELOG("invalid task ready msg, msg:%p, msgLen:%d", msg, pMsg->contLen); QW_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); - } + } msg->sId = be64toh(msg->sId); msg->queryId = be64toh(msg->queryId); @@ -406,18 +413,19 @@ int32_t qWorkerProcessReadyMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg){ uint64_t sId = msg->sId; uint64_t qId = msg->queryId; uint64_t tId = msg->taskId; - int64_t rId = 0; + int64_t rId = 0; SQWMsg qwMsg = {.node = node, .msg = NULL, .msgLen = 0}; qwMsg.connInfo.handle = pMsg->handle; qwMsg.connInfo.ahandle = pMsg->ahandle; + qwMsg.connInfo.refId = pMsg->refId; QW_SCH_TASK_DLOG("processReady start, node:%p, handle:%p", node, pMsg->handle); QW_ERR_RET(qwProcessReady(QW_FPARAMS(), &qwMsg)); QW_SCH_TASK_DLOG("processReady end, node:%p", node); - + return TSDB_CODE_SUCCESS; } @@ -426,24 +434,24 @@ int32_t qWorkerProcessStatusMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg) { return TSDB_CODE_QRY_INVALID_INPUT; } - int32_t code = 0; + int32_t code = 0; SSchTasksStatusReq *msg = pMsg->pCont; if (NULL == msg || pMsg->contLen < sizeof(*msg)) { qError("invalid task status msg"); QW_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); - } + } SQWorkerMgmt *mgmt = (SQWorkerMgmt *)qWorkerMgmt; msg->sId = htobe64(msg->sId); uint64_t sId = msg->sId; SSchedulerStatusRsp *sStatus = NULL; - - //QW_ERR_JRET(qwGetSchTasksStatus(qWorkerMgmt, msg->sId, &sStatus)); + + // QW_ERR_JRET(qwGetSchTasksStatus(qWorkerMgmt, msg->sId, &sStatus)); _return: - //QW_ERR_RET(qwBuildAndSendStatusRsp(pMsg, sStatus)); + // QW_ERR_RET(qwBuildAndSendStatusRsp(pMsg, sStatus)); return TSDB_CODE_SUCCESS; } @@ -455,11 +463,11 @@ int32_t qWorkerProcessFetchMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg) { SResFetchReq *msg = pMsg->pCont; SQWorkerMgmt *mgmt = (SQWorkerMgmt *)qWorkerMgmt; - + if (NULL == msg || pMsg->contLen < sizeof(*msg)) { - QW_ELOG("invalid fetch msg, msg:%p, msgLen:%d", msg, pMsg->contLen); + QW_ELOG("invalid fetch msg, msg:%p, msgLen:%d", msg, pMsg->contLen); QW_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); - } + } msg->sId = be64toh(msg->sId); msg->queryId = be64toh(msg->queryId); @@ -468,11 +476,12 @@ int32_t qWorkerProcessFetchMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg) { uint64_t sId = msg->sId; uint64_t qId = msg->queryId; uint64_t tId = msg->taskId; - int64_t rId = 0; + int64_t rId = 0; SQWMsg qwMsg = {.node = node, .msg = NULL, .msgLen = 0}; qwMsg.connInfo.handle = pMsg->handle; qwMsg.connInfo.ahandle = pMsg->ahandle; + qwMsg.connInfo.refId = pMsg->refId; QW_SCH_TASK_DLOG("processFetch start, node:%p, handle:%p", node, pMsg->handle); @@ -480,7 +489,7 @@ int32_t qWorkerProcessFetchMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg) { QW_SCH_TASK_DLOG("processFetch end, node:%p", node); - return TSDB_CODE_SUCCESS; + return TSDB_CODE_SUCCESS; } int32_t qWorkerProcessFetchRsp(void *node, void *qWorkerMgmt, SRpcMsg *pMsg) { @@ -493,13 +502,13 @@ int32_t qWorkerProcessCancelMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg) { return TSDB_CODE_QRY_INVALID_INPUT; } - SQWorkerMgmt *mgmt = (SQWorkerMgmt *)qWorkerMgmt; - int32_t code = 0; + SQWorkerMgmt * mgmt = (SQWorkerMgmt *)qWorkerMgmt; + int32_t code = 0; STaskCancelReq *msg = pMsg->pCont; if (NULL == msg || pMsg->contLen < sizeof(*msg)) { - qError("invalid task cancel msg"); + qError("invalid task cancel msg"); QW_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); - } + } msg->sId = be64toh(msg->sId); msg->queryId = be64toh(msg->queryId); @@ -514,8 +523,9 @@ int32_t qWorkerProcessCancelMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg) { SQWMsg qwMsg = {.node = node, .msg = NULL, .msgLen = 0}; qwMsg.connInfo.handle = pMsg->handle; qwMsg.connInfo.ahandle = pMsg->ahandle; + qwMsg.connInfo.refId = pMsg->refId; - //QW_ERR_JRET(qwCancelTask(qWorkerMgmt, msg->sId, msg->queryId, msg->taskId)); + // QW_ERR_JRET(qwCancelTask(qWorkerMgmt, msg->sId, msg->queryId, msg->taskId)); _return: @@ -530,14 +540,14 @@ int32_t qWorkerProcessDropMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg) { return TSDB_CODE_QRY_INVALID_INPUT; } - int32_t code = 0; + int32_t code = 0; STaskDropReq *msg = pMsg->pCont; SQWorkerMgmt *mgmt = (SQWorkerMgmt *)qWorkerMgmt; - + if (NULL == msg || pMsg->contLen < sizeof(*msg)) { QW_ELOG("invalid task drop msg, msg:%p, msgLen:%d", msg, pMsg->contLen); QW_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); - } + } msg->sId = be64toh(msg->sId); msg->queryId = be64toh(msg->queryId); @@ -552,9 +562,10 @@ int32_t qWorkerProcessDropMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg) { SQWMsg qwMsg = {.node = node, .msg = NULL, .msgLen = 0, .code = pMsg->code}; qwMsg.connInfo.handle = pMsg->handle; qwMsg.connInfo.ahandle = pMsg->ahandle; + qwMsg.connInfo.refId = pMsg->refId; if (TSDB_CODE_RPC_NETWORK_UNAVAIL == pMsg->code) { - QW_SCH_TASK_DLOG("receive drop task due to network broken, error:%s", tstrerror(pMsg->code)); + QW_SCH_TASK_DLOG("receive drop task due to network broken, error:%s", tstrerror(pMsg->code)); } QW_SCH_TASK_DLOG("processDrop start, node:%p, handle:%p", node, pMsg->handle); @@ -571,14 +582,14 @@ int32_t qWorkerProcessHbMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg) { return TSDB_CODE_QRY_INVALID_INPUT; } - int32_t code = 0; + int32_t code = 0; SSchedulerHbReq req = {0}; - SQWorkerMgmt *mgmt = (SQWorkerMgmt *)qWorkerMgmt; - + SQWorkerMgmt * mgmt = (SQWorkerMgmt *)qWorkerMgmt; + if (NULL == pMsg->pCont) { QW_ELOG("invalid hb msg, msg:%p, msgLen:%d", pMsg->pCont, pMsg->contLen); QW_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); - } + } if (tDeserializeSSchedulerHbReq(pMsg->pCont, pMsg->contLen, &req)) { QW_ELOG("invalid hb msg, msg:%p, msgLen:%d", pMsg->pCont, pMsg->contLen); @@ -587,9 +598,10 @@ int32_t qWorkerProcessHbMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg) { } uint64_t sId = req.sId; - SQWMsg qwMsg = {.node = node, .msg = NULL, .msgLen = 0}; + SQWMsg qwMsg = {.node = node, .msg = NULL, .msgLen = 0}; qwMsg.connInfo.handle = pMsg->handle; qwMsg.connInfo.ahandle = pMsg->ahandle; + qwMsg.connInfo.refId = pMsg->refId; QW_SCH_DLOG("processHb start, node:%p, handle:%p", node, pMsg->handle); @@ -605,7 +617,7 @@ int32_t qWorkerProcessShowMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg) { return TSDB_CODE_QRY_INVALID_INPUT; } - int32_t code = 0; + int32_t code = 0; SVShowTablesReq *pReq = pMsg->pCont; QW_RET(qwBuildAndSendShowRsp(pMsg, code)); } diff --git a/source/libs/transport/inc/transComm.h b/source/libs/transport/inc/transComm.h index e18538cf27..5dab6f0a97 100644 --- a/source/libs/transport/inc/transComm.h +++ b/source/libs/transport/inc/transComm.h @@ -327,6 +327,10 @@ void transQueueClear(STransQueue* queue); */ void transQueueDestroy(STransQueue* queue); +/* + * init global func + */ +void transThreadOnce(); #ifdef __cplusplus } #endif diff --git a/source/libs/transport/src/transComm.c b/source/libs/transport/src/transComm.c index 9e53811fd3..ef595fb0ec 100644 --- a/source/libs/transport/src/transComm.c +++ b/source/libs/transport/src/transComm.c @@ -16,6 +16,8 @@ #include "transComm.h" +// static TdThreadOnce transModuleInit = PTHREAD_ONCE_INIT; + int transAuthenticateMsg(void* pMsg, int msgLen, void* pAuth, void* pKey) { T_MD5_CTX context; int ret = -1; @@ -361,5 +363,10 @@ void transQueueDestroy(STransQueue* queue) { transQueueClear(queue); taosArrayDestroy(queue->q); } - +// int32_t transGetExHandle() { +// static +//} +// void transThreadOnce() { +// taosThreadOnce(&transModuleInit, ); +//} #endif diff --git a/source/libs/transport/src/transSrv.c b/source/libs/transport/src/transSrv.c index a3ed8cb519..6bb8e0c1c5 100644 --- a/source/libs/transport/src/transSrv.c +++ b/source/libs/transport/src/transSrv.c @@ -17,6 +17,10 @@ #include "transComm.h" +static TdThreadOnce transModuleInit = PTHREAD_ONCE_INIT; + +static char* notify = "a"; + typedef struct { int notifyCount; // int init; // init or not @@ -97,8 +101,6 @@ typedef struct SExHandle { SWorkThrdObj* pThrd; } SExHandle; -static const char* notify = "a"; - static void uvAllocConnBufferCb(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf); static void uvAllocRecvBufferCb(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf); static void uvOnRecvCb(uv_stream_t* cli, ssize_t nread, const uv_buf_t* buf); @@ -138,9 +140,11 @@ static void uvHandleRegister(SSrvMsg* msg, SWorkThrdObj* thrd); static void (*transAsyncHandle[])(SSrvMsg* msg, SWorkThrdObj* thrd) = {uvHandleResp, uvHandleQuit, uvHandleRelease, uvHandleRegister}; -static int exHandlesMgt; +static int32_t exHandlesMgt; +void uvInitExHandleMgt(); void uvOpenExHandleMgt(int size); +void uvCloseExHandleMgt(); int64_t uvAddExHandle(void* p); int32_t uvRemoveExHandle(int64_t refId); int32_t uvReleaseExHandle(int64_t refId); @@ -189,19 +193,36 @@ static bool addHandleToAcceptloop(void* arg); do { \ if (thrd->quit) { \ tTrace("worker thread already quit, ignore msg"); \ - goto _return; \ + goto _return1; \ } \ } while (0) -#define ASYNC_CHECK_HANDLE(exh1, refId) \ - do { \ - if (refId != -1) { \ - SExHandle* exh2 = uvAcquireExHandle(refId); \ - if (exh2 == NULL || exh1 != exh2) { \ - tTrace("server conn %p except, may already freed, ignore msg", exh2 ? exh2->handle : NULL); \ - goto _return; \ - } \ - } \ +#define ASYNC_CHECK_HANDLE(exh1, refId) \ + do { \ + if (refId > 0) { \ + tTrace("server handle step1"); \ + SExHandle* exh2 = uvAcquireExHandle(refId); \ + if (exh2 == NULL || exh1 != exh2) { \ + tTrace("server handle %p except, may already freed, ignore msg, ref1: %" PRIu64 ", ref2 : %" PRIu64 "", exh1, \ + exh1->refId, refId); \ + tTrace("server handle step2"); \ + goto _return1; \ + } \ + } else if (refId == 0) { \ + tTrace("server handle step3"); \ + SExHandle* exh2 = uvAcquireExHandle(refId); \ + tTrace("server handle %p except, may already freed, ignore msg, ", exh1); \ + if (exh2 != NULL && exh1 != exh2) { \ + tTrace("server handle step4"); \ + tTrace("server handle %p except, may already freed, ignore msg, ", exh1); \ + goto _return1; \ + } else { \ + refId = exh1->refId; \ + } \ + } else if (refId == -1) { \ + tTrace("server handle step5"); \ + goto _return2; \ + } \ } while (0) void uvAllocRecvBufferCb(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf) { @@ -269,9 +290,13 @@ static void uvHandleReq(SSrvConn* pConn) { // 1. server application should not send resp on handle // 2. once send out data, cli conn released to conn pool immediately // 3. not mixed with persist + transMsg.handle = (void*)uvAcquireExHandle(pConn->refId); + tTrace("server handle %p conn: %p translated to app, refId: %" PRIu64 "", transMsg.handle, pConn, pConn->refId); + transMsg.refId = pConn->refId; + assert(transMsg.handle != NULL); if (pHead->noResp == 1) { - // transMsg.refId = -1; + transMsg.refId = -1; } uvReleaseExHandle(pConn->refId); @@ -444,6 +469,7 @@ static void destroySmsg(SSrvMsg* smsg) { taosMemoryFree(smsg); } static void destroyAllConn(SWorkThrdObj* pThrd) { + tTrace("thread %p destroy all conn ", pThrd); while (!QUEUE_IS_EMPTY(&pThrd->conn)) { queue* h = QUEUE_HEAD(&pThrd->conn); QUEUE_REMOVE(h); @@ -477,18 +503,24 @@ void uvWorkerAsyncCb(uv_async_t* handle) { continue; } // release handle to rpc init - STransMsg transMsg = msg->msg; - SExHandle* exh1 = transMsg.handle; - int64_t refId = transMsg.refId; - SExHandle* exh2 = uvAcquireExHandle(refId); - if (exh2 == NULL || exh1 != exh2) { - uvReleaseExHandle(refId); - destroySmsg(msg); + if (msg->type == Quit) { + (*transAsyncHandle[msg->type])(msg, pThrd); continue; - } + } else { + STransMsg transMsg = msg->msg; - msg->pConn = exh1->handle; - (*transAsyncHandle[msg->type])(msg, pThrd); + SExHandle* exh1 = transMsg.handle; + int64_t refId = transMsg.refId; + SExHandle* exh2 = uvAcquireExHandle(refId); + if (exh2 == NULL || exh1 != exh2) { + tTrace("server handle %p except msg, ignore it", exh1); + uvReleaseExHandle(refId); + destroySmsg(msg); + continue; + } + msg->pConn = exh1->handle; + (*transAsyncHandle[msg->type])(msg, pThrd); + } } } static void uvWalkCb(uv_handle_t* handle, void* arg) { @@ -718,7 +750,7 @@ static SSrvConn* createConn(void* hThrd) { pConn->refId = exh->refId; transRefSrvHandle(pConn); - tTrace("server conn %p created", pConn); + tTrace("server handle %p, conn %p created, refId: %" PRId64 "", exh, pConn, pConn->refId); return pConn; } @@ -767,7 +799,8 @@ void* transInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads, srv->port = port; uv_loop_init(srv->loop); - uvOpenExHandleMgt(10000); + taosThreadOnce(&transModuleInit, uvInitExHandleMgt); + // uvOpenExHandleMgt(10000); for (int i = 0; i < srv->numOfThreads; i++) { SWorkThrdObj* thrd = (SWorkThrdObj*)taosMemoryCalloc(1, sizeof(SWorkThrdObj)); @@ -813,10 +846,19 @@ End: transCloseServer(srv); return NULL; } + +void uvInitExHandleMgt() { + // init exhandle mgt + uvOpenExHandleMgt(10000); +} void uvOpenExHandleMgt(int size) { // added into once later exHandlesMgt = taosOpenRef(size, uvDestoryExHandle); } +void uvCloseExHandleMgt() { + // close ref + taosCloseRef(exHandlesMgt); +} int64_t uvAddExHandle(void* p) { // acquire extern handle return taosAddRef(exHandlesMgt, p); @@ -932,6 +974,8 @@ void transCloseServer(void* arg) { taosMemoryFree(srv->pipe); taosMemoryFree(srv); + + // uvCloseExHandleMgt(); } void transRefSrvHandle(void* handle) { @@ -955,14 +999,14 @@ void transUnrefSrvHandle(void* handle) { void transReleaseSrvHandle(void* handle) { SExHandle* exh = handle; - // TODO(yihaoDeng): not safy here, - int64_t refId = exh->refId; + int64_t refId = exh->refId; + ASYNC_CHECK_HANDLE(exh, refId); SWorkThrdObj* pThrd = exh->pThrd; ASYNC_ERR_JRET(pThrd); - STransMsg tmsg = {.code = 0, .handle = exh, .ahandle = NULL, .refId = exh->refId}; + STransMsg tmsg = {.code = 0, .handle = exh, .ahandle = NULL, .refId = refId}; SSrvMsg* srvMsg = taosMemoryCalloc(1, sizeof(SSrvMsg)); srvMsg->msg = tmsg; @@ -972,50 +1016,73 @@ void transReleaseSrvHandle(void* handle) { transSendAsync(pThrd->asyncPool, &srvMsg->q); uvReleaseExHandle(refId); return; -_return: +_return1: uvReleaseExHandle(refId); + return; +_return2: + return; } void transSendResponse(const STransMsg* msg) { SExHandle* exh = msg->handle; int64_t refId = msg->refId; ASYNC_CHECK_HANDLE(exh, refId); + STransMsg tmsg = *msg; + tmsg.refId = refId; + SWorkThrdObj* pThrd = exh->pThrd; ASYNC_ERR_JRET(pThrd); SSrvMsg* srvMsg = taosMemoryCalloc(1, sizeof(SSrvMsg)); - srvMsg->msg = *msg; + srvMsg->msg = tmsg; srvMsg->type = Normal; tTrace("server conn %p start to send resp (1/2)", exh->handle); transSendAsync(pThrd->asyncPool, &srvMsg->q); uvReleaseExHandle(refId); return; -_return: +_return1: + rpcFreeCont(msg->pCont); uvReleaseExHandle(refId); + return; +_return2: + rpcFreeCont(msg->pCont); + return; } void transRegisterMsg(const STransMsg* msg) { - SExHandle* exh = NULL; + SExHandle* exh = msg->handle; int64_t refId = msg->refId; ASYNC_CHECK_HANDLE(exh, refId); + STransMsg tmsg = *msg; + tmsg.refId = refId; + SWorkThrdObj* pThrd = exh->pThrd; ASYNC_ERR_JRET(pThrd); SSrvMsg* srvMsg = taosMemoryCalloc(1, sizeof(SSrvMsg)); - srvMsg->msg = *msg; + srvMsg->msg = tmsg; srvMsg->type = Register; tTrace("server conn %p start to register brokenlink callback", exh->handle); transSendAsync(pThrd->asyncPool, &srvMsg->q); uvReleaseExHandle(refId); return; -_return: +_return1: + rpcFreeCont(msg->pCont); uvReleaseExHandle(refId); + return; +_return2: + rpcFreeCont(msg->pCont); } -int transGetConnInfo(void* thandle, STransHandleInfo* pInfo) { - SExHandle* ex = thandle; - SSrvConn* pConn = ex->handle; - struct sockaddr_in addr = pConn->addr; +int transGetConnInfo(void* thandle, STransHandleInfo* pInfo) { + if (thandle == NULL) { + tTrace("invalid handle %p, failed to Get Conn info", thandle); + return -1; + } + SExHandle* ex = thandle; + SSrvConn* pConn = ex->handle; + + struct sockaddr_in addr = pConn->addr; pInfo->clientIp = (uint32_t)(addr.sin_addr.s_addr); pInfo->clientPort = ntohs(addr.sin_port); tstrncpy(pInfo->user, pConn->user, sizeof(pInfo->user)); From 4f27533d426a483ea4f1203d17acc0ba6abacf69 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Sat, 23 Apr 2022 15:33:25 +0800 Subject: [PATCH 03/11] enh(rpc): fix hb problem --- .../mnode/impl/test/profile/.profile.cpp.swo | Bin 16384 -> 0 bytes source/dnode/vnode/inc/log | 586 ------------------ source/dnode/vnode/src/vnd/vnodeQuery.c | 11 +- source/libs/transport/src/transSrv.c | 6 + 4 files changed, 12 insertions(+), 591 deletions(-) delete mode 100644 source/dnode/mnode/impl/test/profile/.profile.cpp.swo delete mode 100644 source/dnode/vnode/inc/log diff --git a/source/dnode/mnode/impl/test/profile/.profile.cpp.swo b/source/dnode/mnode/impl/test/profile/.profile.cpp.swo deleted file mode 100644 index 004b23f8f98327c311baaa89f32bcfab92866a8c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16384 zcmeI3U2Ggz700I}rJ<0tfK&oV^s+(GthL@V#A+1;c`qjowwd)GVi zcxF6v$7U0iO7sD>LI|1yqVNO{h<*sf1D{2G;Ohb2ka$6A0YyLo5kT-n`1s#DA3L+_ zwMkS2LSyCU_1t^r-gD1A_ue^YHqGMsg=I38ACvHNwe+bA&V zvV!ecZQY>ZXI``I-TFxDQVXOO*uerGYmZJHlqSZ)0M|HJtI z#$A&1Yw$977CZ&EfD3A11uTLOfN3xV4uBhnBOW+~!esB={@GX+`1Mn%(1?RyC$b#Rz89IWez>{DeX`U=_R@ybJscbNMp(0{A?50-Of#1h)e|*ZV;9L&$8sUa2*d%30aHoFm2T zNr@2MWW>Ep?juaK+*!v_yJsk?>zAqQxON`6LX4HEOC4P`P*X1%IyKpRb53Pir{>zS zz3i@yp0Z1p$#TTM(D3&XHFM-B+7L|)+(uA?j;|CSJ1Ievo_1jiEgEVW)Kx2@s~j;s z!?2m-w_CF{^gkjx<^#bOO7eATwrX@!Zj_fB%5t@=%vWY>jk(HfBS)HEJ4cv7P27%t zS$)XBaC;<*aWutf>89v(%hFpTgz&b|rQA0*x;c_{pp|MEmd33j2i*yKPmC)}^v{*u zrSs~!r6m|3*)>-tmcbXXjED$SHu!rsGgr)S|}^!IWe2D zHH{XBt!Y&8sn~H%^8vz4*m5uvITEOZ#$mzu!t#d%895;crw>fSCzAV3xT?7rdQC3j zUh}bl!4cp23k$||PjbZsWo8kF_08DlE> zSMB(8?$lhX2?5>20@hnft2sV=C)>;v^uG)QiD?lQj3 z!rh!N@n8(A7?`5TvWK%~N?{|}Xr#=+E-d?(@aw^mYaP`|7GDxRwF>8XaHUpOmMYbU z!!<^T5ciwA#EUaritBHihh}JvtXgt8#SD& zF%fFlDa%vay;OWS-`;HDAk5$_P>qh|22<8spJLnUJy6Y7R-OsGP8>Bf}Y z#Qxol=~lKQ?i>GWy9#s){R3{%tPAn-rUi(KIY2aC-Y;BuzmRMWVar71?SNQV=KlliCtaEmMmF+bRU7O(x(`72t zH6Ahe`h@*QHIX7g$5Dl7KJ1)J)jge2balmFKqZ5!riZ>y60S|qQBSEIZV}I9nF8Ce z{V$Uz53g|7q5@Yev!x97TO*A~VDvBbk}udh6!e%na|4p8!X6Q!_kRDdT!9 z-^suXBL#qe-uFOH9gGB|vwC>Sk{jTVoK`(Sw&4`XC3Uli9( zN2hJFT*Y$|*|1ukLAlQS`|!d#t`Jf^*0FFF8f%_v650Pe9iDGEk~XqJPTUsUF1|)z z7#Wdx{C_`UO&+82_`ezih1U?vzW|;CUjmPV61WfWc>gf?8{+s^!7Jc%U=y4KJkI|M z;`X0{Z-7sOtKezyF`$A+!F#|B#PF|zm%wL$0oK7$Z~*)kG5l-btKb=6fH`mvxQ6)s zE8sHdf(9spL*O;U?cW8T1%1PPAe84QteS}2Q9BNi>(Vj5#{VQER>!??ItCL>aOr(DK5 zM)mq8G7{bOQW?FD@T?YGU^<#1#j3X!?jK`yU5Xr}H;8D1^AqvEYN%lwK z!{m}7_@ETG93PpVv|cRX2Kp`d~A`1S3qx zJPOYrl<}upWa5xC@xyt7>>N)R`qmGOiP`Qj66`a8&U0!uTs$G&Av=YWK=OMvG{_7C9fMjwR?t;-=`Bw_|NI>4)kO~A|KV5edKwWV0gmWxf_)3DRH0q}!y!U+OgRQip7~YeQ4dClY7cfAC4 -802e2d77c00 include/tkv/tkv.h (Hongze Cheng 2021-09-22 13:21:07 +0800 3) * -802e2d77c00 include/tkv/tkv.h (Hongze Cheng 2021-09-22 13:21:07 +0800 4) * This program is free software: you can use, redistribute, and/or modify -802e2d77c00 include/tkv/tkv.h (Hongze Cheng 2021-09-22 13:21:07 +0800 5) * it under the terms of the GNU Affero General Public License, version 3 -802e2d77c00 include/tkv/tkv.h (Hongze Cheng 2021-09-22 13:21:07 +0800 6) * or later ("AGPL"), as published by the Free Software Foundation. -802e2d77c00 include/tkv/tkv.h (Hongze Cheng 2021-09-22 13:21:07 +0800 7) * -802e2d77c00 include/tkv/tkv.h (Hongze Cheng 2021-09-22 13:21:07 +0800 8) * This program is distributed in the hope that it will be useful, but WITHOUT -802e2d77c00 include/tkv/tkv.h (Hongze Cheng 2021-09-22 13:21:07 +0800 9) * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -802e2d77c00 include/tkv/tkv.h (Hongze Cheng 2021-09-22 13:21:07 +0800 10) * FITNESS FOR A PARTICULAR PURPOSE. -802e2d77c00 include/tkv/tkv.h (Hongze Cheng 2021-09-22 13:21:07 +0800 11) * -802e2d77c00 include/tkv/tkv.h (Hongze Cheng 2021-09-22 13:21:07 +0800 12) * You should have received a copy of the GNU Affero General Public License -802e2d77c00 include/tkv/tkv.h (Hongze Cheng 2021-09-22 13:21:07 +0800 13) * along with this program. If not, see . -ce7a1600eb4 include/server/vnode/vnode.h (Shengliang Guan 2021-09-22 20:29:24 +0800 14) */ -ce7a1600eb4 include/server/vnode/vnode.h (Shengliang Guan 2021-09-22 20:29:24 +0800 15) -ce7a1600eb4 include/server/vnode/vnode.h (Shengliang Guan 2021-09-22 20:29:24 +0800 16) #ifndef _TD_VNODE_H_ -ce7a1600eb4 include/server/vnode/vnode.h (Shengliang Guan 2021-09-22 20:29:24 +0800 17) #define _TD_VNODE_H_ -ce7a1600eb4 include/server/vnode/vnode.h (Shengliang Guan 2021-09-22 20:29:24 +0800 18) -79e5aeaa093 include/server/vnode/vnode.h (Hongze Cheng 2021-11-09 13:24:22 +0800 19) #include "os.h" -220fdfabe29 source/dnode/vnode/inc/vnode.h (Shengliang Guan 2022-03-21 19:08:25 +0800 20) #include "tmsgcb.h" -a9ad7ebd100 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-29 18:58:15 +0800 21) #include "tqueue.h" -a9ad7ebd100 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-29 18:58:15 +0800 22) #include "trpc.h" -79e5aeaa093 include/server/vnode/vnode.h (Hongze Cheng 2021-11-09 13:24:22 +0800 23) -7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 24) #include "tarray.h" -cc5563716c5 source/dnode/vnode/inc/vnode.h (Shengliang Guan 2022-01-18 22:04:01 -0800 25) #include "tfs.h" -2b5e0592c4d include/dnode/vnode/vnode.h (Hongze Cheng 2021-11-24 16:29:02 +0800 26) #include "wal.h" -2f36662750f include/server/vnode/vnode.h (Shengliang Guan 2021-11-01 19:49:44 +0800 27) -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 28) #include "tmallocator.h" -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 29) #include "tmsg.h" -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 30) #include "trow.h" -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 31) #include "tmallocator.h" -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 32) #include "tcommon.h" -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 33) #include "tfs.h" -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 34) -ce7a1600eb4 include/server/vnode/vnode.h (Shengliang Guan 2021-09-22 20:29:24 +0800 35) #ifdef __cplusplus -ce7a1600eb4 include/server/vnode/vnode.h (Shengliang Guan 2021-09-22 20:29:24 +0800 36) extern "C" { -ce7a1600eb4 include/server/vnode/vnode.h (Shengliang Guan 2021-09-22 20:29:24 +0800 37) #endif -ce7a1600eb4 include/server/vnode/vnode.h (Shengliang Guan 2021-09-22 20:29:24 +0800 38) -993d28df0f6 include/server/vnode/vnode.h (Hongze Cheng 2021-11-07 15:58:32 +0800 39) /* ------------------------ TYPES EXPOSED ------------------------ */ -5832b6772c1 source/dnode/vnode/inc/vnode.h (Shengliang Guan 2022-03-16 21:18:54 +0800 40) typedef struct SMgmtWrapper SMgmtWrapper; -5832b6772c1 source/dnode/vnode/inc/vnode.h (Shengliang Guan 2022-03-16 21:18:54 +0800 41) typedef struct SVnode SVnode; -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 42) -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 43) #define META_SUPER_TABLE TD_SUPER_TABLE -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 44) #define META_CHILD_TABLE TD_CHILD_TABLE -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 45) #define META_NORMAL_TABLE TD_NORMAL_TABLE -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 46) -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 47) // Types exported -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 48) typedef struct SMeta SMeta; -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 49) -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 50) typedef struct SMetaCfg { -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 51) /// LRU cache size -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 52) uint64_t lruSize; -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 53) } SMetaCfg; -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 54) -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 55) typedef struct SMTbCursor SMTbCursor; -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 56) typedef struct SMCtbCursor SMCtbCursor; -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 57) typedef struct SMSmaCursor SMSmaCursor; -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 58) -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 59) typedef SVCreateTbReq STbCfg; -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 60) typedef SVCreateTSmaReq SSmaCfg; -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 61) -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 62) typedef struct SDataStatis { -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 63) int16_t colId; -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 64) int16_t maxIndex; -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 65) int16_t minIndex; -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 66) int16_t numOfNull; -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 67) int64_t sum; -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 68) int64_t max; -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 69) int64_t min; -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 70) } SDataStatis; -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 71) -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 72) typedef struct STsdbQueryCond { -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 73) STimeWindow twindow; -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 74) int32_t order; // desc|asc order to iterate the data block -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 75) int32_t numOfCols; -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 76) SColumnInfo *colList; -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 77) bool loadExternalRows; // load external rows or not -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 78) int32_t type; // data block load type: -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 79) } STsdbQueryCond; -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 80) -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 81) typedef struct { -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 82) TSKEY lastKey; -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 83) uint64_t uid; -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 84) } STableKeyInfo; -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 85) -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 86) -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 87) typedef struct STable { -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 88) uint64_t tid; -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 89) uint64_t uid; -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 90) STSchema *pSchema; -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 91) } STable; -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 92) -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 93) #define BLOCK_LOAD_OFFSET_SEQ_ORDER 1 -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 94) #define BLOCK_LOAD_TABLE_SEQ_ORDER 2 -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 95) #define BLOCK_LOAD_TABLE_RR_ORDER 3 -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 96) -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 97) #define TABLE_TID(t) (t)->tid -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 98) #define TABLE_UID(t) (t)->uid -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 99) -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 100) // TYPES EXPOSED -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 101) typedef struct STsdb STsdb; -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 102) -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 103) typedef struct STsdbCfg { -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 104) int8_t precision; -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 105) int8_t update; -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 106) int8_t compression; -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 107) int32_t daysPerFile; -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 108) int32_t minRowsPerFileBlock; -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 109) int32_t maxRowsPerFileBlock; -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 110) int32_t keep; -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 111) int32_t keep1; -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 112) int32_t keep2; -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 113) uint64_t lruCacheSize; -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 114) SArray *retentions; -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 115) } STsdbCfg; -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 116) -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 117) -a038c466075 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-02-15 10:11:34 +0800 118) typedef struct { -35749cb3742 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-21 16:12:02 +0800 119) // TODO -35749cb3742 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-21 16:12:02 +0800 120) int32_t reserved; -35749cb3742 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-21 16:12:02 +0800 121) } STqCfg; -35749cb3742 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-21 16:12:02 +0800 122) -a038c466075 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-02-15 10:11:34 +0800 123) typedef struct { -7dbc861b4c1 source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-01-13 08:57:18 +0000 124) int32_t vgId; -5f2dc1401fe source/dnode/vnode/inc/vnode.h (dapan1121 2022-02-11 19:52:07 +0800 125) uint64_t dbId; -ed9709c3f0a source/dnode/vnode/inc/vnode.h (Shengliang Guan 2022-01-18 21:39:32 -0800 126) STfs *pTfs; -7dbc861b4c1 source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-01-13 08:57:18 +0000 127) uint64_t wsize; -7dbc861b4c1 source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-01-13 08:57:18 +0000 128) uint64_t ssize; -7dbc861b4c1 source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-01-13 08:57:18 +0000 129) uint64_t lsize; -7dbc861b4c1 source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-01-13 08:57:18 +0000 130) bool isHeapAllocator; -2ae35c3404c include/dnode/vnode/vnode.h (Hongze Cheng 2021-11-26 13:43:38 +0800 131) uint32_t ttl; -2ae35c3404c include/dnode/vnode/vnode.h (Hongze Cheng 2021-11-26 13:43:38 +0800 132) uint32_t keep; -82bcecc4ff5 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-02-18 16:59:33 +0800 133) int8_t streamMode; -7dbc861b4c1 source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-01-13 08:57:18 +0000 134) bool isWeak; -2ae35c3404c include/dnode/vnode/vnode.h (Hongze Cheng 2021-11-26 13:43:38 +0800 135) STsdbCfg tsdbCfg; -2ae35c3404c include/dnode/vnode/vnode.h (Hongze Cheng 2021-11-26 13:43:38 +0800 136) SMetaCfg metaCfg; -7dbc861b4c1 source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-01-13 08:57:18 +0000 137) STqCfg tqCfg; -7dbc861b4c1 source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-01-13 08:57:18 +0000 138) SWalCfg walCfg; -220fdfabe29 source/dnode/vnode/inc/vnode.h (Shengliang Guan 2022-03-21 19:08:25 +0800 139) SMsgCb msgCb; -09e6462c5fa source/dnode/vnode/inc/vnode.h (dapan1121 2022-03-03 09:09:11 +0800 140) uint32_t hashBegin; -09e6462c5fa source/dnode/vnode/inc/vnode.h (dapan1121 2022-03-03 09:09:11 +0800 141) uint32_t hashEnd; -913e8d70d87 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-09 10:49:42 +0800 142) int8_t hashMethod; -2ae35c3404c include/dnode/vnode/vnode.h (Hongze Cheng 2021-11-26 13:43:38 +0800 143) } SVnodeCfg; -993d28df0f6 include/server/vnode/vnode.h (Hongze Cheng 2021-11-07 15:58:32 +0800 144) -a038c466075 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-02-15 10:11:34 +0800 145) typedef struct { -5bb010ef4af source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-28 15:24:09 +0800 146) int64_t ver; -a038c466075 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-02-15 10:11:34 +0800 147) int64_t tbUid; -5bb010ef4af source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-28 15:24:09 +0800 148) SHashObj *tbIdHash; -246311d4fcf source/dnode/vnode/inc/vnode.h (Shengliang Guan 2022-02-16 15:27:19 +0800 149) const SSubmitReq *pMsg; -5bb010ef4af source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-28 15:24:09 +0800 150) SSubmitBlk *pBlock; -5bb010ef4af source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-28 15:24:09 +0800 151) SSubmitMsgIter msgIter; -5bb010ef4af source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-28 15:24:09 +0800 152) SSubmitBlkIter blkIter; -5bb010ef4af source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-28 15:24:09 +0800 153) SMeta *pVnodeMeta; -5bb010ef4af source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-28 15:24:09 +0800 154) SArray *pColIdList; // SArray -5bb010ef4af source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-28 15:24:09 +0800 155) int32_t sver; -5bb010ef4af source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-28 15:24:09 +0800 156) SSchemaWrapper *pSchemaWrapper; -5bb010ef4af source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-28 15:24:09 +0800 157) STSchema *pSchema; -35749cb3742 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-21 16:12:02 +0800 158) } STqReadHandle; -35749cb3742 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-21 16:12:02 +0800 159) -993d28df0f6 include/server/vnode/vnode.h (Hongze Cheng 2021-11-07 15:58:32 +0800 160) /* ------------------------ SVnode ------------------------ */ -757dea61705 include/dnode/vnode/vnode.h (Hongze Cheng 2021-11-29 14:06:16 +0800 161) /** -757dea61705 include/dnode/vnode/vnode.h (Hongze Cheng 2021-11-29 14:06:16 +0800 162) * @brief Initialize the vnode module -018661e1779 include/dnode/vnode/vnode.h (Hongze Cheng 2021-11-29 15:42:17 +0800 163) * -757dea61705 include/dnode/vnode/vnode.h (Hongze Cheng 2021-11-29 14:06:16 +0800 164) * @return int 0 for success and -1 for failure -757dea61705 include/dnode/vnode/vnode.h (Hongze Cheng 2021-11-29 14:06:16 +0800 165) */ -220fdfabe29 source/dnode/vnode/inc/vnode.h (Shengliang Guan 2022-03-21 19:08:25 +0800 166) int vnodeInit(); -757dea61705 include/dnode/vnode/vnode.h (Hongze Cheng 2021-11-29 14:06:16 +0800 167) -757dea61705 include/dnode/vnode/vnode.h (Hongze Cheng 2021-11-29 14:06:16 +0800 168) /** -0b6d32a3d92 include/dnode/vnode/vnode.h (Shengliang Guan 2022-01-11 19:35:40 -0800 169) * @brief Cleanup the vnode module -018661e1779 include/dnode/vnode/vnode.h (Hongze Cheng 2021-11-29 15:42:17 +0800 170) * -757dea61705 include/dnode/vnode/vnode.h (Hongze Cheng 2021-11-29 14:06:16 +0800 171) */ -0b6d32a3d92 include/dnode/vnode/vnode.h (Shengliang Guan 2022-01-11 19:35:40 -0800 172) void vnodeCleanup(); -757dea61705 include/dnode/vnode/vnode.h (Hongze Cheng 2021-11-29 14:06:16 +0800 173) -7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 174) /** -7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 175) * @brief Open a VNODE. -7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 176) * -7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 177) * @param path path of the vnode -3906f6a7073 include/dnode/vnode/vnode.h (Hongze Cheng 2021-11-22 15:39:05 +0800 178) * @param pVnodeCfg options of the vnode -7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 179) * @return SVnode* The vnode object -7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 180) */ -ab3378e0901 include/dnode/vnode/vnode.h (Shengliang Guan 2022-01-11 16:44:11 -0800 181) SVnode *vnodeOpen(const char *path, const SVnodeCfg *pVnodeCfg); -7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 182) -7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 183) /** -7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 184) * @brief Close a VNODE -7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 185) * -baac49c75b2 include/dnode/vnode/vnode.h (Hongze Cheng 2021-11-12 17:50:46 +0800 186) * @param pVnode The vnode object to close -7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 187) */ -7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 188) void vnodeClose(SVnode *pVnode); -7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 189) -7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 190) /** -7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 191) * @brief Destroy a VNODE. -7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 192) * -7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 193) * @param path Path of the VNODE. -7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 194) */ -7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 195) void vnodeDestroy(const char *path); -7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 196) -7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 197) /** -7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 198) * @brief Process an array of write messages. -7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 199) * -7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 200) * @param pVnode The vnode object. -7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 201) * @param pMsgs The array of SRpcMsg -7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 202) */ -50229512d32 source/dnode/vnode/inc/vnode.h (Shengliang Guan 2022-03-21 14:39:35 +0800 203) void vnodeProcessWMsgs(SVnode *pVnode, SArray *pMsgs); -7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 204) -7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 205) /** -7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 206) * @brief Apply a write request message. -7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 207) * -7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 208) * @param pVnode The vnode object. -7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 209) * @param pMsg The request message -15d9a46600d include/server/vnode/vnode.h (Hongze Cheng 2021-11-12 10:53:52 +0800 210) * @param pRsp The response message -7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 211) * @return int 0 for success, -1 for failure -7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 212) */ -7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 213) int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp); -7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 214) -6beee204d82 include/dnode/vnode/vnode.h (Liu Jicong 2021-12-21 20:07:32 +0800 215) /** -6beee204d82 include/dnode/vnode/vnode.h (Liu Jicong 2021-12-21 20:07:32 +0800 216) * @brief Process a consume message. -6beee204d82 include/dnode/vnode/vnode.h (Liu Jicong 2021-12-21 20:07:32 +0800 217) * -6beee204d82 include/dnode/vnode/vnode.h (Liu Jicong 2021-12-21 20:07:32 +0800 218) * @param pVnode The vnode object. -6beee204d82 include/dnode/vnode/vnode.h (Liu Jicong 2021-12-21 20:07:32 +0800 219) * @param pMsg The request message -6beee204d82 include/dnode/vnode/vnode.h (Liu Jicong 2021-12-21 20:07:32 +0800 220) * @param pRsp The response message -6beee204d82 include/dnode/vnode/vnode.h (Liu Jicong 2021-12-21 20:07:32 +0800 221) * @return int 0 for success, -1 for failure -6beee204d82 include/dnode/vnode/vnode.h (Liu Jicong 2021-12-21 20:07:32 +0800 222) */ -6beee204d82 include/dnode/vnode/vnode.h (Liu Jicong 2021-12-21 20:07:32 +0800 223) int vnodeProcessCMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp); -6beee204d82 include/dnode/vnode/vnode.h (Liu Jicong 2021-12-21 20:07:32 +0800 224) -7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 225) /** -7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 226) * @brief Process the sync request -7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 227) * -7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 228) * @param pVnode -7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 229) * @param pMsg -7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 230) * @param pRsp -7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 231) * @return int -7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 232) */ -7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 233) int vnodeProcessSyncReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp); -993d28df0f6 include/server/vnode/vnode.h (Hongze Cheng 2021-11-07 15:58:32 +0800 234) -293ad0bb066 include/dnode/vnode/vnode.h (Shengliang Guan 2021-12-21 16:15:38 +0800 235) /** -293ad0bb066 include/dnode/vnode/vnode.h (Shengliang Guan 2021-12-21 16:15:38 +0800 236) * @brief Process a query message. -293ad0bb066 include/dnode/vnode/vnode.h (Shengliang Guan 2021-12-21 16:15:38 +0800 237) * -293ad0bb066 include/dnode/vnode/vnode.h (Shengliang Guan 2021-12-21 16:15:38 +0800 238) * @param pVnode The vnode object. -293ad0bb066 include/dnode/vnode/vnode.h (Shengliang Guan 2021-12-21 16:15:38 +0800 239) * @param pMsg The request message -293ad0bb066 include/dnode/vnode/vnode.h (Shengliang Guan 2021-12-21 16:15:38 +0800 240) * @return int 0 for success, -1 for failure -293ad0bb066 include/dnode/vnode/vnode.h (Shengliang Guan 2021-12-21 16:15:38 +0800 241) */ -808efe80698 source/dnode/vnode/inc/vnode.h (Shengliang 2022-01-25 14:20:52 +0800 242) int vnodeProcessQueryMsg(SVnode *pVnode, SRpcMsg *pMsg); -293ad0bb066 include/dnode/vnode/vnode.h (Shengliang Guan 2021-12-21 16:15:38 +0800 243) -293ad0bb066 include/dnode/vnode/vnode.h (Shengliang Guan 2021-12-21 16:15:38 +0800 244) /** -293ad0bb066 include/dnode/vnode/vnode.h (Shengliang Guan 2021-12-21 16:15:38 +0800 245) * @brief Process a fetch message. -293ad0bb066 include/dnode/vnode/vnode.h (Shengliang Guan 2021-12-21 16:15:38 +0800 246) * -293ad0bb066 include/dnode/vnode/vnode.h (Shengliang Guan 2021-12-21 16:15:38 +0800 247) * @param pVnode The vnode object. -293ad0bb066 include/dnode/vnode/vnode.h (Shengliang Guan 2021-12-21 16:15:38 +0800 248) * @param pMsg The request message -293ad0bb066 include/dnode/vnode/vnode.h (Shengliang Guan 2021-12-21 16:15:38 +0800 249) * @return int 0 for success, -1 for failure -293ad0bb066 include/dnode/vnode/vnode.h (Shengliang Guan 2021-12-21 16:15:38 +0800 250) */ -a9ad7ebd100 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-29 18:58:15 +0800 251) int vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo); -293ad0bb066 include/dnode/vnode/vnode.h (Shengliang Guan 2021-12-21 16:15:38 +0800 252) -9001468b212 include/dnode/vnode/vnode.h (Hongze Cheng 2021-11-22 15:02:53 +0800 253) /* ------------------------ SVnodeCfg ------------------------ */ -7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 254) /** -7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 255) * @brief Initialize VNODE options. -7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 256) * -7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 257) * @param pOptions The options object to be initialized. It should not be NULL. -7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 258) */ -9001468b212 include/dnode/vnode/vnode.h (Hongze Cheng 2021-11-22 15:02:53 +0800 259) void vnodeOptionsInit(SVnodeCfg *pOptions); -7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 260) -7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 261) /** -7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 262) * @brief Clear VNODE options. -7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 263) * -7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 264) * @param pOptions Options to clear. -7277784852b include/server/vnode/vnode.h (Hongze Cheng 2021-11-11 11:41:16 +0800 265) */ -9001468b212 include/dnode/vnode/vnode.h (Hongze Cheng 2021-11-22 15:02:53 +0800 266) void vnodeOptionsClear(SVnodeCfg *pOptions); -993d28df0f6 include/server/vnode/vnode.h (Hongze Cheng 2021-11-07 15:58:32 +0800 267) -260aad808b4 source/dnode/vnode/inc/vnode.h (dapan1121 2022-03-11 19:45:34 +0800 268) int vnodeValidateTableHash(SVnodeCfg *pVnodeOptions, char *tableFName); -763eccf8aa4 source/dnode/vnode/inc/vnode.h (dapan1121 2022-03-10 19:05:58 +0800 269) -c8ee7ba9a7b include/server/vnode/vnode.h (Hongze Cheng 2021-11-09 14:36:53 +0800 270) /* ------------------------ FOR COMPILE ------------------------ */ -c8ee7ba9a7b include/server/vnode/vnode.h (Hongze Cheng 2021-11-09 14:36:53 +0800 271) -2f36662750f include/server/vnode/vnode.h (Shengliang Guan 2021-11-01 19:49:44 +0800 272) int32_t vnodeAlter(SVnode *pVnode, const SVnodeCfg *pCfg); -2f36662750f include/server/vnode/vnode.h (Shengliang Guan 2021-11-01 19:49:44 +0800 273) int32_t vnodeCompact(SVnode *pVnode); -2f36662750f include/server/vnode/vnode.h (Shengliang Guan 2021-11-01 19:49:44 +0800 274) int32_t vnodeSync(SVnode *pVnode); -dd3281c9d2f include/server/vnode/vnode.h (Shengliang Guan 2021-11-04 18:38:07 +0800 275) int32_t vnodeGetLoad(SVnode *pVnode, SVnodeLoad *pLoad); -2f09d49aa4c include/server/vnode/vnode.h (Shengliang Guan 2021-11-04 14:06:29 +0800 276) -a038c466075 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-02-15 10:11:34 +0800 277) /* ------------------------- TQ READ --------------------------- */ -35749cb3742 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-21 16:12:02 +0800 278) -913e8d70d87 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-09 10:49:42 +0800 279) enum { -913e8d70d87 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-09 10:49:42 +0800 280) TQ_STREAM_TOKEN__DATA = 1, -913e8d70d87 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-09 10:49:42 +0800 281) TQ_STREAM_TOKEN__WATERMARK, -913e8d70d87 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-09 10:49:42 +0800 282) TQ_STREAM_TOKEN__CHECKPOINT, -913e8d70d87 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-09 10:49:42 +0800 283) }; -913e8d70d87 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-09 10:49:42 +0800 284) -913e8d70d87 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-09 10:49:42 +0800 285) typedef struct { -913e8d70d87 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-09 10:49:42 +0800 286) int8_t type; -913e8d70d87 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-09 10:49:42 +0800 287) int8_t reserved[7]; -913e8d70d87 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-09 10:49:42 +0800 288) union { -913e8d70d87 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-09 10:49:42 +0800 289) void *data; -913e8d70d87 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-09 10:49:42 +0800 290) int64_t wmTs; -913e8d70d87 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-09 10:49:42 +0800 291) int64_t checkpointId; -913e8d70d87 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-09 10:49:42 +0800 292) }; -913e8d70d87 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-09 10:49:42 +0800 293) } STqStreamToken; -913e8d70d87 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-09 10:49:42 +0800 294) -5bb010ef4af source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-28 15:24:09 +0800 295) STqReadHandle *tqInitSubmitMsgScanner(SMeta *pMeta); -35749cb3742 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-21 16:12:02 +0800 296) -5bb010ef4af source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-28 15:24:09 +0800 297) static FORCE_INLINE void tqReadHandleSetColIdList(STqReadHandle *pReadHandle, SArray *pColIdList) { -a1c6c94c0b3 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-21 19:00:09 +0800 298) pReadHandle->pColIdList = pColIdList; -a1c6c94c0b3 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-21 19:00:09 +0800 299) } -a1c6c94c0b3 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-21 19:00:09 +0800 300) -a038c466075 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-02-15 10:11:34 +0800 301) // static FORCE_INLINE void tqReadHandleSetTbUid(STqReadHandle* pHandle, int64_t tbUid) { -a038c466075 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-02-15 10:11:34 +0800 302) // pHandle->tbUid = tbUid; -60a1ae8ce4c source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-28 13:31:46 +0800 303) //} -35749cb3742 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-21 16:12:02 +0800 304) -5bb010ef4af source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-28 15:24:09 +0800 305) static FORCE_INLINE int tqReadHandleSetTbUidList(STqReadHandle *pHandle, const SArray *tbUidList) { -b7788aca04f source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-02 16:22:43 +0800 306) if (pHandle->tbIdHash) { -b7788aca04f source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-02 16:22:43 +0800 307) taosHashClear(pHandle->tbIdHash); -b7788aca04f source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-02 16:22:43 +0800 308) } -b7788aca04f source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-02 16:22:43 +0800 309) -a038c466075 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-02-15 10:11:34 +0800 310) pHandle->tbIdHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_NO_LOCK); -963fb9b9f61 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-27 18:05:23 +0800 311) if (pHandle->tbIdHash == NULL) { -36aedfbb7cd source/dnode/vnode/inc/vnode.h (Haojun Liao 2022-02-17 15:24:00 +0800 312) terrno = TSDB_CODE_OUT_OF_MEMORY; -963fb9b9f61 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-27 18:05:23 +0800 313) return -1; -963fb9b9f61 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-27 18:05:23 +0800 314) } -36aedfbb7cd source/dnode/vnode/inc/vnode.h (Haojun Liao 2022-02-17 15:24:00 +0800 315) -963fb9b9f61 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-27 18:05:23 +0800 316) for (int i = 0; i < taosArrayGetSize(tbUidList); i++) { -5bb010ef4af source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-28 15:24:09 +0800 317) int64_t *pKey = (int64_t *)taosArrayGet(tbUidList, i); -963fb9b9f61 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-27 18:05:23 +0800 318) taosHashPut(pHandle->tbIdHash, pKey, sizeof(int64_t), NULL, 0); -963fb9b9f61 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-27 18:05:23 +0800 319) } -36aedfbb7cd source/dnode/vnode/inc/vnode.h (Haojun Liao 2022-02-17 15:24:00 +0800 320) -963fb9b9f61 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-27 18:05:23 +0800 321) return 0; -963fb9b9f61 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-27 18:05:23 +0800 322) } -963fb9b9f61 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-27 18:05:23 +0800 323) -b7788aca04f source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-02 16:22:43 +0800 324) static FORCE_INLINE int tqReadHandleAddTbUidList(STqReadHandle *pHandle, const SArray *tbUidList) { -b7788aca04f source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-02 16:22:43 +0800 325) if (pHandle->tbIdHash == NULL) { -b7788aca04f source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-02 16:22:43 +0800 326) pHandle->tbIdHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_NO_LOCK); -b7788aca04f source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-02 16:22:43 +0800 327) if (pHandle->tbIdHash == NULL) { -b7788aca04f source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-02 16:22:43 +0800 328) terrno = TSDB_CODE_OUT_OF_MEMORY; -b7788aca04f source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-02 16:22:43 +0800 329) return -1; -b7788aca04f source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-02 16:22:43 +0800 330) } -b7788aca04f source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-02 16:22:43 +0800 331) } -b7788aca04f source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-02 16:22:43 +0800 332) -b7788aca04f source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-02 16:22:43 +0800 333) for (int i = 0; i < taosArrayGetSize(tbUidList); i++) { -b7788aca04f source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-02 16:22:43 +0800 334) int64_t *pKey = (int64_t *)taosArrayGet(tbUidList, i); -b7788aca04f source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-02 16:22:43 +0800 335) taosHashPut(pHandle->tbIdHash, pKey, sizeof(int64_t), NULL, 0); -b7788aca04f source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-02 16:22:43 +0800 336) } -b7788aca04f source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-02 16:22:43 +0800 337) -b7788aca04f source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-02 16:22:43 +0800 338) return 0; -b7788aca04f source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-02 16:22:43 +0800 339) } -b7788aca04f source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-03-02 16:22:43 +0800 340) -7ee6657cf72 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-02-21 10:48:23 +0800 341) int32_t tqReadHandleSetMsg(STqReadHandle *pHandle, SSubmitReq *pMsg, int64_t ver); -7ee6657cf72 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-02-21 10:48:23 +0800 342) bool tqNextDataBlock(STqReadHandle *pHandle); -7ee6657cf72 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-02-21 10:48:23 +0800 343) int tqRetrieveDataBlockInfo(STqReadHandle *pHandle, SDataBlockInfo *pBlockInfo); -35749cb3742 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-21 16:12:02 +0800 344) // return SArray -5bb010ef4af source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-28 15:24:09 +0800 345) SArray *tqRetrieveDataBlock(STqReadHandle *pHandle); -35749cb3742 source/dnode/vnode/inc/vnode.h (Liu Jicong 2022-01-21 16:12:02 +0800 346) -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 347) // meta.h -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 348) SMeta *metaOpen(const char *path, const SMetaCfg *pMetaCfg, SMemAllocatorFactory *pMAF); -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 349) void metaClose(SMeta *pMeta); -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 350) void metaRemove(const char *path); -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 351) int metaCreateTable(SMeta *pMeta, STbCfg *pTbCfg); -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 352) int metaDropTable(SMeta *pMeta, tb_uid_t uid); -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 353) int metaCommit(SMeta *pMeta); -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 354) int32_t metaCreateTSma(SMeta *pMeta, SSmaCfg *pCfg); -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 355) int32_t metaDropTSma(SMeta *pMeta, int64_t indexUid); -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 356) STbCfg *metaGetTbInfoByUid(SMeta *pMeta, tb_uid_t uid); -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 357) STbCfg *metaGetTbInfoByName(SMeta *pMeta, char *tbname, tb_uid_t *uid); -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 358) SSchemaWrapper *metaGetTableSchema(SMeta *pMeta, tb_uid_t uid, int32_t sver, bool isinline); -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 359) STSchema *metaGetTbTSchema(SMeta *pMeta, tb_uid_t uid, int32_t sver); -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 360) STSma *metaGetSmaInfoByIndex(SMeta *pMeta, int64_t indexUid); -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 361) STSmaWrapper *metaGetSmaInfoByTable(SMeta *pMeta, tb_uid_t uid); -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 362) SArray *metaGetSmaTbUids(SMeta *pMeta, bool isDup); -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 363) int metaGetTbNum(SMeta *pMeta); -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 364) SMTbCursor *metaOpenTbCursor(SMeta *pMeta); -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 365) void metaCloseTbCursor(SMTbCursor *pTbCur); -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 366) char *metaTbCursorNext(SMTbCursor *pTbCur); -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 367) SMCtbCursor *metaOpenCtbCursor(SMeta *pMeta, tb_uid_t uid); -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 368) void metaCloseCtbCurosr(SMCtbCursor *pCtbCur); -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 369) tb_uid_t metaCtbCursorNext(SMCtbCursor *pCtbCur); -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 370) -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 371) SMSmaCursor *metaOpenSmaCursor(SMeta *pMeta, tb_uid_t uid); -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 372) void metaCloseSmaCurosr(SMSmaCursor *pSmaCur); -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 373) const char *metaSmaCursorNext(SMSmaCursor *pSmaCur); -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 374) -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 375) // Options -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 376) void metaOptionsInit(SMetaCfg *pMetaCfg); -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 377) void metaOptionsClear(SMetaCfg *pMetaCfg); -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 378) -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 379) // query condition to build multi-table data block iterator -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 380) // STsdb -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 381) STsdb *tsdbOpen(const char *path, int32_t vgId, const STsdbCfg *pTsdbCfg, SMemAllocatorFactory *pMAF, SMeta *pMeta, STfs *pTfs); -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 382) void tsdbClose(STsdb *); -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 383) void tsdbRemove(const char *path); -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 384) int tsdbInsertData(STsdb *pTsdb, SSubmitReq *pMsg, SSubmitRsp *pRsp); -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 385) int tsdbPrepareCommit(STsdb *pTsdb); -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 386) int tsdbCommit(STsdb *pTsdb); -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 387) -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 388) -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 389) int32_t tsdbInitSma(STsdb *pTsdb); -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 390) int32_t tsdbCreateTSma(STsdb *pTsdb, char *pMsg); -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 391) int32_t tsdbDropTSma(STsdb *pTsdb, char *pMsg); -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 392) /** -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 393) * @brief When submit msg received, update the relative expired window synchronously. -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 394) * -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 395) * @param pTsdb -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 396) * @param msg -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 397) * @return int32_t -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 398) */ -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 399) int32_t tsdbUpdateSmaWindow(STsdb *pTsdb, SSubmitReq *pMsg); -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 400) -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 401) /** -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 402) * @brief Insert tSma(Time-range-wise SMA) data from stream computing engine -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 403) * -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 404) * @param pTsdb -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 405) * @param indexUid -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 406) * @param msg -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 407) * @return int32_t -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 408) */ -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 409) int32_t tsdbInsertTSmaData(STsdb *pTsdb, int64_t indexUid, const char *msg); -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 410) -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 411) /** -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 412) * @brief Drop tSma data and local cache. -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 413) * -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 414) * @param pTsdb -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 415) * @param indexUid -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 416) * @return int32_t -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 417) */ -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 418) int32_t tsdbDropTSmaData(STsdb *pTsdb, int64_t indexUid); -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 419) -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 420) /** -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 421) * @brief Insert RSma(Rollup SMA) data. -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 422) * -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 423) * @param pTsdb -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 424) * @param msg -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 425) * @return int32_t -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 426) */ -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 427) int32_t tsdbInsertRSmaData(STsdb *pTsdb, char *msg); -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 428) -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 429) // TODO: This is the basic params, and should wrap the params to a queryHandle. -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 430) /** -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 431) * @brief Get tSma(Time-range-wise SMA) data. -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 432) * -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 433) * @param pTsdb -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 434) * @param pData -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 435) * @param indexUid -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 436) * @param querySKey -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 437) * @param nMaxResult -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 438) * @return int32_t -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 439) */ -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 440) int32_t tsdbGetTSmaData(STsdb *pTsdb, char *pData, int64_t indexUid, TSKEY querySKey, int32_t nMaxResult); -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 441) -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 442) // STsdbCfg -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 443) int tsdbOptionsInit(STsdbCfg *); -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 444) void tsdbOptionsClear(STsdbCfg *); -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 445) -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 446) typedef void* tsdbReaderT; -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 447) -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 448) /** -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 449) * Get the data block iterator, starting from position according to the query condition -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 450) * -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 451) * @param tsdb tsdb handle -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 452) * @param pCond query condition, including time window, result set order, and basic required columns for each block -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 453) * @param tableInfoGroup table object list in the form of set, grouped into different sets according to the -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 454) * group by condition -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 455) * @param qinfo query info handle from query processor -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 456) * @return -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 457) */ -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 458) tsdbReaderT *tsdbQueryTables(STsdb *tsdb, STsdbQueryCond *pCond, STableGroupInfo *tableInfoGroup, uint64_t qId, uint64_t taskId); -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 459) -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 460) /** -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 461) * Get the last row of the given query time window for all the tables in STableGroupInfo object. -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 462) * Note that only one data block with only row will be returned while invoking retrieve data block function for -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 463) * all tables in this group. -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 464) * -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 465) * @param tsdb tsdb handle -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 466) * @param pCond query condition, including time window, result set order, and basic required columns for each block -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 467) * @param tableInfo table list. -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 468) * @return -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 469) */ -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 470) //tsdbReaderT tsdbQueryLastRow(STsdbRepo *tsdb, STsdbQueryCond *pCond, STableGroupInfo *tableInfo, uint64_t qId, -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 471) // SMemRef *pRef); -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 472) -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 473) -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 474) tsdbReaderT tsdbQueryCacheLast(STsdb *tsdb, STsdbQueryCond *pCond, STableGroupInfo *groupList, uint64_t qId, void* pMemRef); -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 475) -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 476) int32_t tsdbGetFileBlocksDistInfo(tsdbReaderT* pReader, STableBlockDistInfo* pTableBlockInfo); -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 477) -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 478) bool isTsdbCacheLastRow(tsdbReaderT* pReader); -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 479) -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 480) /** -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 481) * -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 482) * @param tsdb -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 483) * @param uid -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 484) * @param skey -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 485) * @param pTagCond -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 486) * @param len -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 487) * @param tagNameRelType -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 488) * @param tbnameCond -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 489) * @param pGroupInfo -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 490) * @param pColIndex -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 491) * @param numOfCols -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 492) * @param reqId -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 493) * @return -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 494) */ -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 495) int32_t tsdbQuerySTableByTagCond(void* pMeta, uint64_t uid, TSKEY skey, const char* pTagCond, size_t len, -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 496) int16_t tagNameRelType, const char* tbnameCond, STableGroupInfo* pGroupInfo, -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 497) SColIndex* pColIndex, int32_t numOfCols, uint64_t reqId, uint64_t taskId); -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 498) /** -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 499) * get num of rows in mem table -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 500) * -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 501) * @param pHandle -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 502) * @return row size -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 503) */ -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 504) -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 505) int64_t tsdbGetNumOfRowsInMemTable(tsdbReaderT* pHandle); -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 506) -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 507) /** -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 508) * move to next block if exists -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 509) * -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 510) * @param pTsdbReadHandle -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 511) * @return -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 512) */ -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 513) bool tsdbNextDataBlock(tsdbReaderT pTsdbReadHandle); -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 514) -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 515) /** -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 516) * Get current data block information -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 517) * -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 518) * @param pTsdbReadHandle -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 519) * @param pBlockInfo -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 520) * @return -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 521) */ -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 522) void tsdbRetrieveDataBlockInfo(tsdbReaderT *pTsdbReadHandle, SDataBlockInfo *pBlockInfo); -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 523) -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 524) /** -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 525) * -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 526) * Get the pre-calculated information w.r.t. current data block. -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 527) * -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 528) * In case of data block in cache, the pBlockStatis will always be NULL. -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 529) * If a block is not completed loaded from disk, the pBlockStatis will be NULL. -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 530) -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 531) * @pBlockStatis the pre-calculated value for current data blocks. if the block is a cache block, always return 0 -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 532) * @return -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 533) */ -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 534) int32_t tsdbRetrieveDataBlockStatisInfo(tsdbReaderT *pTsdbReadHandle, SDataStatis **pBlockStatis); -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 535) -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 536) /** -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 537) * -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 538) * The query condition with primary timestamp is passed to iterator during its constructor function, -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 539) * the returned data block must be satisfied with the time window condition in any cases, -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 540) * which means the SData data block is not actually the completed disk data blocks. -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 541) * -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 542) * @param pTsdbReadHandle query handle -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 543) * @param pColumnIdList required data columns id list -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 544) * @return -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 545) */ -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 546) SArray *tsdbRetrieveDataBlock(tsdbReaderT *pTsdbReadHandle, SArray *pColumnIdList); -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 547) -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 548) /** -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 549) * destroy the created table group list, which is generated by tag query -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 550) * @param pGroupList -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 551) */ -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 552) void tsdbDestroyTableGroup(STableGroupInfo *pGroupList); -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 553) -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 554) /** -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 555) * create the table group result including only one table, used to handle the normal table query -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 556) * -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 557) * @param tsdb tsdbHandle -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 558) * @param uid table uid -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 559) * @param pGroupInfo the generated result -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 560) * @return -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 561) */ -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 562) int32_t tsdbGetOneTableGroup(void *pMeta, uint64_t uid, TSKEY startKey, STableGroupInfo *pGroupInfo); -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 563) -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 564) /** -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 565) * -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 566) * @param tsdb -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 567) * @param pTableIdList -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 568) * @param pGroupInfo -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 569) * @return -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 570) */ -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 571) int32_t tsdbGetTableGroupFromIdList(STsdb *tsdb, SArray *pTableIdList, STableGroupInfo *pGroupInfo); -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 572) -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 573) /** -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 574) * clean up the query handle -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 575) * @param queryHandle -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 576) */ -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 577) void tsdbCleanupReadHandle(tsdbReaderT queryHandle); -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 578) -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 579) int32_t tdScanAndConvertSubmitMsg(SSubmitReq *pMsg); -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 580) -6faaafb7a2f source/dnode/vnode/inc/vnode.h (Hongze Cheng 2022-04-08 06:09:15 +0000 581) -ce7a1600eb4 include/server/vnode/vnode.h (Shengliang Guan 2021-09-22 20:29:24 +0800 582) #ifdef __cplusplus -ce7a1600eb4 include/server/vnode/vnode.h (Shengliang Guan 2021-09-22 20:29:24 +0800 583) } -ce7a1600eb4 include/server/vnode/vnode.h (Shengliang Guan 2021-09-22 20:29:24 +0800 584) #endif -ce7a1600eb4 include/server/vnode/vnode.h (Shengliang Guan 2021-09-22 20:29:24 +0800 585) -daafc0feb7f include/server/vnode/vnode.h (Shengliang Guan 2021-09-29 19:26:11 +0800 586) #endif /*_TD_VNODE_H_*/ diff --git a/source/dnode/vnode/src/vnd/vnodeQuery.c b/source/dnode/vnode/src/vnd/vnodeQuery.c index 3747e1dbc7..6280542ffe 100644 --- a/source/dnode/vnode/src/vnd/vnodeQuery.c +++ b/source/dnode/vnode/src/vnd/vnodeQuery.c @@ -22,21 +22,21 @@ int vnodeQueryOpen(SVnode *pVnode) { void vnodeQueryClose(SVnode *pVnode) { qWorkerDestroy((void **)&pVnode->pQuery); } int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg) { - STbCfg *pTbCfg = NULL; - STbCfg *pStbCfg = NULL; + STbCfg * pTbCfg = NULL; + STbCfg * pStbCfg = NULL; tb_uid_t uid; int32_t nCols; int32_t nTagCols; SSchemaWrapper *pSW = NULL; - STableMetaRsp *pTbMetaMsg = NULL; + STableMetaRsp * pTbMetaMsg = NULL; STableMetaRsp metaRsp = {0}; - SSchema *pTagSchema; + SSchema * pTagSchema; SRpcMsg rpcMsg; int msgLen = 0; int32_t code = 0; char tableFName[TSDB_TABLE_FNAME_LEN]; int32_t rspLen = 0; - void *pRsp = NULL; + void * pRsp = NULL; STableInfoReq infoReq = {0}; if (tDeserializeSTableInfoReq(pMsg->pCont, pMsg->contLen, &infoReq) != 0) { @@ -142,6 +142,7 @@ _exit: rpcMsg.handle = pMsg->handle; rpcMsg.ahandle = pMsg->ahandle; + rpcMsg.refId = pMsg->refId; rpcMsg.pCont = pRsp; rpcMsg.contLen = rspLen; rpcMsg.code = code; diff --git a/source/libs/transport/src/transSrv.c b/source/libs/transport/src/transSrv.c index 6bb8e0c1c5..9ba84c21b5 100644 --- a/source/libs/transport/src/transSrv.c +++ b/source/libs/transport/src/transSrv.c @@ -1017,9 +1017,11 @@ void transReleaseSrvHandle(void* handle) { uvReleaseExHandle(refId); return; _return1: + tTrace("server handle %p failed to send to release handle", exh); uvReleaseExHandle(refId); return; _return2: + tTrace("server handle %p failed to send to release handle", exh); return; } void transSendResponse(const STransMsg* msg) { @@ -1041,10 +1043,12 @@ void transSendResponse(const STransMsg* msg) { uvReleaseExHandle(refId); return; _return1: + tTrace("server handle %p failed to send resp", exh); rpcFreeCont(msg->pCont); uvReleaseExHandle(refId); return; _return2: + tTrace("server handle %p failed to send resp", exh); rpcFreeCont(msg->pCont); return; } @@ -1067,10 +1071,12 @@ void transRegisterMsg(const STransMsg* msg) { uvReleaseExHandle(refId); return; _return1: + tTrace("server handle %p failed to send to register brokenlink", exh); rpcFreeCont(msg->pCont); uvReleaseExHandle(refId); return; _return2: + tTrace("server handle %p failed to send to register brokenlink", exh); rpcFreeCont(msg->pCont); } From d8a82e322391b0e4e1b29f38a24b1f650fb60643 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Sun, 24 Apr 2022 12:11:27 +0800 Subject: [PATCH 04/11] fix hb problem --- source/dnode/mgmt/mgmt_vnode/src/vmWorker.c | 1 + source/dnode/vnode/src/vnd/vnodeSync.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c b/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c index d8a9952fed..7285503a73 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c @@ -348,6 +348,7 @@ static int32_t vmPutRpcMsgToQueue(SMgmtWrapper *pWrapper, SRpcMsg *pRpc, EQueueT } else { dTrace("msg:%p, is created, type:%s", pMsg, TMSG_INFO(pRpc->msgType)); pMsg->rpcMsg = *pRpc; + // if (pMsg->rpcMsg.handle != NULL) assert(pMsg->rpcMsg.refId != 0); switch (qtype) { case QUERY_QUEUE: dTrace("msg:%p, will be put into vnode-query queue", pMsg); diff --git a/source/dnode/vnode/src/vnd/vnodeSync.c b/source/dnode/vnode/src/vnd/vnodeSync.c index 546e925106..5f8bf3c7b5 100644 --- a/source/dnode/vnode/src/vnd/vnodeSync.c +++ b/source/dnode/vnode/src/vnd/vnodeSync.c @@ -113,7 +113,7 @@ void vnodeSyncCommitCb(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cb pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncUtilState2String(cbMeta.state), beginIndex); syncRpcMsgLog2(logBuf, (SRpcMsg *)pMsg); - SVnode *pVnode = (SVnode *)(pFsm->data); + SVnode * pVnode = (SVnode *)(pFsm->data); SyncApplyMsg *pSyncApplyMsg = syncApplyMsgBuild2(pMsg, pVnode->config.vgId, &cbMeta); SRpcMsg applyMsg; syncApplyMsg2RpcMsg(pSyncApplyMsg, &applyMsg); @@ -133,6 +133,7 @@ void vnodeSyncCommitCb(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cb if (ret == 1 && cbMeta.state == TAOS_SYNC_STATE_LEADER) { applyMsg.handle = saveRpcMsg.handle; applyMsg.ahandle = saveRpcMsg.ahandle; + applyMsg.refId = saveRpcMsg.refId; } else { applyMsg.handle = NULL; applyMsg.ahandle = NULL; From bd70f5e104d407b2a3d933a1bc9544f41a9204d9 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Sun, 24 Apr 2022 14:35:21 +0800 Subject: [PATCH 05/11] fix(cluster): disable startup on create dir failed --- source/common/src/tglobal.c | 14 ++++--- source/dnode/mgmt/exe/dmMain.c | 2 +- source/util/src/tconfig.c | 73 +++++++++++++++++----------------- 3 files changed, 45 insertions(+), 44 deletions(-) diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c index b41bcd7145..46e9654a69 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -237,18 +237,20 @@ static int32_t taosLoadCfg(SConfig *pCfg, const char *inputCfgDir, const char *e char cfgFile[PATH_MAX + 100] = {0}; taosExpandDir(inputCfgDir, cfgDir, PATH_MAX); - snprintf(cfgFile, sizeof(cfgFile), "%s" TD_DIRSEP "taos.cfg", cfgDir); + if (taosIsDir(cfgDir)) { + snprintf(cfgFile, sizeof(cfgFile), "%s" TD_DIRSEP "taos.cfg", cfgDir); + } else { + tstrncpy(cfgFile, cfgDir, sizeof(cfgDir)); + } if (cfgLoad(pCfg, CFG_STYPE_APOLLO_URL, apolloUrl) != 0) { uError("failed to load from apollo url:%s since %s", apolloUrl, terrstr()); return -1; } - if (cfgLoad(pCfg, CFG_STYPE_CFG_FILE, cfgDir) != 0) { - if (cfgLoad(pCfg, CFG_STYPE_CFG_FILE, cfgFile) != 0) { - uInfo("cfg file:%s not read since %s", cfgFile, terrstr()); - return 0; - } + if (cfgLoad(pCfg, CFG_STYPE_CFG_FILE, cfgFile) != 0) { + uError("failed to load from cfg file:%s since %s", cfgFile, terrstr()); + return -1; } if (cfgLoad(pCfg, CFG_STYPE_ENV_FILE, envFile) != 0) { diff --git a/source/dnode/mgmt/exe/dmMain.c b/source/dnode/mgmt/exe/dmMain.c index 7e4505ec95..b8ace4bf50 100644 --- a/source/dnode/mgmt/exe/dmMain.c +++ b/source/dnode/mgmt/exe/dmMain.c @@ -190,7 +190,7 @@ int main(int argc, char const *argv[]) { } if (dmInitLog() != 0) { - printf("failed to start since init log error\n"); + dError("failed to start since init log error"); return -1; } diff --git a/source/util/src/tconfig.c b/source/util/src/tconfig.c index eea5c9fecc..ec63a7ced4 100644 --- a/source/util/src/tconfig.c +++ b/source/util/src/tconfig.c @@ -139,12 +139,6 @@ static int32_t cfgCheckAndSetDir(SConfigItem *pItem, const char *inputDir) { return -1; } - if (taosRealPath(fullDir, NULL, PATH_MAX) != 0) { - terrno = TAOS_SYSTEM_ERROR(errno); - uError("failed to get realpath of dir:%s since %s", inputDir, terrstr()); - return -1; - } - taosMemoryFreeClear(pItem->str); pItem->str = strdup(fullDir); if (pItem->str == NULL) { @@ -172,9 +166,8 @@ static int32_t cfgSetBool(SConfigItem *pItem, const char *value, ECfgSrcType sty static int32_t cfgSetInt32(SConfigItem *pItem, const char *value, ECfgSrcType stype) { int32_t ival = (int32_t)atoi(value); if (ival < pItem->imin || ival > pItem->imax) { - uError("cfg:%s, type:%s src:%s value:%d out of range[%" PRId64 ", %" PRId64 "], use last src:%s value:%d", - pItem->name, cfgDtypeStr(pItem->dtype), cfgStypeStr(stype), ival, pItem->imin, pItem->imax, - cfgStypeStr(pItem->stype), pItem->i32); + uError("cfg:%s, type:%s src:%s value:%d out of range[%" PRId64 ", %" PRId64 "]", pItem->name, + cfgDtypeStr(pItem->dtype), cfgStypeStr(stype), ival, pItem->imin, pItem->imax); terrno = TSDB_CODE_OUT_OF_RANGE; return -1; } @@ -187,10 +180,8 @@ static int32_t cfgSetInt32(SConfigItem *pItem, const char *value, ECfgSrcType st static int32_t cfgSetInt64(SConfigItem *pItem, const char *value, ECfgSrcType stype) { int64_t ival = (int64_t)atoi(value); if (ival < pItem->imin || ival > pItem->imax) { - uError("cfg:%s, type:%s src:%s value:%" PRId64 " out of range[%" PRId64 ", %" PRId64 - "], use last src:%s value:%" PRId64, - pItem->name, cfgDtypeStr(pItem->dtype), cfgStypeStr(stype), ival, pItem->imin, pItem->imax, - cfgStypeStr(pItem->stype), pItem->i64); + uError("cfg:%s, type:%s src:%s value:%" PRId64 " out of range[%" PRId64 ", %" PRId64 "]", pItem->name, + cfgDtypeStr(pItem->dtype), cfgStypeStr(stype), ival, pItem->imin, pItem->imax); terrno = TSDB_CODE_OUT_OF_RANGE; return -1; } @@ -203,9 +194,8 @@ static int32_t cfgSetInt64(SConfigItem *pItem, const char *value, ECfgSrcType st static int32_t cfgSetFloat(SConfigItem *pItem, const char *value, ECfgSrcType stype) { float fval = (float)atof(value); if (fval < pItem->fmin || fval > pItem->fmax) { - uError("cfg:%s, type:%s src:%s value:%f out of range[%f, %f], use last src:%s value:%f", pItem->name, - cfgDtypeStr(pItem->dtype), cfgStypeStr(stype), fval, pItem->fmin, pItem->fmax, cfgStypeStr(pItem->stype), - pItem->fval); + uError("cfg:%s, type:%s src:%s value:%f out of range[%f, %f]", pItem->name, cfgDtypeStr(pItem->dtype), + cfgStypeStr(stype), fval, pItem->fmin, pItem->fmax); terrno = TSDB_CODE_OUT_OF_RANGE; return -1; } @@ -219,8 +209,8 @@ static int32_t cfgSetString(SConfigItem *pItem, const char *value, ECfgSrcType s char *tmp = strdup(value); if (tmp == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; - uError("cfg:%s, type:%s src:%s value:%s failed to dup since %s, use last src:%s value:%s", pItem->name, - cfgDtypeStr(pItem->dtype), cfgStypeStr(stype), value, terrstr(), cfgStypeStr(pItem->stype), pItem->str); + uError("cfg:%s, type:%s src:%s value:%s failed to dup since %s", pItem->name, cfgDtypeStr(pItem->dtype), + cfgStypeStr(stype), value, terrstr()); return -1; } @@ -232,9 +222,8 @@ static int32_t cfgSetString(SConfigItem *pItem, const char *value, ECfgSrcType s static int32_t cfgSetDir(SConfigItem *pItem, const char *value, ECfgSrcType stype) { if (cfgCheckAndSetDir(pItem, value) != 0) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - uError("cfg:%s, type:%s src:%s value:%s failed to dup since %s, use last src:%s value:%s", pItem->name, - cfgDtypeStr(pItem->dtype), cfgStypeStr(stype), value, terrstr(), cfgStypeStr(pItem->stype), pItem->str); + uError("cfg:%s, type:%s src:%s value:%s failed to dup since %s", pItem->name, cfgDtypeStr(pItem->dtype), + cfgStypeStr(stype), value, terrstr()); return -1; } @@ -245,8 +234,8 @@ static int32_t cfgSetDir(SConfigItem *pItem, const char *value, ECfgSrcType styp static int32_t cfgSetLocale(SConfigItem *pItem, const char *value, ECfgSrcType stype) { if (cfgCheckAndSetLocale(pItem, value) != 0) { terrno = TSDB_CODE_OUT_OF_MEMORY; - uError("cfg:%s, type:%s src:%s value:%s failed to dup since %s, use last src:%s value:%s", pItem->name, - cfgDtypeStr(pItem->dtype), cfgStypeStr(stype), value, terrstr(), cfgStypeStr(pItem->stype), pItem->str); + uError("cfg:%s, type:%s src:%s value:%s failed to dup since %s", pItem->name, cfgDtypeStr(pItem->dtype), + cfgStypeStr(stype), value, terrstr()); return -1; } @@ -257,8 +246,8 @@ static int32_t cfgSetLocale(SConfigItem *pItem, const char *value, ECfgSrcType s static int32_t cfgSetCharset(SConfigItem *pItem, const char *value, ECfgSrcType stype) { if (cfgCheckAndSetCharset(pItem, value) != 0) { terrno = TSDB_CODE_OUT_OF_MEMORY; - uError("cfg:%s, type:%s src:%s value:%s failed to dup since %s, use last src:%s value:%s", pItem->name, - cfgDtypeStr(pItem->dtype), cfgStypeStr(stype), value, terrstr(), cfgStypeStr(pItem->stype), pItem->str); + uError("cfg:%s, type:%s src:%s value:%s failed to dup since %s", pItem->name, cfgDtypeStr(pItem->dtype), + cfgStypeStr(stype), value, terrstr()); return -1; } @@ -269,8 +258,8 @@ static int32_t cfgSetCharset(SConfigItem *pItem, const char *value, ECfgSrcType static int32_t cfgSetTimezone(SConfigItem *pItem, const char *value, ECfgSrcType stype) { if (cfgCheckAndSetTimezone(pItem, value) != 0) { terrno = TSDB_CODE_OUT_OF_MEMORY; - uError("cfg:%s, type:%s src:%s value:%s failed to dup since %s, use last src:%s value:%s", pItem->name, - cfgDtypeStr(pItem->dtype), cfgStypeStr(stype), value, terrstr(), cfgStypeStr(pItem->stype), pItem->str); + uError("cfg:%s, type:%s src:%s value:%s failed to dup since %s", pItem->name, cfgDtypeStr(pItem->dtype), + cfgStypeStr(stype), value, terrstr()); return -1; } @@ -606,15 +595,19 @@ int32_t cfgLoadFromCfgFile(SConfig *pConfig, const char *filepath) { char *line = NULL, *name, *value, *value2, *value3; int32_t olen, vlen, vlen2, vlen3; ssize_t _bytes = 0; - - if (taosIsDir(filepath)) { - return -1; - } + int32_t code = 0; TdFilePtr pFile = taosOpenFile(filepath, TD_FILE_READ | TD_FILE_STREAM); if (pFile == NULL) { - terrno = TAOS_SYSTEM_ERROR(errno); - return -1; + // success when the file does not exist + if (errno == ENOENT) { + terrno = TAOS_SYSTEM_ERROR(errno); + uInfo("failed to load from cfg file %s since %s, use default parameters", filepath, terrstr()); + return 0; + } else { + uError("failed to load from cfg file %s since %s", filepath, terrstr()); + return -1; + } } while (!taosEOFFile(pFile)) { @@ -643,17 +636,23 @@ int32_t cfgLoadFromCfgFile(SConfig *pConfig, const char *filepath) { if (vlen3 != 0) value3[vlen3] = 0; } - cfgSetItem(pConfig, name, value, CFG_STYPE_CFG_FILE); + code = cfgSetItem(pConfig, name, value, CFG_STYPE_CFG_FILE); + if (code != 0 && terrno != TSDB_CODE_CFG_NOT_FOUND) break; if (value2 != NULL && value3 != NULL && value2[0] != 0 && value3[0] != 0 && strcasecmp(name, "dataDir") == 0) { - cfgSetTfsItem(pConfig, name, value, value2, value3, CFG_STYPE_CFG_FILE); + code = cfgSetTfsItem(pConfig, name, value, value2, value3, CFG_STYPE_CFG_FILE); + if (code != 0 && terrno != TSDB_CODE_CFG_NOT_FOUND) break; } } taosCloseFile(&pFile); if (line != NULL) taosMemoryFreeClear(line); - uInfo("load from cfg file %s success", filepath); - return 0; + if (code == 0) { + uInfo("load from cfg file %s success", filepath); + } else { + uError("failed to load from cfg file %s since %s", filepath, terrstr()); + } + return code; } int32_t cfgLoadFromApollUrl(SConfig *pConfig, const char *url) { From 4ae6e090d8e275b6ef0a3eff07652b55edde1b69 Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Sun, 24 Apr 2022 15:29:53 +0800 Subject: [PATCH 06/11] fix hb broken link issue --- source/libs/qworker/src/qworkerMsg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/libs/qworker/src/qworkerMsg.c b/source/libs/qworker/src/qworkerMsg.c index 6723eb21c1..e0bcfabdd3 100644 --- a/source/libs/qworker/src/qworkerMsg.c +++ b/source/libs/qworker/src/qworkerMsg.c @@ -339,7 +339,7 @@ int32_t qwRegisterHbBrokenLinkArg(SQWorkerMgmt *mgmt, uint64_t sId, SQWConnInfo .ahandle = pConn->ahandle, .msgType = TDMT_VND_QUERY_HEARTBEAT, .pCont = msg, - .contLen = sizeof(SSchedulerHbReq), + .contLen = msgSize, .code = TSDB_CODE_RPC_NETWORK_UNAVAIL, }; From a23db2da8a89778907425abbdfe057d81851b25d Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Sun, 24 Apr 2022 17:36:17 +0800 Subject: [PATCH 07/11] fix(cluster): repair dmnodeTest --- source/dnode/mgmt/mgmt_mnode/src/mmHandle.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c b/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c index 159e14a3d5..b434cf102e 100644 --- a/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c +++ b/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c @@ -134,9 +134,9 @@ int32_t mmProcessAlterReq(SMnodeMgmt *pMgmt, SNodeMsg *pMsg) { return -1; } - if (alterReq.dnodeId != pDnode->data.dnodeId) { + if (pDnode->data.dnodeId != 0 && alterReq.dnodeId != pDnode->data.dnodeId) { terrno = TSDB_CODE_INVALID_OPTION; - dError("failed to alter mnode since %s, dnodeId:%d input:%d", terrstr(), pDnode->data.dnodeId, alterReq.dnodeId); + dError("failed to alter mnode since %s, input:%d cur:%d", terrstr(), alterReq.dnodeId, pDnode->data.dnodeId); return -1; } else { return mmAlter(pMgmt, &alterReq); From c5ea02c4edf33499d2cde4522cbb1903c60025a2 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Sun, 24 Apr 2022 17:51:34 +0800 Subject: [PATCH 08/11] fix(cluster): disable startup on create dir failed --- source/dnode/mgmt/mgmt_bnode/src/bmHandle.c | 2 +- source/util/src/tconfig.c | 5 ++-- source/util/src/tlog.c | 31 ++++++++++----------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/source/dnode/mgmt/mgmt_bnode/src/bmHandle.c b/source/dnode/mgmt/mgmt_bnode/src/bmHandle.c index 49bf9201e1..3b314b1d2b 100644 --- a/source/dnode/mgmt/mgmt_bnode/src/bmHandle.c +++ b/source/dnode/mgmt/mgmt_bnode/src/bmHandle.c @@ -53,7 +53,7 @@ int32_t bmProcessCreateReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) { return -1; } - if (createReq.dnodeId != pDnode->data.dnodeId) { + if (pDnode->data.dnodeId != 0 && createReq.dnodeId != pDnode->data.dnodeId) { terrno = TSDB_CODE_INVALID_OPTION; dError("failed to create bnode since %s, input:%d cur:%d", terrstr(), createReq.dnodeId, pDnode->data.dnodeId); return -1; diff --git a/source/util/src/tconfig.c b/source/util/src/tconfig.c index ec63a7ced4..6f6ae5d699 100644 --- a/source/util/src/tconfig.c +++ b/source/util/src/tconfig.c @@ -647,12 +647,13 @@ int32_t cfgLoadFromCfgFile(SConfig *pConfig, const char *filepath) { taosCloseFile(&pFile); if (line != NULL) taosMemoryFreeClear(line); - if (code == 0) { + if (code == 0 || (code != 0 && terrno == TSDB_CODE_CFG_NOT_FOUND)) { uInfo("load from cfg file %s success", filepath); + return 0; } else { uError("failed to load from cfg file %s since %s", filepath, terrstr()); + return -1; } - return code; } int32_t cfgLoadFromApollUrl(SConfig *pConfig, const char *url) { diff --git a/source/util/src/tlog.c b/source/util/src/tlog.c index 23fe2e8301..3564700d53 100644 --- a/source/util/src/tlog.c +++ b/source/util/src/tlog.c @@ -137,24 +137,23 @@ static void taosStopLog() { } } -static void taosLogBuffDestroy() { - taosThreadMutexDestroy(&tsLogObj.logHandle->buffMutex); - taosCloseFile(&tsLogObj.logHandle->pFile); - taosMemoryFreeClear(tsLogObj.logHandle->buffer); - memset(&tsLogObj.logHandle->buffer, 0, sizeof(tsLogObj.logHandle->buffer)); - taosThreadMutexDestroy(&tsLogObj.logMutex); - taosMemoryFreeClear(tsLogObj.logHandle); - memset(&tsLogObj.logHandle, 0, sizeof(tsLogObj.logHandle)); - tsLogObj.logHandle = NULL; -} - void taosCloseLog() { - taosStopLog(); - if (taosCheckPthreadValid(tsLogObj.logHandle->asyncThread)) { - taosThreadJoin(tsLogObj.logHandle->asyncThread, NULL); + if (tsLogObj.logHandle != NULL) { + taosStopLog(); + if (tsLogObj.logHandle != NULL && taosCheckPthreadValid(tsLogObj.logHandle->asyncThread)) { + taosThreadJoin(tsLogObj.logHandle->asyncThread, NULL); + } + tsLogInited = 0; + + taosThreadMutexDestroy(&tsLogObj.logHandle->buffMutex); + taosCloseFile(&tsLogObj.logHandle->pFile); + taosMemoryFreeClear(tsLogObj.logHandle->buffer); + memset(&tsLogObj.logHandle->buffer, 0, sizeof(tsLogObj.logHandle->buffer)); + taosThreadMutexDestroy(&tsLogObj.logMutex); + taosMemoryFreeClear(tsLogObj.logHandle); + memset(&tsLogObj.logHandle, 0, sizeof(tsLogObj.logHandle)); + tsLogObj.logHandle = NULL; } - tsLogInited = 0; - taosLogBuffDestroy(tsLogObj.logHandle); } static bool taosLockLogFile(TdFilePtr pFile) { From 4cf04e264e580081ad669540541091f6b3f0e4cc Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Sun, 24 Apr 2022 17:54:01 +0800 Subject: [PATCH 09/11] fix heartbeat problem --- source/libs/transport/src/transSrv.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/source/libs/transport/src/transSrv.c b/source/libs/transport/src/transSrv.c index f9b9bb4cda..e0984eb24c 100644 --- a/source/libs/transport/src/transSrv.c +++ b/source/libs/transport/src/transSrv.c @@ -20,6 +20,7 @@ static TdThreadOnce transModuleInit = PTHREAD_ONCE_INIT; static char* notify = "a"; +static int transSrvInst = 0; typedef struct { int notifyCount; // @@ -757,8 +758,6 @@ static void destroyConn(SSrvConn* conn, bool clear) { if (conn == NULL) { return; } - uvReleaseExHandle(conn->refId); - uvRemoveExHandle(conn->refId); transDestroyBuffer(&conn->readBuf); if (clear) { @@ -774,6 +773,9 @@ static void uvDestroyConn(uv_handle_t* handle) { } SWorkThrdObj* thrd = conn->hostThrd; + uvReleaseExHandle(conn->refId); + uvRemoveExHandle(conn->refId); + tDebug("server conn %p destroy", conn); // uv_timer_stop(&conn->pTimer); transQueueDestroy(&conn->srvMsgs); @@ -799,6 +801,7 @@ void* transInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads, uv_loop_init(srv->loop); taosThreadOnce(&transModuleInit, uvInitExHandleMgt); + transSrvInst++; // uvOpenExHandleMgt(10000); for (int i = 0; i < srv->numOfThreads; i++) { @@ -974,7 +977,10 @@ void transCloseServer(void* arg) { taosMemoryFree(srv); - // uvCloseExHandleMgt(); + transSrvInst--; + if (transSrvInst == 0) { + uvCloseExHandleMgt(); + } } void transRefSrvHandle(void* handle) { From 5e7da3511d8d413a5a3a0895f9987953415e9910 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Sun, 24 Apr 2022 18:22:00 +0800 Subject: [PATCH 10/11] fix(cluster): add refid in rpc, and handle it in multi-process mode --- include/util/tprocess.h | 4 +-- source/dnode/mgmt/implement/src/dmTransport.c | 4 +-- source/util/src/tprocess.c | 23 +++++++++----- source/util/test/procTest.cpp | 31 +++++++++++-------- 4 files changed, 37 insertions(+), 25 deletions(-) diff --git a/include/util/tprocess.h b/include/util/tprocess.h index 2b0fd89aa5..7e1767441e 100644 --- a/include/util/tprocess.h +++ b/include/util/tprocess.h @@ -53,8 +53,8 @@ int32_t taosProcRun(SProcObj *pProc); void taosProcStop(SProcObj *pProc); int32_t taosProcPutToChildQ(SProcObj *pProc, const void *pHead, int16_t headLen, const void *pBody, int32_t bodyLen, - void *handle, EProcFuncType ftype); -void taosProcRemoveHandle(SProcObj *pProc, void *handle); + void *handle, int64_t handleRef, EProcFuncType ftype); +int64_t taosProcRemoveHandle(SProcObj *pProc, void *handle); void taosProcCloseHandles(SProcObj *pProc, void (*HandleFp)(void *handle)); void taosProcPutToParentQ(SProcObj *pProc, const void *pHead, int16_t headLen, const void *pBody, int32_t bodyLen, EProcFuncType ftype); diff --git a/source/dnode/mgmt/implement/src/dmTransport.c b/source/dnode/mgmt/implement/src/dmTransport.c index 404438238b..96bf69be31 100644 --- a/source/dnode/mgmt/implement/src/dmTransport.c +++ b/source/dnode/mgmt/implement/src/dmTransport.c @@ -88,7 +88,7 @@ static void dmProcessRpcMsg(SMgmtWrapper *pWrapper, SRpcMsg *pRpc, SEpSet *pEpSe dTrace("msg:%p, is created and put into child queue, type:%s handle:%p user:%s", pMsg, TMSG_INFO(msgType), pRpc->handle, pMsg->user); code = taosProcPutToChildQ(pWrapper->procObj, pMsg, sizeof(SNodeMsg), pRpc->pCont, pRpc->contLen, pRpc->handle, - PROC_FUNC_REQ); + pRpc->refId, PROC_FUNC_REQ); } else { dTrace("msg:%p, should not processed in child process, handle:%p user:%s", pMsg, pRpc->handle, pMsg->user); ASSERT(1); @@ -356,7 +356,7 @@ static void dmConsumeParentQueue(SMgmtWrapper *pWrapper, SRpcMsg *pMsg, int16_t dmSendRpcReq(pWrapper->pDnode, (SEpSet *)((char *)pMsg + sizeof(SRpcMsg)), pMsg); break; case PROC_FUNC_RSP: - taosProcRemoveHandle(pWrapper->procObj, pMsg->handle); + pMsg->refId = taosProcRemoveHandle(pWrapper->procObj, pMsg->handle); dmSendRpcRsp(pWrapper->pDnode, pMsg); break; default: diff --git a/source/util/src/tprocess.c b/source/util/src/tprocess.c index 03c9c255b0..d8343bc427 100644 --- a/source/util/src/tprocess.c +++ b/source/util/src/tprocess.c @@ -154,7 +154,8 @@ static void taosProcCleanupQueue(SProcQueue *pQueue) { } static int32_t taosProcQueuePush(SProcObj *pProc, SProcQueue *pQueue, const char *pHead, int16_t rawHeadLen, - const char *pBody, int32_t rawBodyLen, int64_t handle, EProcFuncType ftype) { + const char *pBody, int32_t rawBodyLen, int64_t handle, int64_t handleRef, + EProcFuncType ftype) { if (rawHeadLen == 0 || pHead == NULL) { terrno = TSDB_CODE_INVALID_PARA; return -1; @@ -172,7 +173,7 @@ static int32_t taosProcQueuePush(SProcObj *pProc, SProcQueue *pQueue, const char } if (handle != 0 && ftype == PROC_FUNC_REQ) { - if (taosHashPut(pProc->hash, &handle, sizeof(int64_t), &handle, sizeof(int64_t)) != 0) { + if (taosHashPut(pProc->hash, &handle, sizeof(int64_t), &handleRef, sizeof(int64_t)) != 0) { taosThreadMutexUnlock(&pQueue->mutex); terrno = TSDB_CODE_OUT_OF_MEMORY; return -1; @@ -286,13 +287,13 @@ static int32_t taosProcQueuePop(SProcQueue *pQueue, void **ppHead, int16_t *pHea pQueue->head = headLen + bodyLen; } else if (remain < 8 + headLen) { memcpy(pHead, pQueue->pBuffer + pQueue->head + 8, remain - 8); - memcpy((char*)pHead + remain - 8, pQueue->pBuffer, headLen - (remain - 8)); + memcpy((char *)pHead + remain - 8, pQueue->pBuffer, headLen - (remain - 8)); memcpy(pBody, pQueue->pBuffer + headLen - (remain - 8), bodyLen); pQueue->head = headLen - (remain - 8) + bodyLen; } else if (remain < 8 + headLen + bodyLen) { memcpy(pHead, pQueue->pBuffer + pQueue->head + 8, headLen); memcpy(pBody, pQueue->pBuffer + pQueue->head + 8 + headLen, remain - 8 - headLen); - memcpy((char*)pBody + remain - 8 - headLen, pQueue->pBuffer, bodyLen - (remain - 8 - headLen)); + memcpy((char *)pBody + remain - 8 - headLen, pQueue->pBuffer, bodyLen - (remain - 8 - headLen)); pQueue->head = bodyLen - (remain - 8 - headLen); } else { memcpy(pHead, pQueue->pBuffer + pQueue->head + 8, headLen); @@ -454,19 +455,25 @@ void taosProcCleanup(SProcObj *pProc) { } int32_t taosProcPutToChildQ(SProcObj *pProc, const void *pHead, int16_t headLen, const void *pBody, int32_t bodyLen, - void *handle, EProcFuncType ftype) { + void *handle, int64_t handleRef, EProcFuncType ftype) { if (ftype != PROC_FUNC_REQ) { terrno = TSDB_CODE_INVALID_PARA; return -1; } - return taosProcQueuePush(pProc, pProc->pChildQueue, pHead, headLen, pBody, bodyLen, (int64_t)handle, ftype); + return taosProcQueuePush(pProc, pProc->pChildQueue, pHead, headLen, pBody, bodyLen, (int64_t)handle, handleRef, + ftype); } -void taosProcRemoveHandle(SProcObj *pProc, void *handle) { +int64_t taosProcRemoveHandle(SProcObj *pProc, void *handle) { int64_t h = (int64_t)handle; taosThreadMutexLock(&pProc->pChildQueue->mutex); + + int64_t *handleRef = taosHashGet(pProc->hash, &h, sizeof(int64_t)); taosHashRemove(pProc->hash, &h, sizeof(int64_t)); taosThreadMutexUnlock(&pProc->pChildQueue->mutex); + + if (handleRef == NULL) return 0; + return *handleRef; } void taosProcCloseHandles(SProcObj *pProc, void (*HandleFp)(void *handle)) { @@ -484,7 +491,7 @@ void taosProcCloseHandles(SProcObj *pProc, void (*HandleFp)(void *handle)) { void taosProcPutToParentQ(SProcObj *pProc, const void *pHead, int16_t headLen, const void *pBody, int32_t bodyLen, EProcFuncType ftype) { int32_t retry = 0; - while (taosProcQueuePush(pProc, pProc->pParentQueue, pHead, headLen, pBody, bodyLen, 0, ftype) != 0) { + while (taosProcQueuePush(pProc, pProc->pParentQueue, pHead, headLen, pBody, bodyLen, 0, 0, ftype) != 0) { uWarn("proc:%s, failed to put to queue:%p since %s, retry:%d", pProc->name, pProc->pParentQueue, terrstr(), retry); retry++; taosMsleep(retry); diff --git a/source/util/test/procTest.cpp b/source/util/test/procTest.cpp index 3c014369fb..7ffec04a40 100644 --- a/source/util/test/procTest.cpp +++ b/source/util/test/procTest.cpp @@ -120,20 +120,20 @@ TEST_F(UtilTesProc, 01_Push_Pop_Child) { SProcObj *cproc = taosProcInit(&cfg); ASSERT_NE(cproc, nullptr); - ASSERT_NE(taosProcPutToChildQ(cproc, &head, 0, body, 0, 0, PROC_FUNC_RSP), 0); - ASSERT_NE(taosProcPutToChildQ(cproc, &head, 0, body, 0, 0, PROC_FUNC_REGIST), 0); - ASSERT_NE(taosProcPutToChildQ(cproc, &head, 0, body, 0, 0, PROC_FUNC_RELEASE), 0); - ASSERT_NE(taosProcPutToChildQ(cproc, NULL, 12, body, 0, 0, PROC_FUNC_REQ), 0); - ASSERT_NE(taosProcPutToChildQ(cproc, &head, 0, body, 0, 0, PROC_FUNC_REQ), 0); - ASSERT_NE(taosProcPutToChildQ(cproc, &head, shm.size, body, 0, 0, PROC_FUNC_REQ), 0); - ASSERT_NE(taosProcPutToChildQ(cproc, &head, sizeof(STestMsg), body, shm.size, 0, PROC_FUNC_REQ), 0); + ASSERT_NE(taosProcPutToChildQ(cproc, &head, 0, body, 0, 0, 0, PROC_FUNC_RSP), 0); + ASSERT_NE(taosProcPutToChildQ(cproc, &head, 0, body, 0, 0, 0, PROC_FUNC_REGIST), 0); + ASSERT_NE(taosProcPutToChildQ(cproc, &head, 0, body, 0, 0, 0, PROC_FUNC_RELEASE), 0); + ASSERT_NE(taosProcPutToChildQ(cproc, NULL, 12, body, 0, 0, 0, PROC_FUNC_REQ), 0); + ASSERT_NE(taosProcPutToChildQ(cproc, &head, 0, body, 0, 0, 0, PROC_FUNC_REQ), 0); + ASSERT_NE(taosProcPutToChildQ(cproc, &head, shm.size, body, 0, 0, 0, PROC_FUNC_REQ), 0); + ASSERT_NE(taosProcPutToChildQ(cproc, &head, sizeof(STestMsg), body, shm.size, 0, 0, PROC_FUNC_REQ), 0); for (int32_t j = 0; j < 1000; j++) { int32_t i = 0; for (i = 0; i < 20; ++i) { - ASSERT_EQ(taosProcPutToChildQ(cproc, &head, sizeof(STestMsg), body, i, 0, PROC_FUNC_REQ), 0); + ASSERT_EQ(taosProcPutToChildQ(cproc, &head, sizeof(STestMsg), body, i, 0, 0, PROC_FUNC_REQ), 0); } - ASSERT_NE(taosProcPutToChildQ(cproc, &head, sizeof(STestMsg), body, i, 0, PROC_FUNC_REQ), 0); + ASSERT_NE(taosProcPutToChildQ(cproc, &head, sizeof(STestMsg), body, i, 0, 0, PROC_FUNC_REQ), 0); cfg.isChild = true; cfg.name = "1235_p"; @@ -236,7 +236,7 @@ TEST_F(UtilTesProc, 03_Handle) { int32_t i = 0; for (i = 0; i < 20; ++i) { head.handle = (void *)((int64_t)i); - ASSERT_EQ(taosProcPutToChildQ(cproc, &head, sizeof(STestMsg), body, i, (void *)((int64_t)i), PROC_FUNC_REQ), 0); + ASSERT_EQ(taosProcPutToChildQ(cproc, &head, sizeof(STestMsg), body, i, (void *)((int64_t)i), i, PROC_FUNC_REQ), 0); } cfg.isChild = true; @@ -246,9 +246,14 @@ TEST_F(UtilTesProc, 03_Handle) { taosProcRun(pproc); taosProcCleanup(pproc); - taosProcRemoveHandle(cproc, (void *)((int64_t)3)); - taosProcRemoveHandle(cproc, (void *)((int64_t)5)); - taosProcRemoveHandle(cproc, (void *)((int64_t)6)); + int64_t ref = 0; + + ref = taosProcRemoveHandle(cproc, (void *)((int64_t)3)); + EXPECT_EQ(ref, 3); + ref = taosProcRemoveHandle(cproc, (void *)((int64_t)5)); + EXPECT_EQ(ref, 5); + ref = taosProcRemoveHandle(cproc, (void *)((int64_t)6)); + EXPECT_EQ(ref, 6); taosProcCloseHandles(cproc, processHandle); } From ee929937e13393cca11199b2bf23e68327caf43b Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Sun, 24 Apr 2022 18:41:34 +0800 Subject: [PATCH 11/11] fix unit test --- source/libs/transport/src/transSrv.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/libs/transport/src/transSrv.c b/source/libs/transport/src/transSrv.c index e0984eb24c..c093bdebce 100644 --- a/source/libs/transport/src/transSrv.c +++ b/source/libs/transport/src/transSrv.c @@ -979,6 +979,7 @@ void transCloseServer(void* arg) { transSrvInst--; if (transSrvInst == 0) { + transModuleInit = PTHREAD_ONCE_INIT; uvCloseExHandleMgt(); } }