diff --git a/src/tsdb/inc/tsdbFS.h b/src/tsdb/inc/tsdbFS.h index 0ce9850b0d4152431ab769a8596cee62cd09a0a8..2339fed52fecb62f4942fb237d0beb2edf2f8eb1 100644 --- a/src/tsdb/inc/tsdbFS.h +++ b/src/tsdb/inc/tsdbFS.h @@ -27,6 +27,7 @@ typedef enum { } ETsdbFsVer; #define TSDB_FVER_TYPE uint32_t +#define TSDB_LATEST_FVER TSDB_FS_VER_1 static FORCE_INLINE uint32_t tsdbGetDFSVersion(TSDB_FILE_T fType) { // latest version for DFile switch (fType) { diff --git a/src/tsdb/src/tsdbCommit.c b/src/tsdb/src/tsdbCommit.c index ad8757f006bdc17c70ec33f9ba5e578485ce38f1..e3839f9638700f03b937c109f077103274694b08 100644 --- a/src/tsdb/src/tsdbCommit.c +++ b/src/tsdb/src/tsdbCommit.c @@ -1600,7 +1600,7 @@ static int tsdbSetAndOpenCommitFile(SCommitH *pCommith, SDFileSet *pSet, int fid SDFile *pRDataf = TSDB_READ_DATA_FILE(&(pCommith->readh)); SDFile *pWDataf = TSDB_COMMIT_DATA_FILE(pCommith); tsdbInitDFileEx(pWDataf, pRDataf); - if (tsdbOpenDFile(pWDataf, O_RDWR) < 0) { + if (tsdbOpenDFile(pWDataf, O_WRONLY) < 0) { tsdbError("vgId:%d failed to open file %s to commit since %s", REPO_ID(pRepo), TSDB_FILE_FULL_NAME(pWDataf), tstrerror(terrno)); @@ -1620,7 +1620,7 @@ static int tsdbSetAndOpenCommitFile(SCommitH *pCommith, SDFileSet *pSet, int fid tsdbInitDFileEx(pWLastf, pRLastf); pCommith->isLFileSame = true; - if (tsdbOpenDFile(pWLastf, O_RDWR) < 0) { + if (tsdbOpenDFile(pWLastf, O_WRONLY) < 0) { tsdbError("vgId:%d failed to open file %s to commit since %s", REPO_ID(pRepo), TSDB_FILE_FULL_NAME(pWLastf), tstrerror(terrno)); diff --git a/src/tsdb/src/tsdbFS.c b/src/tsdb/src/tsdbFS.c index 60c73e2d27019cf2e78926fc4c33b976619c8a7b..96a0349e9d647b9e7f22b839a8a687963d0b1163 100644 --- a/src/tsdb/src/tsdbFS.c +++ b/src/tsdb/src/tsdbFS.c @@ -1207,7 +1207,7 @@ static int tsdbRestoreDFileSet(STsdbRepo *pRepo) { TSDB_FSET_SET_INIT(&fset); // Loop to recover ONE fset - for (TSDB_FILE_T ftype = 0; ftype < TSDB_FILE_MAX - 1; ftype++) { + for (TSDB_FILE_T ftype = 0; ftype < TSDB_FILE_MAX; ftype++) { SDFile *pDFile = TSDB_DFILE_IN_SET(&fset, ftype); if (index >= taosArrayGetSize(fArray)) { diff --git a/src/tsdb/src/tsdbFile.c b/src/tsdb/src/tsdbFile.c index 20d521e32e40bb4e957102ca0f60ac78ed67e104..9924a640b089fb6cbf6518e18a74f4fcaf32ad7c 100644 --- a/src/tsdb/src/tsdbFile.c +++ b/src/tsdb/src/tsdbFile.c @@ -341,7 +341,7 @@ static int tsdbEncodeSDFileEx(void **buf, SDFile *pDFile) { static void *tsdbDecodeSDFileEx(void *buf, SDFile *pDFile) { char *aname; - + // The sync module would send DFileSet with latest verion. buf = tsdbDecodeDFInfo(buf, &(pDFile->info), tsdbGetSFSVersion()); buf = taosDecodeString(buf, &aname); strncpy(TSDB_FILE_FULL_NAME(pDFile), aname, TSDB_FILENAME_LEN); @@ -430,7 +430,7 @@ int tsdbLoadDFileHeader(SDFile *pDFile, SDFInfo *pInfo) { } void *pBuf = buf; - pBuf = tsdbDecodeDFInfo(pBuf, pInfo, TSDB_FS_VER_1); + pBuf = tsdbDecodeDFInfo(pBuf, pInfo, TSDB_LATEST_FVER); return 0; }