From 82a72bf2be537c1f36a46fda9936bd18d50216a2 Mon Sep 17 00:00:00 2001 From: slguan Date: Tue, 10 Mar 2020 17:41:25 +0800 Subject: [PATCH] fix compile errors --- src/client/src/tscSQLParser.c | 2 +- src/client/src/tscServer.c | 2 +- src/dnode/CMakeLists.txt | 2 +- src/dnode/src/dnodeMgmt.c | 186 +++++++++++++++++----------------- src/mnode/src/mgmtMnode.c | 1 + src/mnode/src/mgmtShell.c | 2 +- 6 files changed, 98 insertions(+), 97 deletions(-) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 92323dcdfe..25df797c04 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -395,7 +395,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) { char* pMsg = pCmd->payload + tsRpcHeadSize; pMsg += sizeof(SMgmtHead); - SCfgDnodeMsg* pCfg = (SCfgDnodeMsg*)pMsg; + SCMCfgDnodeMsg* pCfg = (SCMCfgDnodeMsg*)pMsg; strncpy(pCfg->ip, pDCL->a[0].z, pDCL->a[0].n); strncpy(pCfg->config, pDCL->a[1].z, pDCL->a[1].n); diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index 31e16792b6..68faf08dd6 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -1795,7 +1795,7 @@ int32_t tscBuildUserMsg(SSqlObj *pSql, SSqlInfo *pInfo) { int32_t tscBuildCfgDnodeMsg(SSqlObj *pSql, SSqlInfo *pInfo) { SSqlCmd *pCmd = &pSql->cmd; - pCmd->payloadLen = sizeof(SCfgDnodeMsg); + pCmd->payloadLen = sizeof(SCMCfgDnodeMsg); if (TSDB_CODE_SUCCESS != tscAllocPayload(pCmd, pCmd->payloadLen)) { tscError("%p failed to malloc for query msg", pSql); diff --git a/src/dnode/CMakeLists.txt b/src/dnode/CMakeLists.txt index 712f81656a..d4901845fa 100644 --- a/src/dnode/CMakeLists.txt +++ b/src/dnode/CMakeLists.txt @@ -7,7 +7,7 @@ IF ((TD_LINUX_64) OR (TD_LINUX_32 AND TD_ARM)) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/util/inc) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/query/inc) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/vnode/tsdb/inc) - INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/vnode/common/inc) + INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/common/inc) INCLUDE_DIRECTORIES(${TD_ENTERPRISE_DIR}/src/inc) INCLUDE_DIRECTORIES(inc) AUX_SOURCE_DIRECTORY(src SRC) diff --git a/src/dnode/src/dnodeMgmt.c b/src/dnode/src/dnodeMgmt.c index 7a5bc66a13..e8fe94f358 100644 --- a/src/dnode/src/dnodeMgmt.c +++ b/src/dnode/src/dnodeMgmt.c @@ -21,7 +21,7 @@ #include "tlog.h" #include "trpc.h" #include "tstatus.h" -//#include "tsdb.h" +#include "tsdb.h" #include "dnodeMgmt.h" #include "dnodeRead.h" #include "dnodeWrite.h" @@ -139,111 +139,111 @@ static void dnodeCleanupVnodes() { } static int32_t dnodeOpenVnode(int32_t vgId) { -// char rootDir[TSDB_FILENAME_LEN] = {0}; -// sprintf(rootDir, "%s/vnode%d", tsDirectory, vgId); -// -// void *pTsdb = tsdbOpenRepo(rootDir); -// if (pTsdb != NULL) { -// return terrno; -// } -// -// SVnodeObj vnodeObj; -// vnodeObj.vgId = vgId; -// vnodeObj.status = TSDB_VN_STATUS_NOT_READY; -// vnodeObj.refCount = 1; -// vnodeObj.version = 0; -// vnodeObj.wworker = dnodeAllocateWriteWorker(); -// vnodeObj.rworker = dnodeAllocateReadWorker(); -// vnodeObj.wal = NULL; -// vnodeObj.tsdb = pTsdb; -// vnodeObj.replica = NULL; -// vnodeObj.events = NULL; -// vnodeObj.cq = NULL; -// -// taosAddIntHash(tsDnodeVnodesHash, vnodeObj.vgId, &vnodeObj); + char rootDir[TSDB_FILENAME_LEN] = {0}; + sprintf(rootDir, "%s/vnode%d", tsDirectory, vgId); + + void *pTsdb = tsdbOpenRepo(rootDir); + if (pTsdb != NULL) { + return terrno; + } + + SVnodeObj vnodeObj; + vnodeObj.vgId = vgId; + vnodeObj.status = TSDB_VN_STATUS_NOT_READY; + vnodeObj.refCount = 1; + vnodeObj.version = 0; + vnodeObj.wworker = dnodeAllocateWriteWorker(); + vnodeObj.rworker = dnodeAllocateReadWorker(); + vnodeObj.wal = NULL; + vnodeObj.tsdb = pTsdb; + vnodeObj.replica = NULL; + vnodeObj.events = NULL; + vnodeObj.cq = NULL; + + taosAddIntHash(tsDnodeVnodesHash, vnodeObj.vgId, &vnodeObj); return TSDB_CODE_SUCCESS; } static void dnodeCleanupVnode(SVnodeObj *pVnode) { -// pVnode->status = TSDB_VN_STATUS_NOT_READY; -// int32_t count = atomic_sub_fetch_32(&pVnode->refCount, 1); -// if (count > 0) { -// // wait refcount -// } -// -// // remove replica -// -// // remove read queue -// dnodeFreeReadWorker(pVnode->rworker); -// pVnode->rworker = NULL; -// -// // remove write queue -// dnodeFreeWriteWorker(pVnode->wworker); -// pVnode->wworker = NULL; -// -// // remove wal -// -// // remove tsdb -// if (pVnode->tsdb) { -// tsdbCloseRepo(pVnode->tsdb); -// pVnode->tsdb = NULL; -// } -// -// taosDeleteIntHash(tsDnodeVnodesHash, pVnode->vgId); + pVnode->status = TSDB_VN_STATUS_NOT_READY; + int32_t count = atomic_sub_fetch_32(&pVnode->refCount, 1); + if (count > 0) { + // wait refcount + } + + // remove replica + + // remove read queue + dnodeFreeReadWorker(pVnode->rworker); + pVnode->rworker = NULL; + + // remove write queue + dnodeFreeWriteWorker(pVnode->wworker); + pVnode->wworker = NULL; + + // remove wal + + // remove tsdb + if (pVnode->tsdb) { + tsdbCloseRepo(pVnode->tsdb); + pVnode->tsdb = NULL; + } + + taosDeleteIntHash(tsDnodeVnodesHash, pVnode->vgId); } static int32_t dnodeCreateVnode(SMDCreateVnodeMsg *pVnodeCfg) { -// STsdbCfg tsdbCfg; -// tsdbCfg.precision = pVnodeCfg->cfg.precision; -// tsdbCfg.tsdbId = pVnodeCfg->vnode; -// tsdbCfg.maxTables = pVnodeCfg->cfg.maxSessions; -// tsdbCfg.daysPerFile = pVnodeCfg->cfg.daysPerFile; -// tsdbCfg.minRowsPerFileBlock = -1; -// tsdbCfg.maxRowsPerFileBlock = -1; -// tsdbCfg.keep = -1; -// tsdbCfg.maxCacheSize = -1; - -// char rootDir[TSDB_FILENAME_LEN] = {0}; -// sprintf(rootDir, "%s/vnode%d", tsDirectory, pVnodeCfg->cfg.vgId); -// -// void *pTsdb = tsdbCreateRepo(rootDir, &tsdbCfg, NULL); -// if (pTsdb != NULL) { -// return terrno; -// } -// -// SVnodeObj vnodeObj; -// vnodeObj.vgId = pVnodeCfg->cfg.vgId; -// vnodeObj.status = TSDB_VN_STATUS_NOT_READY; -// vnodeObj.refCount = 1; -// vnodeObj.version = 0; -// vnodeObj.wworker = dnodeAllocateWriteWorker(); -// vnodeObj.rworker = dnodeAllocateReadWorker(); -// vnodeObj.wal = NULL; -// vnodeObj.tsdb = pTsdb; -// vnodeObj.replica = NULL; -// vnodeObj.events = NULL; -// vnodeObj.cq = NULL; -// -// taosAddIntHash(tsDnodeVnodesHash, vnodeObj.vgId, &vnodeObj); + STsdbCfg tsdbCfg; + tsdbCfg.precision = pVnodeCfg->cfg.precision; + tsdbCfg.tsdbId = pVnodeCfg->vnode; + tsdbCfg.maxTables = pVnodeCfg->cfg.maxSessions; + tsdbCfg.daysPerFile = pVnodeCfg->cfg.daysPerFile; + tsdbCfg.minRowsPerFileBlock = -1; + tsdbCfg.maxRowsPerFileBlock = -1; + tsdbCfg.keep = -1; + tsdbCfg.maxCacheSize = -1; + + char rootDir[TSDB_FILENAME_LEN] = {0}; + sprintf(rootDir, "%s/vnode%d", tsDirectory, pVnodeCfg->cfg.vgId); + + void *pTsdb = tsdbCreateRepo(rootDir, &tsdbCfg, NULL); + if (pTsdb != NULL) { + return terrno; + } + + SVnodeObj vnodeObj; + vnodeObj.vgId = pVnodeCfg->cfg.vgId; + vnodeObj.status = TSDB_VN_STATUS_NOT_READY; + vnodeObj.refCount = 1; + vnodeObj.version = 0; + vnodeObj.wworker = dnodeAllocateWriteWorker(); + vnodeObj.rworker = dnodeAllocateReadWorker(); + vnodeObj.wal = NULL; + vnodeObj.tsdb = pTsdb; + vnodeObj.replica = NULL; + vnodeObj.events = NULL; + vnodeObj.cq = NULL; + + taosAddIntHash(tsDnodeVnodesHash, vnodeObj.vgId, &vnodeObj); return TSDB_CODE_SUCCESS; } static void dnodeDropVnode(SVnodeObj *pVnode) { -// pVnode->status = TSDB_VN_STATUS_NOT_READY; -// -// int32_t count = atomic_sub_fetch_32(&pVnode->refCount, 1); -// if (count > 0) { -// // wait refcount -// } -// -// if (pVnode->tsdb) { -// tsdbDropRepo(pVnode->tsdb); -// pVnode->tsdb = NULL; -// } -// -// dnodeCleanupVnode(pVnode); + pVnode->status = TSDB_VN_STATUS_NOT_READY; + + int32_t count = atomic_sub_fetch_32(&pVnode->refCount, 1); + if (count > 0) { + // wait refcount + } + + if (pVnode->tsdb) { + tsdbDropRepo(pVnode->tsdb); + pVnode->tsdb = NULL; + } + + dnodeCleanupVnode(pVnode); } static void dnodeProcesSMDCreateVnodeMsg(SRpcMsg *rpcMsg) { diff --git a/src/mnode/src/mgmtMnode.c b/src/mnode/src/mgmtMnode.c index 0b8c7797d9..9e1b3f8ceb 100644 --- a/src/mnode/src/mgmtMnode.c +++ b/src/mnode/src/mgmtMnode.c @@ -14,6 +14,7 @@ */ #define _DEFAULT_SOURCE +#include "os.h" #include "mgmtMnode.h" bool mgmtCheckRedirect(void *handle) { diff --git a/src/mnode/src/mgmtShell.c b/src/mnode/src/mgmtShell.c index 6d02bbf18a..be8de5b331 100644 --- a/src/mnode/src/mgmtShell.c +++ b/src/mnode/src/mgmtShell.c @@ -96,7 +96,7 @@ void mgmtCleanUpShell() { } } -void mgmtAddShellHandle(uint8_t showType, void (*fp)(SRpcMsg *rpcMsg)) { +void mgmtAddShellMsgHandle(uint8_t showType, void (*fp)(SRpcMsg *rpcMsg)) { tsMgmtProcessShellMsgFp[showType] = fp; } -- GitLab