diff --git a/include/dnode/vnode/vnode.h b/include/dnode/vnode/vnode.h index 4332fc8e58..6113d0a536 100644 --- a/include/dnode/vnode/vnode.h +++ b/include/dnode/vnode/vnode.h @@ -89,10 +89,10 @@ typedef struct { int vnodeInit(const SVnodeOpt *pOption); /** - * @brief clear a vnode + * @brief Cleanup the vnode module * */ -void vnodeClear(); +void vnodeCleanup(); /** * @brief Open a VNODE. diff --git a/include/libs/tfs/tfs.h b/include/libs/tfs/tfs.h index 6c850d1016..793c861363 100644 --- a/include/libs/tfs/tfs.h +++ b/include/libs/tfs/tfs.h @@ -49,7 +49,7 @@ typedef struct { } STierMeta; int tfsInit(SDiskCfg *pDiskCfg, int ndisk); -void tfsDestroy(); +void tfsCleanup(); void tfsUpdateInfo(SFSMeta *pFSMeta, STierMeta *tierMetas, int8_t numLevels); void tfsGetMeta(SFSMeta *pMeta); void tfsAllocDisk(int expLevel, int *level, int *id); diff --git a/source/dnode/mgmt/impl/src/dndEnv.c b/source/dnode/mgmt/impl/src/dndEnv.c index 44a01049ba..88e38daf1c 100644 --- a/source/dnode/mgmt/impl/src/dndEnv.c +++ b/source/dnode/mgmt/impl/src/dndEnv.c @@ -173,18 +173,6 @@ SDnode *dndCreate(SDnodeObjCfg *pCfg) { return NULL; } - if (rpcInit() != 0) { - dError("failed to init rpc since %s", terrstr()); - dndClose(pDnode); - return NULL; - } - - if (walInit() != 0) { - dError("failed to init wal since %s", terrstr()); - dndClose(pDnode); - return NULL; - } - SDiskCfg dCfg; strcpy(dCfg.dir, pDnode->cfg.dataDir); dCfg.level = 0; @@ -277,10 +265,8 @@ void dndClose(SDnode *pDnode) { dndCleanupQnode(pDnode); dndCleanupVnodes(pDnode); dndCleanupMgmt(pDnode); - vnodeClear(); - tfsDestroy(); - walCleanUp(); - rpcCleanup(); + vnodeCleanup(); + tfsCleanup(); dndCloseImp(pDnode); free(pDnode); @@ -298,6 +284,18 @@ int32_t dndInit(const SDnodeEnvCfg *pCfg) { taosBlockSIGPIPE(); taosResolveCRC(); + if (rpcInit() != 0) { + dError("failed to init rpc since %s", terrstr()); + dndCleanup(); + return -1; + } + + if (walInit() != 0) { + dError("failed to init wal since %s", terrstr()); + dndCleanup(); + return -1; + } + memcpy(&dndEnv.cfg, pCfg, sizeof(SDnodeEnvCfg)); dInfo("dnode env is initialized"); return 0; @@ -309,6 +307,9 @@ void dndCleanup() { return; } + walCleanUp(); + rpcCleanup(); + taosStopCacheRefreshWorker(); dInfo("dnode env is cleaned up"); } \ No newline at end of file diff --git a/source/dnode/vnode/impl/src/vnodeMgr.c b/source/dnode/vnode/impl/src/vnodeMgr.c index cc369a0d15..15550a899b 100644 --- a/source/dnode/vnode/impl/src/vnodeMgr.c +++ b/source/dnode/vnode/impl/src/vnodeMgr.c @@ -56,7 +56,7 @@ int vnodeInit(const SVnodeOpt *pOption) { return 0; } -void vnodeClear() { +void vnodeCleanup() { if (TD_CHECK_AND_SET_MOD_CLEAR(&(vnodeMgr.vnodeInitFlag)) == TD_MOD_UNINITIALIZED) { return; } diff --git a/source/dnode/vnode/impl/test/vnodeApiTests.cpp b/source/dnode/vnode/impl/test/vnodeApiTests.cpp index 71ffdd1d0f..6ec58a1e9d 100644 --- a/source/dnode/vnode/impl/test/vnodeApiTests.cpp +++ b/source/dnode/vnode/impl/test/vnodeApiTests.cpp @@ -227,7 +227,7 @@ TEST(vnodeApiTest, vnode_simple_create_table_test) { // CLOSE THE VNODE vnodeClose(pVnode); - vnodeClear(); + vnodeCleanup(); taosArrayDestroy(pMsgArr); } @@ -279,7 +279,7 @@ TEST(vnodeApiTest, vnode_simple_insert_test) { // Close the vnode vnodeClose(pVnode); - vnodeClear(); + vnodeCleanup(); taosArrayDestroy(pMsgArr); } \ No newline at end of file diff --git a/source/libs/tfs/src/tfs.c b/source/libs/tfs/src/tfs.c index 83d9905511..88d6d587a7 100644 --- a/source/libs/tfs/src/tfs.c +++ b/source/libs/tfs/src/tfs.c @@ -85,19 +85,19 @@ int tfsInit(SDiskCfg *pDiskCfg, int ndisk) { taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK); if (pfs->map == NULL) { terrno = TSDB_CODE_FS_OUT_OF_MEMORY; - tfsDestroy(); + tfsCleanup(); return -1; } for (int idisk = 0; idisk < ndisk; idisk++) { if (tfsMount(pDiskCfg + idisk) < 0) { - tfsDestroy(); + tfsCleanup(); return -1; } } if (tfsCheck() < 0) { - tfsDestroy(); + tfsCleanup(); return -1; } @@ -109,7 +109,7 @@ int tfsInit(SDiskCfg *pDiskCfg, int ndisk) { return 0; } -void tfsDestroy() { +void tfsCleanup() { taosHashCleanup(pfs->map); pfs->map = NULL; diff --git a/src/inc/tfs.h b/src/inc/tfs.h index 11e33a3af7..9ad7a8f66e 100644 --- a/src/inc/tfs.h +++ b/src/inc/tfs.h @@ -49,7 +49,7 @@ typedef struct { } STierMeta; int tfsInit(SDiskCfg *pDiskCfg, int ndisk); -void tfsDestroy(); +void tfsCleanup(); void tfsUpdateInfo(SFSMeta *pFSMeta, STierMeta *tierMetas, int8_t numLevels); void tfsGetMeta(SFSMeta *pMeta); void tfsAllocDisk(int expLevel, int *level, int *id);