diff --git a/source/dnode/vnode/src/tsdb/tsdbCommit.c b/source/dnode/vnode/src/tsdb/tsdbCommit.c index 26c313f42146fddc6c7690d0bb0cf2ecba21ccdc..f7e4d56fe2c22e77895b9b6971c8a937b6277c68 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCommit.c +++ b/source/dnode/vnode/src/tsdb/tsdbCommit.c @@ -523,7 +523,8 @@ 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_WRONLY) < 0) { + // if (tsdbOpenDFile(pWDataf, O_WRONLY) < 0) { + if (tsdbOpenDFile(pWDataf, TD_FILE_WRITE) < 0) { tsdbError("vgId:%d failed to open file %s to commit since %s", REPO_ID(pRepo), TSDB_FILE_FULL_NAME(pWDataf), tstrerror(terrno)); @@ -543,7 +544,8 @@ static int tsdbSetAndOpenCommitFile(SCommitH *pCommith, SDFileSet *pSet, int fid tsdbInitDFileEx(pWLastf, pRLastf); pCommith->isLFileSame = true; - if (tsdbOpenDFile(pWLastf, O_WRONLY) < 0) { + // if (tsdbOpenDFile(pWLastf, O_WRONLY) < 0) { + if (tsdbOpenDFile(pWLastf, TD_FILE_WRITE) < 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/source/dnode/vnode/src/tsdb/tsdbFS.c b/source/dnode/vnode/src/tsdb/tsdbFS.c index 9a444a1c178e925b922c34b0a58fc6085dfd8f08..24c765d3e5939c4dcb3fb9cb6244a25592b6f4bc 100644 --- a/source/dnode/vnode/src/tsdb/tsdbFS.c +++ b/source/dnode/vnode/src/tsdb/tsdbFS.c @@ -1229,7 +1229,8 @@ static int tsdbRestoreDFileSet(STsdb *pRepo) { pDFile->f = *pf; - if (tsdbOpenDFile(pDFile, O_RDONLY) < 0) { + // if (tsdbOpenDFile(pDFile, O_RDONLY) < 0) { + if (tsdbOpenDFile(pDFile, TD_FILE_READ) < 0) { tsdbError("vgId:%d failed to open DFile %s since %s", REPO_ID(pRepo), TSDB_FILE_FULL_NAME(pDFile), tstrerror(terrno)); taosArrayDestroy(fArray); @@ -1338,7 +1339,8 @@ static void tsdbScanAndTryFixDFilesHeader(STsdb *pRepo, int32_t *nExpired) { } tsdbDebug("vgId:%d scan DFileSet %d header", REPO_ID(pRepo), fset.fid); - if (tsdbOpenDFileSet(&fset, O_RDWR) < 0) { + // if (tsdbOpenDFileSet(&fset, O_RDWR) < 0) { + if (tsdbOpenDFileSet(&fset, TD_FILE_WRITE | TD_FILE_READ) < 0) { tsdbError("vgId:%d failed to open DFileSet %d since %s, continue", REPO_ID(pRepo), fset.fid, tstrerror(terrno)); continue; } diff --git a/source/dnode/vnode/src/tsdb/tsdbFile.c b/source/dnode/vnode/src/tsdb/tsdbFile.c index ff79d91081099d2225a43301ff96b05a341b9b46..36fb2b11100d2ef29c31f99dc2e446d0d0d7f0af 100644 --- a/source/dnode/vnode/src/tsdb/tsdbFile.c +++ b/source/dnode/vnode/src/tsdb/tsdbFile.c @@ -456,7 +456,8 @@ static int tsdbScanAndTryFixDFile(STsdb *pRepo, SDFile *pDFile) { } if (pDFile->info.size < dfstat.st_size) { - if (tsdbOpenDFile(&df, O_WRONLY) < 0) { + // if (tsdbOpenDFile(&df, O_WRONLY) < 0) { + if (tsdbOpenDFile(&df, TD_FILE_WRITE) < 0) { return -1; } @@ -537,7 +538,8 @@ static int tsdbApplyDFileChange(SDFile *from, SDFile *to) { static int tsdbRollBackDFile(SDFile *pDFile) { SDFile df = *pDFile; - if (tsdbOpenDFile(&df, O_WRONLY) < 0) { + // if (tsdbOpenDFile(&df, O_WRONLY) < 0) { + if (tsdbOpenDFile(&df, TD_FILE_WRITE) < 0) { return -1; } diff --git a/source/dnode/vnode/src/tsdb/tsdbReadImpl.c b/source/dnode/vnode/src/tsdb/tsdbReadImpl.c index d06e37286d457506d1f1198e8f66a60bc37123ae..7e8e7866d71addb8a125998bf3fa54963b2466cb 100644 --- a/source/dnode/vnode/src/tsdb/tsdbReadImpl.c +++ b/source/dnode/vnode/src/tsdb/tsdbReadImpl.c @@ -83,7 +83,8 @@ int tsdbSetAndOpenReadFSet(SReadH *pReadh, SDFileSet *pSet) { pReadh->rSet = *pSet; TSDB_FSET_SET_CLOSED(TSDB_READ_FSET(pReadh)); - if (tsdbOpenDFileSet(TSDB_READ_FSET(pReadh), O_RDONLY) < 0) { + // if (tsdbOpenDFileSet(TSDB_READ_FSET(pReadh), O_RDONLY) < 0) { + if (tsdbOpenDFileSet(TSDB_READ_FSET(pReadh), TD_FILE_READ) < 0) { tsdbError("vgId:%d failed to open file set %d since %s", TSDB_READ_REPO_ID(pReadh), TSDB_FSET_FID(pSet), tstrerror(terrno)); return -1; diff --git a/source/os/src/osFile.c b/source/os/src/osFile.c index 4bfe618f2cc2854daecb71883d74604deff48f70..8188cfd34a2b7372556ea0663f1670bc5300f116 100644 --- a/source/os/src/osFile.c +++ b/source/os/src/osFile.c @@ -602,7 +602,8 @@ int taosGetErrorFile(TdFilePtr pFile) { return errno; } size_t taosGetLineFile(TdFilePtr pFile, char ** __restrict__ ptrBuf) { - return getline(ptrBuf, NULL, pFile->fp); + size_t len = 0; + return getline(ptrBuf, &len, pFile->fp); } int32_t taosEOFFile(TdFilePtr pFile) { return feof(pFile->fp);