diff --git a/src/inc/twal.h b/src/inc/twal.h index cf570aefdc50f26944706f4eddb1d44364986bca..73da96eb9be6aac478894971c31de62bdbc24f04 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 047ee0b4cc1c89344ec35efa0f16c1aca25ddc5d..028c3683816848a0c5b8d6abd4d14d8e65b62b75 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 5d7f8ee20be7f7b497dd56b9f7387a4cd71f8d34..4efbed0f1487203e35c1d5015c4333b9b5197713 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));