Merge pull request #10399 from taosdata/fix/ZhiqiangWang/TD-13062-file-system-getline-error
[TD-13062]<fix>: file system getline error.
This commit is contained in:
commit
d1e628187a
|
@ -215,7 +215,7 @@ static FORCE_INLINE void tsdbCloseDFile(SDFile* pDFile) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE int64_t tsdbSeekDFile(SDFile* pDFile, int64_t offset, int whence) {
|
static FORCE_INLINE int64_t tsdbSeekDFile(SDFile* pDFile, int64_t offset, int whence) {
|
||||||
ASSERT(TSDB_FILE_OPENED(pDFile));
|
// ASSERT(TSDB_FILE_OPENED(pDFile));
|
||||||
|
|
||||||
int64_t loffset = taosLSeekFile(TSDB_FILE_PFILE(pDFile), offset, whence);
|
int64_t loffset = taosLSeekFile(TSDB_FILE_PFILE(pDFile), offset, whence);
|
||||||
if (loffset < 0) {
|
if (loffset < 0) {
|
||||||
|
|
|
@ -523,7 +523,8 @@ static int tsdbSetAndOpenCommitFile(SCommitH *pCommith, SDFileSet *pSet, int fid
|
||||||
SDFile *pRDataf = TSDB_READ_DATA_FILE(&(pCommith->readh));
|
SDFile *pRDataf = TSDB_READ_DATA_FILE(&(pCommith->readh));
|
||||||
SDFile *pWDataf = TSDB_COMMIT_DATA_FILE(pCommith);
|
SDFile *pWDataf = TSDB_COMMIT_DATA_FILE(pCommith);
|
||||||
tsdbInitDFileEx(pWDataf, pRDataf);
|
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),
|
tsdbError("vgId:%d failed to open file %s to commit since %s", REPO_ID(pRepo), TSDB_FILE_FULL_NAME(pWDataf),
|
||||||
tstrerror(terrno));
|
tstrerror(terrno));
|
||||||
|
|
||||||
|
@ -543,7 +544,8 @@ static int tsdbSetAndOpenCommitFile(SCommitH *pCommith, SDFileSet *pSet, int fid
|
||||||
tsdbInitDFileEx(pWLastf, pRLastf);
|
tsdbInitDFileEx(pWLastf, pRLastf);
|
||||||
pCommith->isLFileSame = true;
|
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),
|
tsdbError("vgId:%d failed to open file %s to commit since %s", REPO_ID(pRepo), TSDB_FILE_FULL_NAME(pWLastf),
|
||||||
tstrerror(terrno));
|
tstrerror(terrno));
|
||||||
|
|
||||||
|
|
|
@ -1229,7 +1229,8 @@ static int tsdbRestoreDFileSet(STsdb *pRepo) {
|
||||||
|
|
||||||
pDFile->f = *pf;
|
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),
|
tsdbError("vgId:%d failed to open DFile %s since %s", REPO_ID(pRepo), TSDB_FILE_FULL_NAME(pDFile),
|
||||||
tstrerror(terrno));
|
tstrerror(terrno));
|
||||||
taosArrayDestroy(fArray);
|
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);
|
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));
|
tsdbError("vgId:%d failed to open DFileSet %d since %s, continue", REPO_ID(pRepo), fset.fid, tstrerror(terrno));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -456,7 +456,8 @@ static int tsdbScanAndTryFixDFile(STsdb *pRepo, SDFile *pDFile) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pDFile->info.size < dfstat.st_size) {
|
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;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -537,7 +538,8 @@ static int tsdbApplyDFileChange(SDFile *from, SDFile *to) {
|
||||||
static int tsdbRollBackDFile(SDFile *pDFile) {
|
static int tsdbRollBackDFile(SDFile *pDFile) {
|
||||||
SDFile df = *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;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,8 @@ int tsdbSetAndOpenReadFSet(SReadH *pReadh, SDFileSet *pSet) {
|
||||||
|
|
||||||
pReadh->rSet = *pSet;
|
pReadh->rSet = *pSet;
|
||||||
TSDB_FSET_SET_CLOSED(TSDB_READ_FSET(pReadh));
|
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),
|
tsdbError("vgId:%d failed to open file set %d since %s", TSDB_READ_REPO_ID(pReadh), TSDB_FSET_FID(pSet),
|
||||||
tstrerror(terrno));
|
tstrerror(terrno));
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -308,6 +308,7 @@ int64_t taosWriteFile(TdFilePtr pFile, const void *buf, int64_t count) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t taosLSeekFile(TdFilePtr pFile, int64_t offset, int32_t whence) {
|
int64_t taosLSeekFile(TdFilePtr pFile, int64_t offset, int32_t whence) {
|
||||||
|
if (pFile == NULL) return -1;
|
||||||
return (int64_t)lseek(pFile->fd, (long)offset, whence);
|
return (int64_t)lseek(pFile->fd, (long)offset, whence);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -602,7 +603,8 @@ int taosGetErrorFile(TdFilePtr pFile) {
|
||||||
return errno;
|
return errno;
|
||||||
}
|
}
|
||||||
size_t taosGetLineFile(TdFilePtr pFile, char ** __restrict__ ptrBuf) {
|
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) {
|
int32_t taosEOFFile(TdFilePtr pFile) {
|
||||||
return feof(pFile->fp);
|
return feof(pFile->fp);
|
||||||
|
|
Loading…
Reference in New Issue