From 050dd145e130be7ce8a80db7bbc4caca4359e4c3 Mon Sep 17 00:00:00 2001 From: slguan Date: Mon, 27 Apr 2020 15:42:27 +0800 Subject: [PATCH 1/2] [TD-184] handle bugs during wal synchronization --- src/vnode/src/vnodeMain.c | 2 +- src/vnode/src/vnodeWrite.c | 12 ++++++------ src/wal/src/walMain.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/vnode/src/vnodeMain.c b/src/vnode/src/vnodeMain.c index cac1030a93..9ae0588771 100644 --- a/src/vnode/src/vnodeMain.c +++ b/src/vnode/src/vnodeMain.c @@ -197,7 +197,7 @@ int32_t vnodeOpen(int32_t vnode, char *rootDir) { syncInfo.vgId = pVnode->vgId; syncInfo.version = pVnode->version; syncInfo.syncCfg = pVnode->syncCfg; - sprintf(syncInfo.path, "%s/tsdb/", rootDir); + sprintf(syncInfo.path, "%s", rootDir); syncInfo.ahandle = pVnode; syncInfo.getWalInfo = vnodeGetWalInfo; syncInfo.getFileInfo = vnodeGetFileInfo; diff --git a/src/vnode/src/vnodeWrite.c b/src/vnode/src/vnodeWrite.c index 26808f2e4e..6007379680 100644 --- a/src/vnode/src/vnodeWrite.c +++ b/src/vnode/src/vnodeWrite.c @@ -74,15 +74,15 @@ int32_t vnodeProcessWrite(void *param1, int qtype, void *param2, void *item) { // write into WAL code = walWrite(pVnode->wal, pHead); - if ( code < 0) return code; - + if (code < 0) return code; + + int32_t syncCode = syncForwardToPeer(pVnode->sync, pHead, item); + if (syncCode < 0) return syncCode; + code = (*vnodeProcessWriteMsgFp[pHead->msgType])(pVnode, pHead->cont, item); if (code < 0) return code; - if (pVnode->syncCfg.replica > 1) - code = syncForwardToPeer(pVnode->sync, pHead, item); - - return code; + return syncCode; } static int32_t vnodeProcessSubmitMsg(SVnodeObj *pVnode, void *pCont, SRspRet *pRet) { diff --git a/src/wal/src/walMain.c b/src/wal/src/walMain.c index 6a4ecee1c3..ad33391b98 100644 --- a/src/wal/src/walMain.c +++ b/src/wal/src/walMain.c @@ -269,7 +269,7 @@ int walGetWalFile(void *handle, char *name, uint32_t *index) { if (*index < first && *index > pWal->id) { code = -1; // index out of range } else { - sprintf(name, "%s/%s%d", pWal->path, walPrefix, *index); + sprintf(name, "wal/%s%d", walPrefix, *index); code = (*index == pWal->id) ? 0:1; } From e8f33da26f1ffd45eeea79377a518ae2c8c70b5f Mon Sep 17 00:00:00 2001 From: slguan Date: Mon, 27 Apr 2020 17:49:22 +0800 Subject: [PATCH 2/2] [TD-184] handle bugs during wal synchronization --- src/vnode/src/vnodeWrite.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vnode/src/vnodeWrite.c b/src/vnode/src/vnodeWrite.c index 6007379680..cfcc9cd847 100644 --- a/src/vnode/src/vnodeWrite.c +++ b/src/vnode/src/vnodeWrite.c @@ -58,7 +58,7 @@ int32_t vnodeProcessWrite(void *param1, int qtype, void *param2, void *item) { return TSDB_CODE_NOT_ACTIVE_VNODE; if (pVnode->syncCfg.replica > 1 && pVnode->role != TAOS_SYNC_ROLE_MASTER) - return TSDB_CODE_NO_MASTER; + return TSDB_CODE_NOT_READY; // assign version pVnode->version++;