From 4f0ed0792185d9cb414d3539739212e0cef4e053 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Sun, 8 Nov 2020 13:56:41 +0000 Subject: [PATCH] TD-1919 change version type to uint64 --- src/inc/twal.h | 2 +- src/vnode/inc/vnodeInt.h | 4 ++-- src/vnode/src/vnodeMain.c | 3 +++ src/vnode/src/vnodeVersion.c | 8 ++++---- src/wal/src/walWrite.c | 2 +- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/inc/twal.h b/src/inc/twal.h index a9e0ddd6b7..c32bb87021 100644 --- a/src/inc/twal.h +++ b/src/inc/twal.h @@ -63,7 +63,7 @@ int32_t walWrite(twalh, SWalHead *); void walFsync(twalh, bool forceFsync); int32_t walRestore(twalh, void *pVnode, FWalWrite writeFp); int32_t walGetWalFile(twalh, char *fileName, int64_t *fileId); -int64_t walGetVersion(twalh); +uint64_t walGetVersion(twalh); #ifdef __cplusplus } diff --git a/src/vnode/inc/vnodeInt.h b/src/vnode/inc/vnodeInt.h index 89ec277006..317d4904cb 100644 --- a/src/vnode/inc/vnodeInt.h +++ b/src/vnode/inc/vnodeInt.h @@ -41,8 +41,8 @@ typedef struct { int8_t status; int8_t role; int8_t accessState; - int64_t version; // current version - int64_t fversion; // version on saved data file + uint64_t version; // current version + uint64_t fversion; // version on saved data file void *wqueue; void *rqueue; void *wal; diff --git a/src/vnode/src/vnodeMain.c b/src/vnode/src/vnodeMain.c index f5b670f423..4cdf9f898a 100644 --- a/src/vnode/src/vnodeMain.c +++ b/src/vnode/src/vnodeMain.c @@ -227,6 +227,7 @@ int32_t vnodeOpen(int32_t vnode, char *rootDir) { pVnode->vgId = vnode; pVnode->status = TAOS_VN_STATUS_INIT; + pVnode->fversion = 0; pVnode->version = 0; pVnode->tsdbCfg.tsdbId = pVnode->vgId; pVnode->rootDir = strdup(rootDir); @@ -288,6 +289,7 @@ int32_t vnodeOpen(int32_t vnode, char *rootDir) { vnodeCleanUp(pVnode); return terrno; } else { + pVnode->fversion = 0; pVnode->version = 0; } } @@ -302,6 +304,7 @@ int32_t vnodeOpen(int32_t vnode, char *rootDir) { walRestore(pVnode->wal, pVnode, vnodeProcessWrite); if (pVnode->version == 0) { + pVnode->fversion = 0; pVnode->version = walGetVersion(pVnode->wal); } diff --git a/src/vnode/src/vnodeVersion.c b/src/vnode/src/vnodeVersion.c index 1d0695fb53..51f9ac8f3a 100644 --- a/src/vnode/src/vnodeVersion.c +++ b/src/vnode/src/vnodeVersion.c @@ -61,10 +61,10 @@ int32_t vnodeReadVersion(SVnodeObj *pVnode) { vError("vgId:%d, failed to read %s, version not found", pVnode->vgId, file); goto PARSE_VER_ERROR; } - pVnode->version = ver->valueint; + pVnode->version = (uint64_t)ver->valueint; terrno = TSDB_CODE_SUCCESS; - vInfo("vgId:%d, read %s successfully, version:%" PRId64, pVnode->vgId, file, pVnode->version); + vInfo("vgId:%d, read %s successfully, version:%" PRIu64, pVnode->vgId, file, pVnode->version); PARSE_VER_ERROR: if (content != NULL) free(content); @@ -89,7 +89,7 @@ int32_t vnodeSaveVersion(SVnodeObj *pVnode) { char * content = calloc(1, maxLen + 1); len += snprintf(content + len, maxLen - len, "{\n"); - len += snprintf(content + len, maxLen - len, " \"version\": %" PRId64 "\n", pVnode->fversion); + len += snprintf(content + len, maxLen - len, " \"version\": %" PRIu64 "\n", pVnode->fversion); len += snprintf(content + len, maxLen - len, "}\n"); fwrite(content, 1, len, fp); @@ -98,6 +98,6 @@ int32_t vnodeSaveVersion(SVnodeObj *pVnode) { free(content); terrno = 0; - vInfo("vgId:%d, successed to write %s, version:%" PRId64, pVnode->vgId, file, pVnode->fversion); + vInfo("vgId:%d, successed to write %s, version:%" PRIu64, pVnode->vgId, file, pVnode->fversion); return TSDB_CODE_SUCCESS; } \ No newline at end of file diff --git a/src/wal/src/walWrite.c b/src/wal/src/walWrite.c index b4769fe57b..ecd0fd0ca0 100644 --- a/src/wal/src/walWrite.c +++ b/src/wal/src/walWrite.c @@ -310,7 +310,7 @@ static int32_t walRestoreWalFile(SWal *pWal, void *pVnode, FWalWrite writeFp, ch return code; } -int64_t walGetVersion(twalh param) { +uint64_t walGetVersion(twalh param) { SWal *pWal = param; if (pWal == 0) return 0; -- GitLab