avoid a potential bug
This commit is contained in:
parent
4328ac123c
commit
4ee2cb13aa
|
@ -284,6 +284,7 @@ int32_t tsdbCloseRepo(TsdbRepoT *repo) {
|
||||||
pRepo->tsdbCache->curBlock = NULL;
|
pRepo->tsdbCache->curBlock = NULL;
|
||||||
tsdbUnLockRepo(repo);
|
tsdbUnLockRepo(repo);
|
||||||
|
|
||||||
|
if (pRepo->appH.notifyStatus) pRepo->appH.notifyStatus(pRepo->appH.appH, TSDB_STATUS_COMMIT_START);
|
||||||
tsdbCommitData((void *)repo);
|
tsdbCommitData((void *)repo);
|
||||||
|
|
||||||
tsdbCloseFileH(pRepo->tsdbFileH);
|
tsdbCloseFileH(pRepo->tsdbFileH);
|
||||||
|
|
|
@ -38,6 +38,7 @@ typedef struct {
|
||||||
int status;
|
int status;
|
||||||
int8_t role;
|
int8_t role;
|
||||||
int64_t version;
|
int64_t version;
|
||||||
|
int64_t savedVersion;
|
||||||
void *wqueue;
|
void *wqueue;
|
||||||
void *rqueue;
|
void *rqueue;
|
||||||
void *wal;
|
void *wal;
|
||||||
|
|
|
@ -380,8 +380,10 @@ static void vnodeCleanUp(SVnodeObj *pVnode) {
|
||||||
static int vnodeProcessTsdbStatus(void *arg, int status) {
|
static int vnodeProcessTsdbStatus(void *arg, int status) {
|
||||||
SVnodeObj *pVnode = arg;
|
SVnodeObj *pVnode = arg;
|
||||||
|
|
||||||
if (status == TSDB_STATUS_COMMIT_START)
|
if (status == TSDB_STATUS_COMMIT_START) {
|
||||||
|
pVnode->savedVersion = pVnode->version;
|
||||||
return walRenew(pVnode->wal);
|
return walRenew(pVnode->wal);
|
||||||
|
}
|
||||||
|
|
||||||
if (status == TSDB_STATUS_COMMIT_OVER)
|
if (status == TSDB_STATUS_COMMIT_OVER)
|
||||||
return vnodeSaveVersion(pVnode);
|
return vnodeSaveVersion(pVnode);
|
||||||
|
@ -690,14 +692,14 @@ static 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->version);
|
len += snprintf(content + len, maxLen - len, " \"version\": %" PRId64 "\n", pVnode->savedVersion);
|
||||||
len += snprintf(content + len, maxLen - len, "}\n");
|
len += snprintf(content + len, maxLen - len, "}\n");
|
||||||
|
|
||||||
fwrite(content, 1, len, fp);
|
fwrite(content, 1, len, fp);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
free(content);
|
free(content);
|
||||||
|
|
||||||
vPrint("vgId:%d, save vnode version:%" PRId64 " successed", pVnode->vgId, pVnode->version);
|
vPrint("vgId:%d, save vnode version:%" PRId64 " succeed", pVnode->vgId, pVnode->savedVersion);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -739,7 +741,7 @@ static bool vnodeReadVersion(SVnodeObj *pVnode) {
|
||||||
|
|
||||||
ret = true;
|
ret = true;
|
||||||
|
|
||||||
vPrint("vgId:%d, read vnode version successed, version:%%" PRId64, pVnode->vgId, pVnode->version);
|
vPrint("vgId:%d, read vnode version succeed, version:%" PRId64, pVnode->vgId, pVnode->version);
|
||||||
|
|
||||||
PARSE_OVER:
|
PARSE_OVER:
|
||||||
free(content);
|
free(content);
|
||||||
|
|
Loading…
Reference in New Issue