diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c index d2ab9de7c8..f19d715ce8 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c @@ -311,8 +311,8 @@ int32_t vmProcessAlterHashRangeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) { int32_t srcVgId = req.srcVgId; int32_t dstVgId = req.dstVgId; - dInfo("vgId:%d, alter hashrange msg will be processed, dstVgId:%d, begin:%u, end:%u", req.srcVgId, req.dstVgId, - req.hashBegin, req.hashEnd); + dInfo("vgId:%d, start to alter vnode hashrange[%u, %u), dstVgId:%d", req.srcVgId, req.hashBegin, req.hashEnd, + req.dstVgId); SVnodeObj *pVnode = vmAcquireVnode(pMgmt, srcVgId); if (pVnode == NULL) { @@ -321,33 +321,34 @@ int32_t vmProcessAlterHashRangeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) { return -1; } - dInfo("vgId:%d, start to close vnode", srcVgId); - vmCloseVnode(pMgmt, pVnode, true); - - char srcPath[TSDB_FILENAME_LEN] = {0}; - char dstPath[TSDB_FILENAME_LEN] = {0}; - snprintf(srcPath, TSDB_FILENAME_LEN, "vnode%svnode%d", TD_DIRSEP, srcVgId); - snprintf(dstPath, TSDB_FILENAME_LEN, "vnode%svnode%d", TD_DIRSEP, dstVgId); - - dInfo("vgId:%d, start to alter vnode hashrange at %s", srcVgId, srcPath); - if (vnodeAlterHashRange(srcPath, dstPath, &req, pMgmt->pTfs) < 0) { - dError("vgId:%d, failed to alter vnode hashrange since %s", srcVgId, terrstr()); - return -1; - } - - dInfo("vgId:%d, start to open vnode", dstVgId); - SVnode *pImpl = vnodeOpen(dstPath, pMgmt->pTfs, pMgmt->msgCb); - if (pImpl == NULL) { - dError("vgId:%d, failed to open vnode at %s since %s", dstVgId, dstPath, terrstr()); - return -1; - } - SWrapperCfg wrapperCfg = { .dropped = pVnode->dropped, .vgId = dstVgId, .vgVersion = pVnode->vgVersion, }; tstrncpy(wrapperCfg.path, pVnode->path, sizeof(wrapperCfg.path)); + + dInfo("vgId:%d, close vnode", srcVgId); + vmCloseVnode(pMgmt, pVnode, true); + + char srcPath[TSDB_FILENAME_LEN] = {0}; + char dstPath[TSDB_FILENAME_LEN] = {0}; + snprintf(srcPath, TSDB_FILENAME_LEN, "vnode%svnode%d", TD_DIRSEP, srcVgId); + snprintf(dstPath, TSDB_FILENAME_LEN, "vnode%svnode%d", TD_DIRSEP, dstVgId); + + dInfo("vgId:%d, alter vnode hashrange at %s", srcVgId, srcPath); + if (vnodeAlterHashRange(srcPath, dstPath, &req, pMgmt->pTfs) < 0) { + dError("vgId:%d, failed to alter vnode hashrange since %s", srcVgId, terrstr()); + return -1; + } + + dInfo("vgId:%d, open vnode", dstVgId); + SVnode *pImpl = vnodeOpen(dstPath, pMgmt->pTfs, pMgmt->msgCb); + if (pImpl == NULL) { + dError("vgId:%d, failed to open vnode at %s since %s", dstVgId, dstPath, terrstr()); + return -1; + } + if (vmOpenVnode(pMgmt, &wrapperCfg, pImpl) != 0) { dError("vgId:%d, failed to open vnode mgmt since %s", dstVgId, terrstr()); return -1; diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmInt.c b/source/dnode/mgmt/mgmt_vnode/src/vmInt.c index 61d83f4e8d..7fa536b84c 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmInt.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmInt.c @@ -128,6 +128,7 @@ void vmCloseVnode(SVnodeMgmt *pMgmt, SVnodeObj *pVnode, bool commitAndRemoveWal) if (commitAndRemoveWal) { dInfo("vgId:%d, commit data", pVnode->vgId); vnodeSyncCommit(pVnode->pImpl); + dInfo("vgId:%d, commit data finished", pVnode->vgId); } vnodeClose(pVnode->pImpl); diff --git a/source/libs/tdb/src/db/tdbPager.c b/source/libs/tdb/src/db/tdbPager.c index ced867e938..29b7fa740c 100644 --- a/source/libs/tdb/src/db/tdbPager.c +++ b/source/libs/tdb/src/db/tdbPager.c @@ -445,6 +445,11 @@ int tdbPagerAbort(SPager *pPager, TXN *pTxn) { SPgno journalSize = 0; int ret; + if (pTxn->jfd == 0) { + // txn is commited + return 0; + } + // sync the journal file ret = tdbOsFSync(pTxn->jfd); if (ret < 0) {