提交 4f0ed079 编写于 作者: S Shengliang Guan

TD-1919 change version type to uint64

上级 047955ab
...@@ -63,7 +63,7 @@ int32_t walWrite(twalh, SWalHead *); ...@@ -63,7 +63,7 @@ int32_t walWrite(twalh, SWalHead *);
void walFsync(twalh, bool forceFsync); void walFsync(twalh, bool forceFsync);
int32_t walRestore(twalh, void *pVnode, FWalWrite writeFp); int32_t walRestore(twalh, void *pVnode, FWalWrite writeFp);
int32_t walGetWalFile(twalh, char *fileName, int64_t *fileId); int32_t walGetWalFile(twalh, char *fileName, int64_t *fileId);
int64_t walGetVersion(twalh); uint64_t walGetVersion(twalh);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -41,8 +41,8 @@ typedef struct { ...@@ -41,8 +41,8 @@ typedef struct {
int8_t status; int8_t status;
int8_t role; int8_t role;
int8_t accessState; int8_t accessState;
int64_t version; // current version uint64_t version; // current version
int64_t fversion; // version on saved data file uint64_t fversion; // version on saved data file
void *wqueue; void *wqueue;
void *rqueue; void *rqueue;
void *wal; void *wal;
......
...@@ -227,6 +227,7 @@ int32_t vnodeOpen(int32_t vnode, char *rootDir) { ...@@ -227,6 +227,7 @@ int32_t vnodeOpen(int32_t vnode, char *rootDir) {
pVnode->vgId = vnode; pVnode->vgId = vnode;
pVnode->status = TAOS_VN_STATUS_INIT; pVnode->status = TAOS_VN_STATUS_INIT;
pVnode->fversion = 0;
pVnode->version = 0; pVnode->version = 0;
pVnode->tsdbCfg.tsdbId = pVnode->vgId; pVnode->tsdbCfg.tsdbId = pVnode->vgId;
pVnode->rootDir = strdup(rootDir); pVnode->rootDir = strdup(rootDir);
...@@ -288,6 +289,7 @@ int32_t vnodeOpen(int32_t vnode, char *rootDir) { ...@@ -288,6 +289,7 @@ int32_t vnodeOpen(int32_t vnode, char *rootDir) {
vnodeCleanUp(pVnode); vnodeCleanUp(pVnode);
return terrno; return terrno;
} else { } else {
pVnode->fversion = 0;
pVnode->version = 0; pVnode->version = 0;
} }
} }
...@@ -302,6 +304,7 @@ int32_t vnodeOpen(int32_t vnode, char *rootDir) { ...@@ -302,6 +304,7 @@ int32_t vnodeOpen(int32_t vnode, char *rootDir) {
walRestore(pVnode->wal, pVnode, vnodeProcessWrite); walRestore(pVnode->wal, pVnode, vnodeProcessWrite);
if (pVnode->version == 0) { if (pVnode->version == 0) {
pVnode->fversion = 0;
pVnode->version = walGetVersion(pVnode->wal); pVnode->version = walGetVersion(pVnode->wal);
} }
......
...@@ -61,10 +61,10 @@ int32_t vnodeReadVersion(SVnodeObj *pVnode) { ...@@ -61,10 +61,10 @@ int32_t vnodeReadVersion(SVnodeObj *pVnode) {
vError("vgId:%d, failed to read %s, version not found", pVnode->vgId, file); vError("vgId:%d, failed to read %s, version not found", pVnode->vgId, file);
goto PARSE_VER_ERROR; goto PARSE_VER_ERROR;
} }
pVnode->version = ver->valueint; pVnode->version = (uint64_t)ver->valueint;
terrno = TSDB_CODE_SUCCESS; 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: PARSE_VER_ERROR:
if (content != NULL) free(content); if (content != NULL) free(content);
...@@ -89,7 +89,7 @@ int32_t vnodeSaveVersion(SVnodeObj *pVnode) { ...@@ -89,7 +89,7 @@ int32_t vnodeSaveVersion(SVnodeObj *pVnode) {
char * content = calloc(1, maxLen + 1); char * content = calloc(1, maxLen + 1);
len += snprintf(content + len, maxLen - len, "{\n"); 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"); len += snprintf(content + len, maxLen - len, "}\n");
fwrite(content, 1, len, fp); fwrite(content, 1, len, fp);
...@@ -98,6 +98,6 @@ int32_t vnodeSaveVersion(SVnodeObj *pVnode) { ...@@ -98,6 +98,6 @@ int32_t vnodeSaveVersion(SVnodeObj *pVnode) {
free(content); free(content);
terrno = 0; 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; return TSDB_CODE_SUCCESS;
} }
\ No newline at end of file
...@@ -310,7 +310,7 @@ static int32_t walRestoreWalFile(SWal *pWal, void *pVnode, FWalWrite writeFp, ch ...@@ -310,7 +310,7 @@ static int32_t walRestoreWalFile(SWal *pWal, void *pVnode, FWalWrite writeFp, ch
return code; return code;
} }
int64_t walGetVersion(twalh param) { uint64_t walGetVersion(twalh param) {
SWal *pWal = param; SWal *pWal = param;
if (pWal == 0) return 0; if (pWal == 0) return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册