From 0831a3120a6fb938795fc025b589524c7c79921f Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Fri, 14 Jan 2022 06:24:25 +0000 Subject: [PATCH 1/9] refact --- source/dnode/vnode/src/inc/vnodeInt.h | 45 --------------------------- source/dnode/vnode/src/vnd/vnodeInt.c | 3 +- 2 files changed, 2 insertions(+), 46 deletions(-) delete mode 100644 source/dnode/vnode/src/inc/vnodeInt.h diff --git a/source/dnode/vnode/src/inc/vnodeInt.h b/source/dnode/vnode/src/inc/vnodeInt.h deleted file mode 100644 index 028798bc3e..0000000000 --- a/source/dnode/vnode/src/inc/vnodeInt.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#ifndef _TD_VNODE_INT_H_ -#define _TD_VNODE_INT_H_ - -#include "vnode.h" - -#include "meta.h" -// #include "sync.h" -#include "tlog.h" -#include "tq.h" -#include "tsdb.h" -#include "wal.h" - -#ifdef __cplusplus -extern "C" { -#endif - -extern int32_t vDebugFlag; - -#define vFatal(...) { if (vDebugFlag & DEBUG_FATAL) { taosPrintLog("VND FATAL ", 255, __VA_ARGS__); }} -#define vError(...) { if (vDebugFlag & DEBUG_ERROR) { taosPrintLog("VND ERROR ", 255, __VA_ARGS__); }} -#define vWarn(...) { if (vDebugFlag & DEBUG_WARN) { taosPrintLog("VND WARN ", 255, __VA_ARGS__); }} -#define vInfo(...) { if (vDebugFlag & DEBUG_INFO) { taosPrintLog("VND ", 255, __VA_ARGS__); }} -#define vDebug(...) { if (vDebugFlag & DEBUG_DEBUG) { taosPrintLog("VND ", vDebugFlag, __VA_ARGS__); }} -#define vTrace(...) { if (vDebugFlag & DEBUG_TRACE) { taosPrintLog("VND ", vDebugFlag, __VA_ARGS__); }} - -#ifdef __cplusplus -} -#endif - -#endif /*_TD_VNODE_INT_H_*/ diff --git a/source/dnode/vnode/src/vnd/vnodeInt.c b/source/dnode/vnode/src/vnd/vnodeInt.c index 0f33fa65cd..159033386b 100644 --- a/source/dnode/vnode/src/vnd/vnodeInt.c +++ b/source/dnode/vnode/src/vnd/vnodeInt.c @@ -14,7 +14,8 @@ */ #define _DEFAULT_SOURCE -#include "vnodeInt.h" +#include "vnodeDef.h" +// #include "vnodeInt.h" int32_t vnodeAlter(SVnode *pVnode, const SVnodeCfg *pCfg) { return 0; } From d860e2687a421fc2c9c6eac78da417639cfbc80b Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Fri, 14 Jan 2022 06:33:13 +0000 Subject: [PATCH 2/9] refact --- source/dnode/vnode/src/inc/vnodeBufferPool.h | 41 ------ source/dnode/vnode/src/inc/vnodeCfg.h | 34 ----- source/dnode/vnode/src/inc/vnodeCommit.h | 33 ----- source/dnode/vnode/src/inc/vnodeDef.h | 133 ++++++++++++++---- .../dnode/vnode/src/inc/vnodeMemAllocator.h | 53 ------- source/dnode/vnode/src/inc/vnodeStateMgr.h | 33 ----- source/dnode/vnode/src/inc/vnodeWrite.h | 31 ---- 7 files changed, 108 insertions(+), 250 deletions(-) delete mode 100644 source/dnode/vnode/src/inc/vnodeBufferPool.h delete mode 100644 source/dnode/vnode/src/inc/vnodeCfg.h delete mode 100644 source/dnode/vnode/src/inc/vnodeCommit.h delete mode 100644 source/dnode/vnode/src/inc/vnodeMemAllocator.h delete mode 100644 source/dnode/vnode/src/inc/vnodeStateMgr.h delete mode 100644 source/dnode/vnode/src/inc/vnodeWrite.h diff --git a/source/dnode/vnode/src/inc/vnodeBufferPool.h b/source/dnode/vnode/src/inc/vnodeBufferPool.h deleted file mode 100644 index b4535597ee..0000000000 --- a/source/dnode/vnode/src/inc/vnodeBufferPool.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#ifndef _TD_VNODE_BUFFER_POOL_H_ -#define _TD_VNODE_BUFFER_POOL_H_ - -#include "tlist.h" -#include "vnode.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct SVBufPool SVBufPool; - -int vnodeOpenBufPool(SVnode *pVnode); -void vnodeCloseBufPool(SVnode *pVnode); -int vnodeBufPoolSwitch(SVnode *pVnode); -int vnodeBufPoolRecycle(SVnode *pVnode); -void *vnodeMalloc(SVnode *pVnode, uint64_t size); -bool vnodeBufPoolIsFull(SVnode *pVnode); - -SMemAllocatorFactory *vBufPoolGetMAF(SVnode *pVnode); - -#ifdef __cplusplus -} -#endif - -#endif /*_TD_VNODE_BUFFER_POOL_H_*/ \ No newline at end of file diff --git a/source/dnode/vnode/src/inc/vnodeCfg.h b/source/dnode/vnode/src/inc/vnodeCfg.h deleted file mode 100644 index c4245b4023..0000000000 --- a/source/dnode/vnode/src/inc/vnodeCfg.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#ifndef _TD_VNODE_CFG_H_ -#define _TD_VNODE_CFG_H_ - -#include "vnode.h" - -#ifdef __cplusplus -extern "C" { -#endif - -extern const SVnodeCfg defaultVnodeOptions; - -int vnodeValidateOptions(const SVnodeCfg *); -void vnodeOptionsCopy(SVnodeCfg *pDest, const SVnodeCfg *pSrc); - -#ifdef __cplusplus -} -#endif - -#endif /*_TD_VNODE_CFG_H_*/ \ No newline at end of file diff --git a/source/dnode/vnode/src/inc/vnodeCommit.h b/source/dnode/vnode/src/inc/vnodeCommit.h deleted file mode 100644 index e6568fbd52..0000000000 --- a/source/dnode/vnode/src/inc/vnodeCommit.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#ifndef _TD_VNODE_COMMIT_H_ -#define _TD_VNODE_COMMIT_H_ - -#include "vnode.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define vnodeShouldCommit vnodeBufPoolIsFull -int vnodeSyncCommit(SVnode *pVnode); -int vnodeAsyncCommit(SVnode *pVnode); - -#ifdef __cplusplus -} -#endif - -#endif /*_TD_VNODE_COMMIT_H_*/ \ No newline at end of file diff --git a/source/dnode/vnode/src/inc/vnodeDef.h b/source/dnode/vnode/src/inc/vnodeDef.h index 1333c9dce7..7f43a93ab7 100644 --- a/source/dnode/vnode/src/inc/vnodeDef.h +++ b/source/dnode/vnode/src/inc/vnodeDef.h @@ -19,25 +19,23 @@ #include "mallocator.h" // #include "sync.h" #include "tcoding.h" +#include "tfs.h" #include "tlist.h" #include "tlockfree.h" #include "tmacro.h" #include "wal.h" -#include "tfs.h" #include "vnode.h" -#include "vnodeBufferPool.h" -#include "vnodeCfg.h" -#include "vnodeCommit.h" -#include "vnodeMemAllocator.h" #include "vnodeQuery.h" -#include "vnodeStateMgr.h" #ifdef __cplusplus extern "C" { #endif +typedef struct SVState SVState; +typedef struct SVBufPool SVBufPool; + typedef struct SVnodeTask { TD_DLIST_NODE(SVnodeTask); void* arg; @@ -60,34 +58,119 @@ typedef struct SVnodeMgr { extern SVnodeMgr vnodeMgr; +// SVState +struct SVState { + int64_t processed; + int64_t committed; + int64_t applied; +}; + struct SVnode { - int32_t vgId; - char* path; - SVnodeCfg config; - SVState state; - SVBufPool* pBufPool; - SMeta* pMeta; - STsdb* pTsdb; - STQ* pTq; - SWal* pWal; - tsem_t canCommit; - SQHandle* pQuery; - SDnode* pDnode; + int32_t vgId; + char* path; + SVnodeCfg config; + SVState state; + SVBufPool* pBufPool; + SMeta* pMeta; + STsdb* pTsdb; + STQ* pTq; + SWal* pWal; + tsem_t canCommit; + SQHandle* pQuery; + SDnode* pDnode; }; int vnodeScheduleTask(SVnodeTask* task); -int32_t vnodePutReqToVQueryQ(SVnode *pVnode, struct SRpcMsg *pReq); +int32_t vnodePutReqToVQueryQ(SVnode* pVnode, struct SRpcMsg* pReq); // For Log extern int32_t vDebugFlag; -#define vFatal(...) do { if (vDebugFlag & DEBUG_FATAL) { taosPrintLog("VND FATAL ", 255, __VA_ARGS__); }} while(0) -#define vError(...) do { if (vDebugFlag & DEBUG_ERROR) { taosPrintLog("VND ERROR ", 255, __VA_ARGS__); }} while(0) -#define vWarn(...) do { if (vDebugFlag & DEBUG_WARN) { taosPrintLog("VND WARN ", 255, __VA_ARGS__); }} while(0) -#define vInfo(...) do { if (vDebugFlag & DEBUG_INFO) { taosPrintLog("VND ", 255, __VA_ARGS__); }} while(0) -#define vDebug(...) do { if (vDebugFlag & DEBUG_DEBUG) { taosPrintLog("VND ", tsdbDebugFlag, __VA_ARGS__); }} while(0) -#define vTrace(...) do { if (vDebugFlag & DEBUG_TRACE) { taosPrintLog("VND ", tsdbDebugFlag, __VA_ARGS__); }} while(0) +#define vFatal(...) \ + do { \ + if (vDebugFlag & DEBUG_FATAL) { \ + taosPrintLog("VND FATAL ", 255, __VA_ARGS__); \ + } \ + } while (0) +#define vError(...) \ + do { \ + if (vDebugFlag & DEBUG_ERROR) { \ + taosPrintLog("VND ERROR ", 255, __VA_ARGS__); \ + } \ + } while (0) +#define vWarn(...) \ + do { \ + if (vDebugFlag & DEBUG_WARN) { \ + taosPrintLog("VND WARN ", 255, __VA_ARGS__); \ + } \ + } while (0) +#define vInfo(...) \ + do { \ + if (vDebugFlag & DEBUG_INFO) { \ + taosPrintLog("VND ", 255, __VA_ARGS__); \ + } \ + } while (0) +#define vDebug(...) \ + do { \ + if (vDebugFlag & DEBUG_DEBUG) { \ + taosPrintLog("VND ", tsdbDebugFlag, __VA_ARGS__); \ + } \ + } while (0) +#define vTrace(...) \ + do { \ + if (vDebugFlag & DEBUG_TRACE) { \ + taosPrintLog("VND ", tsdbDebugFlag, __VA_ARGS__); \ + } \ + } while (0) + +// vnodeCfg.h +extern const SVnodeCfg defaultVnodeOptions; + +int vnodeValidateOptions(const SVnodeCfg*); +void vnodeOptionsCopy(SVnodeCfg* pDest, const SVnodeCfg* pSrc); + +// For commit +#define vnodeShouldCommit vnodeBufPoolIsFull +int vnodeSyncCommit(SVnode* pVnode); +int vnodeAsyncCommit(SVnode* pVnode); + +// SVBufPool + +int vnodeOpenBufPool(SVnode* pVnode); +void vnodeCloseBufPool(SVnode* pVnode); +int vnodeBufPoolSwitch(SVnode* pVnode); +int vnodeBufPoolRecycle(SVnode* pVnode); +void* vnodeMalloc(SVnode* pVnode, uint64_t size); +bool vnodeBufPoolIsFull(SVnode* pVnode); + +SMemAllocatorFactory* vBufPoolGetMAF(SVnode* pVnode); + +// SVMemAllocator +typedef struct SVArenaNode { + TD_SLIST_NODE(SVArenaNode); + uint64_t size; // current node size + void* ptr; + char data[]; +} SVArenaNode; + +typedef struct SVMemAllocator { + T_REF_DECLARE() + TD_DLIST_NODE(SVMemAllocator); + uint64_t capacity; + uint64_t ssize; + uint64_t lsize; + SVArenaNode* pNode; + TD_SLIST(SVArenaNode) nlist; +} SVMemAllocator; + +SVMemAllocator* vmaCreate(uint64_t capacity, uint64_t ssize, uint64_t lsize); +void vmaDestroy(SVMemAllocator* pVMA); +void vmaReset(SVMemAllocator* pVMA); +void* vmaMalloc(SVMemAllocator* pVMA, uint64_t size); +void vmaFree(SVMemAllocator* pVMA, void* ptr); +bool vmaIsFull(SVMemAllocator* pVMA); + #ifdef __cplusplus } diff --git a/source/dnode/vnode/src/inc/vnodeMemAllocator.h b/source/dnode/vnode/src/inc/vnodeMemAllocator.h deleted file mode 100644 index eb821a4b6c..0000000000 --- a/source/dnode/vnode/src/inc/vnodeMemAllocator.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#ifndef _TD_VNODE_MEM_ALLOCATOR_H_ -#define _TD_VNODE_MEM_ALLOCATOR_H_ - -#include "os.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct SVArenaNode { - TD_SLIST_NODE(SVArenaNode); - uint64_t size; // current node size - void * ptr; - char data[]; -} SVArenaNode; - -typedef struct SVMemAllocator { - T_REF_DECLARE() - TD_DLIST_NODE(SVMemAllocator); - uint64_t capacity; - uint64_t ssize; - uint64_t lsize; - SVArenaNode *pNode; - TD_SLIST(SVArenaNode) nlist; -} SVMemAllocator; - -SVMemAllocator *vmaCreate(uint64_t capacity, uint64_t ssize, uint64_t lsize); -void vmaDestroy(SVMemAllocator *pVMA); -void vmaReset(SVMemAllocator *pVMA); -void * vmaMalloc(SVMemAllocator *pVMA, uint64_t size); -void vmaFree(SVMemAllocator *pVMA, void *ptr); -bool vmaIsFull(SVMemAllocator *pVMA); - -#ifdef __cplusplus -} -#endif - -#endif /*_TD_VNODE_MEM_ALLOCATOR_H_*/ diff --git a/source/dnode/vnode/src/inc/vnodeStateMgr.h b/source/dnode/vnode/src/inc/vnodeStateMgr.h deleted file mode 100644 index 5862b304ed..0000000000 --- a/source/dnode/vnode/src/inc/vnodeStateMgr.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#ifndef _TD_VNODE_STATE_MGR_H_ -#define _TD_VNODE_STATE_MGR_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct { - int64_t processed; - int64_t committed; - int64_t applied; -} SVState; - -#ifdef __cplusplus -} -#endif - -#endif /*_TD_VNODE_STATE_MGR_H_*/ diff --git a/source/dnode/vnode/src/inc/vnodeWrite.h b/source/dnode/vnode/src/inc/vnodeWrite.h deleted file mode 100644 index 57f19b11c4..0000000000 --- a/source/dnode/vnode/src/inc/vnodeWrite.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#ifndef _TD_VNODE_WRITE_H_ -#define _TD_VNODE_WRITE_H_ - -#include "vnode.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void vnodeProcessWriteMsg(SVnode* pVnode, SVnodeMsg* pMsg); - -#ifdef __cplusplus -} -#endif - -#endif /*_TD_VNODE_WRITE_H_*/ From 883111c62fd649c4d3725dd0dbc988dd094b00ee Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Fri, 14 Jan 2022 06:38:45 +0000 Subject: [PATCH 3/9] refact --- source/dnode/vnode/src/inc/tsdbHealth.h | 29 ------- source/dnode/vnode/src/tsdb/tsdbHealth.c | 98 ------------------------ 2 files changed, 127 deletions(-) delete mode 100644 source/dnode/vnode/src/inc/tsdbHealth.h delete mode 100644 source/dnode/vnode/src/tsdb/tsdbHealth.c diff --git a/source/dnode/vnode/src/inc/tsdbHealth.h b/source/dnode/vnode/src/inc/tsdbHealth.h deleted file mode 100644 index d7b70ac053..0000000000 --- a/source/dnode/vnode/src/inc/tsdbHealth.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#ifndef _TD_TSDB_HEALTH_H_ -#define _TD_TSDB_HEALTH_H_ - -#if 0 - -bool tsdbUrgeQueryFree(STsdbRepo* pRepo); -int32_t tsdbInsertNewBlock(STsdbRepo* pRepo); - -bool tsdbIdleMemEnough(); -bool tsdbAllowNewBlock(STsdbRepo* pRepo); - -#endif - -#endif /* _TD_TSDB_BUFFER_H_ */ diff --git a/source/dnode/vnode/src/tsdb/tsdbHealth.c b/source/dnode/vnode/src/tsdb/tsdbHealth.c deleted file mode 100644 index 99c1b925b0..0000000000 --- a/source/dnode/vnode/src/tsdb/tsdbHealth.c +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -// #include "os.h" -// #include "tmsg.h" -// #include "tarray.h" -// #include "query.h" -// #include "tglobal.h" -// #include "tlist.h" -// #include "tsdbint.h" -// #include "tsdbBuffer.h" -// #include "tsdbLog.h" -// #include "tsdbHealth.h" -// #include "ttimer.h" -// #include "tthread.h" - - -// // return malloc new block count -// int32_t tsdbInsertNewBlock(STsdbRepo * pRepo) { -// STsdbBufPool *pPool = pRepo->pPool; -// int32_t cnt = 0; - -// if(tsdbAllowNewBlock(pRepo)) { -// STsdbBufBlock *pBufBlock = tsdbNewBufBlock(pPool->bufBlockSize); -// if (pBufBlock) { -// if (tdListAppend(pPool->bufBlockList, (void *)(&pBufBlock)) < 0) { -// // append error -// tsdbFreeBufBlock(pBufBlock); -// } else { -// pPool->nElasticBlocks ++; -// cnt ++ ; -// } -// } -// } -// return cnt; -// } - -// // switch anther thread to run -// void* cbKillQueryFree(void* param) { -// STsdbRepo* pRepo = (STsdbRepo*)param; -// // vnode -// if(pRepo->appH.notifyStatus) { -// pRepo->appH.notifyStatus(pRepo->appH.appH, TSDB_STATUS_COMMIT_NOBLOCK, TSDB_CODE_SUCCESS); -// } - -// // free -// if(pRepo->pthread){ -// void* p = pRepo->pthread; -// pRepo->pthread = NULL; -// free(p); -// } - -// return NULL; -// } - -// // return true do free , false do nothing -// bool tsdbUrgeQueryFree(STsdbRepo * pRepo) { -// // check previous running -// if(pRepo->pthread && taosThreadRunning(pRepo->pthread)) { -// tsdbWarn("vgId:%d pre urge thread is runing. nBlocks=%d nElasticBlocks=%d", REPO_ID(pRepo), pRepo->pPool->nBufBlocks, pRepo->pPool->nElasticBlocks); -// return false; -// } -// // create new -// pRepo->pthread = taosCreateThread(cbKillQueryFree, pRepo); -// if(pRepo->pthread == NULL) { -// tsdbError("vgId:%d create urge thread error.", REPO_ID(pRepo)); -// return false; -// } -// return true; -// } - -// bool tsdbAllowNewBlock(STsdbRepo* pRepo) { -// int32_t nMaxElastic = pRepo->config.totalBlocks/3; -// STsdbBufPool* pPool = pRepo->pPool; -// if(pPool->nElasticBlocks >= nMaxElastic) { -// tsdbWarn("vgId:%d tsdbAllowNewBlock return fasle. nElasticBlock(%d) >= MaxElasticBlocks(%d)", REPO_ID(pRepo), pPool->nElasticBlocks, nMaxElastic); -// return false; -// } -// return true; -// } - -// bool tsdbNoProblem(STsdbRepo* pRepo) { -// if(listNEles(pRepo->pPool->bufBlockList) == 0) -// return false; -// return true; -// } \ No newline at end of file From cde3c5a8999c4ff21b5ae7fdfce1a9c44100e31d Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Fri, 14 Jan 2022 06:45:12 +0000 Subject: [PATCH 4/9] refact --- source/dnode/vnode/src/inc/metaCache.h | 34 ------------- source/dnode/vnode/src/inc/metaCfg.h | 34 ------------- source/dnode/vnode/src/inc/metaDef.h | 37 +++++++++++--- source/dnode/vnode/src/inc/metaIdx.h | 36 -------------- source/dnode/vnode/src/inc/metaQuery.h | 27 ---------- source/dnode/vnode/src/inc/metaTbCfg.h | 32 ------------ source/dnode/vnode/src/inc/metaTbTag.h | 27 ---------- source/dnode/vnode/src/inc/metaTbUid.h | 42 ---------------- source/dnode/vnode/src/inc/tsdbRowMergeBuf.h | 49 ------------------- source/dnode/vnode/src/meta/metaTable.c | 8 +-- source/dnode/vnode/src/tsdb/tsdbRowMergeBuf.c | 30 ------------ 11 files changed, 35 insertions(+), 321 deletions(-) delete mode 100644 source/dnode/vnode/src/inc/metaCache.h delete mode 100644 source/dnode/vnode/src/inc/metaCfg.h delete mode 100644 source/dnode/vnode/src/inc/metaIdx.h delete mode 100644 source/dnode/vnode/src/inc/metaQuery.h delete mode 100644 source/dnode/vnode/src/inc/metaTbCfg.h delete mode 100644 source/dnode/vnode/src/inc/metaTbTag.h delete mode 100644 source/dnode/vnode/src/inc/metaTbUid.h delete mode 100644 source/dnode/vnode/src/inc/tsdbRowMergeBuf.h delete mode 100644 source/dnode/vnode/src/tsdb/tsdbRowMergeBuf.c diff --git a/source/dnode/vnode/src/inc/metaCache.h b/source/dnode/vnode/src/inc/metaCache.h deleted file mode 100644 index 46798f0de4..0000000000 --- a/source/dnode/vnode/src/inc/metaCache.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#ifndef _TD_META_CACHE_H_ -#define _TD_META_CACHE_H_ - -#include "meta.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct SMetaCache SMetaCache; - -int metaOpenCache(SMeta *pMeta); -void metaCloseCache(SMeta *pMeta); - -#ifdef __cplusplus -} -#endif - -#endif /*_TD_META_CACHE_H_*/ \ No newline at end of file diff --git a/source/dnode/vnode/src/inc/metaCfg.h b/source/dnode/vnode/src/inc/metaCfg.h deleted file mode 100644 index 5c72ffa680..0000000000 --- a/source/dnode/vnode/src/inc/metaCfg.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#ifndef _TD_META_CFG_H_ -#define _TD_META_CFG_H_ - -#include "meta.h" - -#ifdef __cplusplus -extern "C" { -#endif - -extern const SMetaCfg defaultMetaOptions; - -int metaValidateOptions(const SMetaCfg *); -void metaOptionsCopy(SMetaCfg *pDest, const SMetaCfg *pSrc); - -#ifdef __cplusplus -} -#endif - -#endif /*_TD_META_CFG_H_*/ \ No newline at end of file diff --git a/source/dnode/vnode/src/inc/metaDef.h b/source/dnode/vnode/src/inc/metaDef.h index e1c15af5aa..82c74f47d2 100644 --- a/source/dnode/vnode/src/inc/metaDef.h +++ b/source/dnode/vnode/src/inc/metaDef.h @@ -19,18 +19,43 @@ #include "mallocator.h" #include "meta.h" -#include "metaCache.h" -#include "metaCfg.h" #include "metaDB.h" -#include "metaIdx.h" -#include "metaTbCfg.h" -#include "metaTbTag.h" -#include "metaTbUid.h" #ifdef __cplusplus extern "C" { #endif +typedef struct SMetaCache SMetaCache; +typedef struct SMetaIdx SMetaIdx; + +// SMetaCache +int metaOpenCache(SMeta* pMeta); +void metaCloseCache(SMeta* pMeta); + +// SMetaCfg +extern const SMetaCfg defaultMetaOptions; +// int metaValidateOptions(const SMetaCfg*); +void metaOptionsCopy(SMetaCfg* pDest, const SMetaCfg* pSrc); + +// SMetaIdx +int metaOpenIdx(SMeta* pMeta); +void metaCloseIdx(SMeta* pMeta); +int metaSaveTableToIdx(SMeta* pMeta, const STbCfg* pTbOptions); +int metaRemoveTableFromIdx(SMeta* pMeta, tb_uid_t uid); + +// STbUidGnrt +typedef struct STbUidGenerator { + tb_uid_t nextUid; +} STbUidGenerator; + +// STableUidGenerator +int metaOpenUidGnrt(SMeta *pMeta); +void metaCloseUidGnrt(SMeta *pMeta); + +// tb_uid_t +#define IVLD_TB_UID 0 +tb_uid_t metaGenerateUid(SMeta *pMeta); + struct SMeta { char* path; SMetaCfg options; diff --git a/source/dnode/vnode/src/inc/metaIdx.h b/source/dnode/vnode/src/inc/metaIdx.h deleted file mode 100644 index b6afc4cc97..0000000000 --- a/source/dnode/vnode/src/inc/metaIdx.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#ifndef _TD_META_IDX_H_ -#define _TD_META_IDX_H_ - -#include "meta.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct SMetaIdx SMetaIdx; - -int metaOpenIdx(SMeta *pMeta); -void metaCloseIdx(SMeta *pMeta); -int metaSaveTableToIdx(SMeta *pMeta, const STbCfg *pTbOptions); -int metaRemoveTableFromIdx(SMeta *pMeta, tb_uid_t uid); - -#ifdef __cplusplus -} -#endif - -#endif /*_TD_META_IDX_H_*/ \ No newline at end of file diff --git a/source/dnode/vnode/src/inc/metaQuery.h b/source/dnode/vnode/src/inc/metaQuery.h deleted file mode 100644 index ca3b68b415..0000000000 --- a/source/dnode/vnode/src/inc/metaQuery.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#ifndef _VNODE_QUERY_H_ -#define _VNODE_QUERY_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef __cplusplus -} -#endif - -#endif /*_VNODE_QUERY_H_*/ \ No newline at end of file diff --git a/source/dnode/vnode/src/inc/metaTbCfg.h b/source/dnode/vnode/src/inc/metaTbCfg.h deleted file mode 100644 index b7b3924d14..0000000000 --- a/source/dnode/vnode/src/inc/metaTbCfg.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#ifndef _TD_META_TABLE_CFG_H_ -#define _TD_META_TABLE_CFG_H_ - -#include "meta.h" - -#ifdef __cplusplus -extern "C" { -#endif - -int metaValidateTbCfg(SMeta *pMeta, const STbCfg *); -size_t metaEncodeTbObjFromTbOptions(const STbCfg *, void *pBuf, size_t bsize); - -#ifdef __cplusplus -} -#endif - -#endif /*_TD_META_TABLE_CFG_H_*/ \ No newline at end of file diff --git a/source/dnode/vnode/src/inc/metaTbTag.h b/source/dnode/vnode/src/inc/metaTbTag.h deleted file mode 100644 index 15b660be92..0000000000 --- a/source/dnode/vnode/src/inc/metaTbTag.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#ifndef _TD_META_TB_TAG_H_ -#define _TD_META_TB_TAG_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef __cplusplus -} -#endif - -#endif /*_TD_META_TB_TAG_H_*/ \ No newline at end of file diff --git a/source/dnode/vnode/src/inc/metaTbUid.h b/source/dnode/vnode/src/inc/metaTbUid.h deleted file mode 100644 index 07d1f6635b..0000000000 --- a/source/dnode/vnode/src/inc/metaTbUid.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#ifndef _TD_META_UID_H_ -#define _TD_META_UID_H_ - -#include "meta.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* ------------------------ APIS EXPOSED ------------------------ */ -typedef struct STbUidGenerator { - tb_uid_t nextUid; -} STbUidGenerator; - -// STableUidGenerator -int metaOpenUidGnrt(SMeta *pMeta); -void metaCloseUidGnrt(SMeta *pMeta); - -// tb_uid_t -#define IVLD_TB_UID 0 -tb_uid_t metaGenerateUid(SMeta *pMeta); - -#ifdef __cplusplus -} -#endif - -#endif /*_TD_META_UID_H_*/ \ No newline at end of file diff --git a/source/dnode/vnode/src/inc/tsdbRowMergeBuf.h b/source/dnode/vnode/src/inc/tsdbRowMergeBuf.h deleted file mode 100644 index 1531d532b9..0000000000 --- a/source/dnode/vnode/src/inc/tsdbRowMergeBuf.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#ifndef TSDB_ROW_MERGE_BUF_H -#define TSDB_ROW_MERGE_BUF_H - -#if 0 - -#ifdef __cplusplus -extern "C" { -#endif - -#include "tsdb.h" -#include "tchecksum.h" -#include "tsdbReadImpl.h" - -typedef void* SMergeBuf; - -SDataRow tsdbMergeTwoRows(SMergeBuf *pBuf, SMemRow row1, SMemRow row2, STSchema *pSchema1, STSchema *pSchema2); - -static FORCE_INLINE int tsdbMergeBufMakeSureRoom(SMergeBuf *pBuf, STSchema* pSchema1, STSchema* pSchema2) { - size_t len1 = dataRowMaxBytesFromSchema(pSchema1); - size_t len2 = dataRowMaxBytesFromSchema(pSchema2); - return tsdbMakeRoom(pBuf, MAX(len1, len2)); -} - -static FORCE_INLINE void tsdbFreeMergeBuf(SMergeBuf buf) { - taosTZfree(buf); -} - -#ifdef __cplusplus -} -#endif - -#endif - -#endif /* ifndef TSDB_ROW_MERGE_BUF_H */ diff --git a/source/dnode/vnode/src/meta/metaTable.c b/source/dnode/vnode/src/meta/metaTable.c index 1398639f39..4725f77fa2 100644 --- a/source/dnode/vnode/src/meta/metaTable.c +++ b/source/dnode/vnode/src/meta/metaTable.c @@ -17,10 +17,10 @@ int metaCreateTable(SMeta *pMeta, STbCfg *pTbCfg) { // Validate the tbOptions - if (metaValidateTbCfg(pMeta, pTbCfg) < 0) { - // TODO: handle error - return -1; - } + // if (metaValidateTbCfg(pMeta, pTbCfg) < 0) { + // // TODO: handle error + // return -1; + // } // TODO: add atomicity diff --git a/source/dnode/vnode/src/tsdb/tsdbRowMergeBuf.c b/source/dnode/vnode/src/tsdb/tsdbRowMergeBuf.c deleted file mode 100644 index 1eebea22d4..0000000000 --- a/source/dnode/vnode/src/tsdb/tsdbRowMergeBuf.c +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -// #include "tsdbRowMergeBuf.h" -// #include "tdataformat.h" - -// // row1 has higher priority -// SMemRow tsdbMergeTwoRows(SMergeBuf *pBuf, SMemRow row1, SMemRow row2, STSchema *pSchema1, STSchema *pSchema2) { -// if(row2 == NULL) return row1; -// if(row1 == NULL) return row2; -// ASSERT(pSchema1->version == memRowVersion(row1)); -// ASSERT(pSchema2->version == memRowVersion(row2)); - -// if(tsdbMergeBufMakeSureRoom(pBuf, pSchema1, pSchema2) < 0) { -// return NULL; -// } -// return mergeTwoMemRows(*pBuf, row1, row2, pSchema1, pSchema2); -// } From 1cc52364912deb337e26c9014ea0c96f53bb0151 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Fri, 14 Jan 2022 06:53:08 +0000 Subject: [PATCH 5/9] refact --- source/dnode/vnode/src/inc/{vnodeDef.h => vnd.h} | 6 +++--- source/dnode/vnode/src/vnd/vnodeArenaMAImpl.c | 2 +- source/dnode/vnode/src/vnd/vnodeBufferPool.c | 2 +- source/dnode/vnode/src/vnd/vnodeCfg.c | 2 +- source/dnode/vnode/src/vnd/vnodeCommit.c | 2 +- source/dnode/vnode/src/vnd/vnodeInt.c | 2 +- source/dnode/vnode/src/vnd/vnodeMain.c | 2 +- source/dnode/vnode/src/vnd/vnodeMgr.c | 2 +- source/dnode/vnode/src/vnd/vnodeQuery.c | 2 +- source/dnode/vnode/src/vnd/vnodeWrite.c | 2 +- 10 files changed, 12 insertions(+), 12 deletions(-) rename source/dnode/vnode/src/inc/{vnodeDef.h => vnd.h} (98%) diff --git a/source/dnode/vnode/src/inc/vnodeDef.h b/source/dnode/vnode/src/inc/vnd.h similarity index 98% rename from source/dnode/vnode/src/inc/vnodeDef.h rename to source/dnode/vnode/src/inc/vnd.h index 7f43a93ab7..f74497d309 100644 --- a/source/dnode/vnode/src/inc/vnodeDef.h +++ b/source/dnode/vnode/src/inc/vnd.h @@ -13,8 +13,8 @@ * along with this program. If not, see . */ -#ifndef _TD_VNODE_DEF_H_ -#define _TD_VNODE_DEF_H_ +#ifndef _TD_VND_H_ +#define _TD_VND_H_ #include "mallocator.h" // #include "sync.h" @@ -176,4 +176,4 @@ bool vmaIsFull(SVMemAllocator* pVMA); } #endif -#endif /*_TD_VNODE_DEF_H_*/ \ No newline at end of file +#endif /*_TD_VND_H_*/ \ No newline at end of file diff --git a/source/dnode/vnode/src/vnd/vnodeArenaMAImpl.c b/source/dnode/vnode/src/vnd/vnodeArenaMAImpl.c index 5999b08a7d..f49babb1a5 100644 --- a/source/dnode/vnode/src/vnd/vnodeArenaMAImpl.c +++ b/source/dnode/vnode/src/vnd/vnodeArenaMAImpl.c @@ -13,7 +13,7 @@ * along with this program. If not, see . */ -#include "vnodeDef.h" +#include "vnd.h" static SVArenaNode *vArenaNodeNew(uint64_t capacity); static void vArenaNodeFree(SVArenaNode *pNode); diff --git a/source/dnode/vnode/src/vnd/vnodeBufferPool.c b/source/dnode/vnode/src/vnd/vnodeBufferPool.c index c2040501e8..8df6b42566 100644 --- a/source/dnode/vnode/src/vnd/vnodeBufferPool.c +++ b/source/dnode/vnode/src/vnd/vnodeBufferPool.c @@ -13,7 +13,7 @@ * along with this program. If not, see . */ -#include "vnodeDef.h" +#include "vnd.h" /* ------------------------ STRUCTURES ------------------------ */ #define VNODE_BUF_POOL_SHARDS 3 diff --git a/source/dnode/vnode/src/vnd/vnodeCfg.c b/source/dnode/vnode/src/vnd/vnodeCfg.c index 97c3cc9cee..727a4b41f7 100644 --- a/source/dnode/vnode/src/vnd/vnodeCfg.c +++ b/source/dnode/vnode/src/vnd/vnodeCfg.c @@ -13,7 +13,7 @@ * along with this program. If not, see . */ -#include "vnodeDef.h" +#include "vnd.h" const SVnodeCfg defaultVnodeOptions = { .wsize = 96 * 1024 * 1024, .ssize = 1 * 1024 * 1024, .lsize = 1024, .walCfg = {.level = TAOS_WAL_WRITE}}; /* TODO */ diff --git a/source/dnode/vnode/src/vnd/vnodeCommit.c b/source/dnode/vnode/src/vnd/vnodeCommit.c index fbea827ec7..bc7a8460b8 100644 --- a/source/dnode/vnode/src/vnd/vnodeCommit.c +++ b/source/dnode/vnode/src/vnd/vnodeCommit.c @@ -13,7 +13,7 @@ * along with this program. If not, see . */ -#include "vnodeDef.h" +#include "vnd.h" static int vnodeStartCommit(SVnode *pVnode); static int vnodeEndCommit(SVnode *pVnode); diff --git a/source/dnode/vnode/src/vnd/vnodeInt.c b/source/dnode/vnode/src/vnd/vnodeInt.c index 159033386b..3d23784e13 100644 --- a/source/dnode/vnode/src/vnd/vnodeInt.c +++ b/source/dnode/vnode/src/vnd/vnodeInt.c @@ -14,7 +14,7 @@ */ #define _DEFAULT_SOURCE -#include "vnodeDef.h" +#include "vnd.h" // #include "vnodeInt.h" int32_t vnodeAlter(SVnode *pVnode, const SVnodeCfg *pCfg) { return 0; } diff --git a/source/dnode/vnode/src/vnd/vnodeMain.c b/source/dnode/vnode/src/vnd/vnodeMain.c index 85ccc9879e..ae17c9887d 100644 --- a/source/dnode/vnode/src/vnd/vnodeMain.c +++ b/source/dnode/vnode/src/vnd/vnodeMain.c @@ -13,7 +13,7 @@ * along with this program. If not, see . */ -#include "vnodeDef.h" +#include "vnd.h" static SVnode *vnodeNew(const char *path, const SVnodeCfg *pVnodeCfg); static void vnodeFree(SVnode *pVnode); diff --git a/source/dnode/vnode/src/vnd/vnodeMgr.c b/source/dnode/vnode/src/vnd/vnodeMgr.c index ce9e487076..730155b75a 100644 --- a/source/dnode/vnode/src/vnd/vnodeMgr.c +++ b/source/dnode/vnode/src/vnd/vnodeMgr.c @@ -13,7 +13,7 @@ * along with this program. If not, see . */ -#include "vnodeDef.h" +#include "vnd.h" SVnodeMgr vnodeMgr = {.vnodeInitFlag = TD_MOD_UNINITIALIZED}; diff --git a/source/dnode/vnode/src/vnd/vnodeQuery.c b/source/dnode/vnode/src/vnd/vnodeQuery.c index 909b233efb..881c74e5b0 100644 --- a/source/dnode/vnode/src/vnd/vnodeQuery.c +++ b/source/dnode/vnode/src/vnd/vnodeQuery.c @@ -14,7 +14,7 @@ */ #include "vnodeQuery.h" -#include "vnodeDef.h" +#include "vnd.h" static int32_t vnodeGetTableList(SVnode *pVnode, SRpcMsg *pMsg); static int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp); diff --git a/source/dnode/vnode/src/vnd/vnodeWrite.c b/source/dnode/vnode/src/vnd/vnodeWrite.c index 472f8e0fe0..fb2d182e6c 100644 --- a/source/dnode/vnode/src/vnd/vnodeWrite.c +++ b/source/dnode/vnode/src/vnd/vnodeWrite.c @@ -13,7 +13,7 @@ * along with this program. If not, see . */ -#include "vnodeDef.h" +#include "vnd.h" int vnodeProcessNoWalWMsgs(SVnode *pVnode, SRpcMsg *pMsg) { switch (pMsg->msgType) { From 523ba0ab9819bc740713c1aada117d9d27c4a659 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Fri, 14 Jan 2022 06:55:24 +0000 Subject: [PATCH 6/9] refact --- source/dnode/vnode/src/inc/metaDB.h | 36 -------------------------- source/dnode/vnode/src/inc/metaDef.h | 16 ++++++++---- source/dnode/vnode/src/inc/vnd.h | 6 ++--- source/dnode/vnode/src/meta/metaMain.c | 10 +++---- 4 files changed, 19 insertions(+), 49 deletions(-) delete mode 100644 source/dnode/vnode/src/inc/metaDB.h diff --git a/source/dnode/vnode/src/inc/metaDB.h b/source/dnode/vnode/src/inc/metaDB.h deleted file mode 100644 index b4b7e5d19e..0000000000 --- a/source/dnode/vnode/src/inc/metaDB.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#ifndef _TD_META_DB_H_ -#define _TD_META_DB_H_ - -#include "meta.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct SMetaDB SMetaDB; - -int metaOpenDB(SMeta *pMeta); -void metaCloseDB(SMeta *pMeta); -int metaSaveTableToDB(SMeta *pMeta, STbCfg *pTbCfg); -int metaRemoveTableFromDb(SMeta *pMeta, tb_uid_t uid); - -#ifdef __cplusplus -} -#endif - -#endif /*_TD_META_DB_H_*/ \ No newline at end of file diff --git a/source/dnode/vnode/src/inc/metaDef.h b/source/dnode/vnode/src/inc/metaDef.h index 82c74f47d2..b76c08b7b4 100644 --- a/source/dnode/vnode/src/inc/metaDef.h +++ b/source/dnode/vnode/src/inc/metaDef.h @@ -19,7 +19,6 @@ #include "mallocator.h" #include "meta.h" -#include "metaDB.h" #ifdef __cplusplus extern "C" { @@ -27,6 +26,13 @@ extern "C" { typedef struct SMetaCache SMetaCache; typedef struct SMetaIdx SMetaIdx; +typedef struct SMetaDB SMetaDB; + +// SMetaDB +int metaOpenDB(SMeta* pMeta); +void metaCloseDB(SMeta* pMeta); +int metaSaveTableToDB(SMeta* pMeta, STbCfg* pTbCfg); +int metaRemoveTableFromDb(SMeta* pMeta, tb_uid_t uid); // SMetaCache int metaOpenCache(SMeta* pMeta); @@ -35,7 +41,7 @@ void metaCloseCache(SMeta* pMeta); // SMetaCfg extern const SMetaCfg defaultMetaOptions; // int metaValidateOptions(const SMetaCfg*); -void metaOptionsCopy(SMetaCfg* pDest, const SMetaCfg* pSrc); +void metaOptionsCopy(SMetaCfg* pDest, const SMetaCfg* pSrc); // SMetaIdx int metaOpenIdx(SMeta* pMeta); @@ -49,12 +55,12 @@ typedef struct STbUidGenerator { } STbUidGenerator; // STableUidGenerator -int metaOpenUidGnrt(SMeta *pMeta); -void metaCloseUidGnrt(SMeta *pMeta); +int metaOpenUidGnrt(SMeta* pMeta); +void metaCloseUidGnrt(SMeta* pMeta); // tb_uid_t #define IVLD_TB_UID 0 -tb_uid_t metaGenerateUid(SMeta *pMeta); +tb_uid_t metaGenerateUid(SMeta* pMeta); struct SMeta { char* path; diff --git a/source/dnode/vnode/src/inc/vnd.h b/source/dnode/vnode/src/inc/vnd.h index f74497d309..7f43a93ab7 100644 --- a/source/dnode/vnode/src/inc/vnd.h +++ b/source/dnode/vnode/src/inc/vnd.h @@ -13,8 +13,8 @@ * along with this program. If not, see . */ -#ifndef _TD_VND_H_ -#define _TD_VND_H_ +#ifndef _TD_VNODE_DEF_H_ +#define _TD_VNODE_DEF_H_ #include "mallocator.h" // #include "sync.h" @@ -176,4 +176,4 @@ bool vmaIsFull(SVMemAllocator* pVMA); } #endif -#endif /*_TD_VND_H_*/ \ No newline at end of file +#endif /*_TD_VNODE_DEF_H_*/ \ No newline at end of file diff --git a/source/dnode/vnode/src/meta/metaMain.c b/source/dnode/vnode/src/meta/metaMain.c index b6aa029b19..ad87b2de9e 100644 --- a/source/dnode/vnode/src/meta/metaMain.c +++ b/source/dnode/vnode/src/meta/metaMain.c @@ -30,11 +30,11 @@ SMeta *metaOpen(const char *path, const SMetaCfg *pMetaCfg, SMemAllocatorFactory pMetaCfg = &defaultMetaOptions; } - // Validate the options - if (metaValidateOptions(pMetaCfg) < 0) { - // TODO: deal with error - return NULL; - } + // // Validate the options + // if (metaValidateOptions(pMetaCfg) < 0) { + // // TODO: deal with error + // return NULL; + // } // Allocate handle pMeta = metaNew(path, pMetaCfg, pMAF); From 3b4fabc70205fd6f4fd3e4a0b2581c2346907c9d Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Fri, 14 Jan 2022 08:11:58 +0000 Subject: [PATCH 7/9] more tkv --- source/libs/tdb/src/inc/tdbDB.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/libs/tdb/src/inc/tdbDB.h b/source/libs/tdb/src/inc/tdbDB.h index e6b49c94ec..fca197dc39 100644 --- a/source/libs/tdb/src/inc/tdbDB.h +++ b/source/libs/tdb/src/inc/tdbDB.h @@ -28,11 +28,13 @@ extern "C" { struct TDB { pgsize_t pageSize; tdb_db_t type; + char * fname; + char * dbname; union { TDB_BTREE *btree; TDB_HASH * hash; TDB_HEAP * heap; - } dbam; // Different access methods + } dbam; // db access method }; #ifdef __cplusplus From ac01ea4abb52773197fb7d30c72bec93887817f4 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Mon, 17 Jan 2022 02:36:26 +0000 Subject: [PATCH 8/9] more --- cmake/bdb_CMakeLists.txt.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/bdb_CMakeLists.txt.in b/cmake/bdb_CMakeLists.txt.in index 57acc95a11..651a657c0d 100644 --- a/cmake/bdb_CMakeLists.txt.in +++ b/cmake/bdb_CMakeLists.txt.in @@ -6,7 +6,7 @@ ExternalProject_Add(bdb SOURCE_DIR "${CMAKE_CONTRIB_DIR}/bdb" BINARY_DIR "${CMAKE_CONTRIB_DIR}/bdb" #BUILD_IN_SOURCE TRUE - CONFIGURE_COMMAND "./dist/configure" + CONFIGURE_COMMAND COMMAND ./dist/configure --enable-debug BUILD_COMMAND "$(MAKE)" INSTALL_COMMAND "" TEST_COMMAND "" From 4843d6484ea882be6aff56b3aafd87964ace552f Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Mon, 17 Jan 2022 03:58:39 +0000 Subject: [PATCH 9/9] fix memory leak --- source/dnode/vnode/src/vnd/vnodeWrite.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/dnode/vnode/src/vnd/vnodeWrite.c b/source/dnode/vnode/src/vnd/vnodeWrite.c index fb2d182e6c..bb863d6ed0 100644 --- a/source/dnode/vnode/src/vnd/vnodeWrite.c +++ b/source/dnode/vnode/src/vnd/vnodeWrite.c @@ -84,6 +84,7 @@ int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) { // TODO: handle error } vTrace("vgId:%d process create table %s", pVnode->vgId, pCreateTbReq->name); + free(pCreateTbReq->name); if (pCreateTbReq->type == TD_SUPER_TABLE) { free(pCreateTbReq->stbCfg.pSchema); free(pCreateTbReq->stbCfg.pTagSchema);