From 1da7d9b593da0b97b858c0fe8f67bcb39f112583 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Tue, 13 Oct 2020 19:31:17 +0800 Subject: [PATCH] TD-1652 --- src/inc/twal.h | 1 + src/vnode/src/vnodeWrite.c | 3 ++- src/wal/src/walMain.c | 15 +++++++++++++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/inc/twal.h b/src/inc/twal.h index cf570aefdc..73da96eb9b 100644 --- a/src/inc/twal.h +++ b/src/inc/twal.h @@ -51,6 +51,7 @@ int walWrite(twalh, SWalHead *); void walFsync(twalh); int walRestore(twalh, void *pVnode, FWalWrite writeFp); int walGetWalFile(twalh, char *name, uint32_t *index); +void walResetVersion(void *handle, uint64_t version); extern int wDebugFlag; diff --git a/src/vnode/src/vnodeWrite.c b/src/vnode/src/vnodeWrite.c index 047ee0b4cc..028c368381 100644 --- a/src/vnode/src/vnodeWrite.c +++ b/src/vnode/src/vnodeWrite.c @@ -98,7 +98,8 @@ int32_t vnodeProcessWrite(void *param1, int qtype, void *param2, void *item) { syncCode = syncForwardToPeer(pVnode->sync, pHead, item, qtype); if (syncCode < 0) { pVnode->version = lastVersion; - vError("vgId:%d, msgType:%s not processed, reason:%s, wal ver:%" PRIu64 " restore to last ver:%" PRIu64, + walResetVersion(pVnode->wal, lastVersion); + vError("vgId:%d, msgType:%s not processed, reason:%s, wal ver:%" PRIu64 " set to last ver:%" PRIu64, pVnode->vgId, taosMsg[pHead->msgType], tstrerror(syncCode), pHead->version, pVnode->version); return syncCode; } diff --git a/src/wal/src/walMain.c b/src/wal/src/walMain.c index 5d7f8ee20b..4efbed0f14 100644 --- a/src/wal/src/walMain.c +++ b/src/wal/src/walMain.c @@ -233,15 +233,26 @@ int walRenew(void *handle) { return terrno; } +void walResetVersion(void *handle, uint64_t version) { + SWal *pWal = handle; + if (pWal == NULL) return; + + pWal->version = version; + wInfo("wal:%s, reset ver to %" PRIu64, pWal->name, version); +} + int walWrite(void *handle, SWalHead *pHead) { SWal *pWal = handle; if (pWal == NULL) return -1; terrno = 0; - // no wal + // no wal if (pWal->level == TAOS_WAL_NOLOG) return 0; - if (pHead->version <= pWal->version) return 0; + if (pHead->version <= pWal->version) { + wError("wal:%s, failed to write ver:%" PRIu64 ", last ver:%" PRIu64, pWal->name, pHead->version, pWal->version); + return 0; + } pHead->signature = walSignature; taosCalcChecksumAppend(0, (uint8_t *)pHead, sizeof(SWalHead)); -- GitLab