提交 f6248d21 编写于 作者: S Shengliang Guan

fix: coredump if no data while vnode commit

上级 53ac9c72
...@@ -311,8 +311,8 @@ int32_t vmProcessAlterHashRangeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) { ...@@ -311,8 +311,8 @@ int32_t vmProcessAlterHashRangeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
int32_t srcVgId = req.srcVgId; int32_t srcVgId = req.srcVgId;
int32_t dstVgId = req.dstVgId; int32_t dstVgId = req.dstVgId;
dInfo("vgId:%d, alter hashrange msg will be processed, dstVgId:%d, begin:%u, end:%u", req.srcVgId, req.dstVgId, dInfo("vgId:%d, start to alter vnode hashrange[%u, %u), dstVgId:%d", req.srcVgId, req.hashBegin, req.hashEnd,
req.hashBegin, req.hashEnd); req.dstVgId);
SVnodeObj *pVnode = vmAcquireVnode(pMgmt, srcVgId); SVnodeObj *pVnode = vmAcquireVnode(pMgmt, srcVgId);
if (pVnode == NULL) { if (pVnode == NULL) {
...@@ -321,7 +321,14 @@ int32_t vmProcessAlterHashRangeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) { ...@@ -321,7 +321,14 @@ int32_t vmProcessAlterHashRangeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
return -1; return -1;
} }
dInfo("vgId:%d, start to close vnode", srcVgId); 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); vmCloseVnode(pMgmt, pVnode, true);
char srcPath[TSDB_FILENAME_LEN] = {0}; char srcPath[TSDB_FILENAME_LEN] = {0};
...@@ -329,25 +336,19 @@ int32_t vmProcessAlterHashRangeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) { ...@@ -329,25 +336,19 @@ int32_t vmProcessAlterHashRangeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
snprintf(srcPath, TSDB_FILENAME_LEN, "vnode%svnode%d", TD_DIRSEP, srcVgId); snprintf(srcPath, TSDB_FILENAME_LEN, "vnode%svnode%d", TD_DIRSEP, srcVgId);
snprintf(dstPath, TSDB_FILENAME_LEN, "vnode%svnode%d", TD_DIRSEP, dstVgId); snprintf(dstPath, TSDB_FILENAME_LEN, "vnode%svnode%d", TD_DIRSEP, dstVgId);
dInfo("vgId:%d, start to alter vnode hashrange at %s", srcVgId, srcPath); dInfo("vgId:%d, alter vnode hashrange at %s", srcVgId, srcPath);
if (vnodeAlterHashRange(srcPath, dstPath, &req, pMgmt->pTfs) < 0) { if (vnodeAlterHashRange(srcPath, dstPath, &req, pMgmt->pTfs) < 0) {
dError("vgId:%d, failed to alter vnode hashrange since %s", srcVgId, terrstr()); dError("vgId:%d, failed to alter vnode hashrange since %s", srcVgId, terrstr());
return -1; return -1;
} }
dInfo("vgId:%d, start to open vnode", dstVgId); dInfo("vgId:%d, open vnode", dstVgId);
SVnode *pImpl = vnodeOpen(dstPath, pMgmt->pTfs, pMgmt->msgCb); SVnode *pImpl = vnodeOpen(dstPath, pMgmt->pTfs, pMgmt->msgCb);
if (pImpl == NULL) { if (pImpl == NULL) {
dError("vgId:%d, failed to open vnode at %s since %s", dstVgId, dstPath, terrstr()); dError("vgId:%d, failed to open vnode at %s since %s", dstVgId, dstPath, terrstr());
return -1; return -1;
} }
SWrapperCfg wrapperCfg = {
.dropped = pVnode->dropped,
.vgId = dstVgId,
.vgVersion = pVnode->vgVersion,
};
tstrncpy(wrapperCfg.path, pVnode->path, sizeof(wrapperCfg.path));
if (vmOpenVnode(pMgmt, &wrapperCfg, pImpl) != 0) { if (vmOpenVnode(pMgmt, &wrapperCfg, pImpl) != 0) {
dError("vgId:%d, failed to open vnode mgmt since %s", dstVgId, terrstr()); dError("vgId:%d, failed to open vnode mgmt since %s", dstVgId, terrstr());
return -1; return -1;
......
...@@ -128,6 +128,7 @@ void vmCloseVnode(SVnodeMgmt *pMgmt, SVnodeObj *pVnode, bool commitAndRemoveWal) ...@@ -128,6 +128,7 @@ void vmCloseVnode(SVnodeMgmt *pMgmt, SVnodeObj *pVnode, bool commitAndRemoveWal)
if (commitAndRemoveWal) { if (commitAndRemoveWal) {
dInfo("vgId:%d, commit data", pVnode->vgId); dInfo("vgId:%d, commit data", pVnode->vgId);
vnodeSyncCommit(pVnode->pImpl); vnodeSyncCommit(pVnode->pImpl);
dInfo("vgId:%d, commit data finished", pVnode->vgId);
} }
vnodeClose(pVnode->pImpl); vnodeClose(pVnode->pImpl);
......
...@@ -445,6 +445,11 @@ int tdbPagerAbort(SPager *pPager, TXN *pTxn) { ...@@ -445,6 +445,11 @@ int tdbPagerAbort(SPager *pPager, TXN *pTxn) {
SPgno journalSize = 0; SPgno journalSize = 0;
int ret; int ret;
if (pTxn->jfd == 0) {
// txn is commited
return 0;
}
// sync the journal file // sync the journal file
ret = tdbOsFSync(pTxn->jfd); ret = tdbOsFSync(pTxn->jfd);
if (ret < 0) { if (ret < 0) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册