diff --git a/src/tfs/src/tfs.c b/src/tfs/src/tfs.c index 01f5dc613b..36f3b4ee53 100644 --- a/src/tfs/src/tfs.c +++ b/src/tfs/src/tfs.c @@ -162,7 +162,7 @@ const char *TFS_DISK_PATH(int level, int id) { return DISK_DIR(TFS_DISK_AT(level // TFILE APIs ==================================== static void tfsSetFileAname(TFILE *pf) { if (TFS_IS_VALID_DISK(pf->level, pf->id)) { - SDisk *pDisk = TFS_DISK_AT(pf->level, pf->level); + SDisk *pDisk = TFS_DISK_AT(pf->level, pf->id); ASSERT(pDisk != NULL); snprintf(pf->aname, TSDB_FILENAME_LEN, "%s/%s", DISK_DIR(pDisk), pf->rname); } diff --git a/src/tsdb/inc/tsdbMain.h b/src/tsdb/inc/tsdbMain.h index b9714be599..1f8e0f9347 100644 --- a/src/tsdb/inc/tsdbMain.h +++ b/src/tsdb/inc/tsdbMain.h @@ -511,7 +511,7 @@ static FORCE_INLINE STsdbBufBlock* tsdbGetCurrBufBlock(STsdbRepo* pRepo) { STsdbFileH* tsdbNewFileH(STsdbCfg* pCfg); void tsdbFreeFileH(STsdbFileH* pFileH); int tsdbOpenFileH(STsdbRepo* pRepo); -void tsdbCloseFileH(STsdbRepo* pRepo); +void tsdbCloseFileH(STsdbRepo* pRepo, bool isRestart); SFileGroup *tsdbCreateFGroup(STsdbRepo *pRepo, int fid, int level); void tsdbInitFileGroupIter(STsdbFileH* pFileH, SFileGroupIter* pIter, int direction); void tsdbSeekFileGroupIter(SFileGroupIter* pIter, int fid); diff --git a/src/tsdb/src/tsdbFile.c b/src/tsdb/src/tsdbFile.c index f0e8eb4037..24fdf93a60 100644 --- a/src/tsdb/src/tsdbFile.c +++ b/src/tsdb/src/tsdbFile.c @@ -124,7 +124,7 @@ int tsdbOpenFileH(STsdbRepo *pRepo) { return 0; } -void tsdbCloseFileH(STsdbRepo *pRepo) { +void tsdbCloseFileH(STsdbRepo *pRepo, bool isRestart) { STsdbFileH *pFileH = pRepo->tsdbFileH; for (int i = 0; i < pFileH->nFGroups; i++) { @@ -132,7 +132,9 @@ void tsdbCloseFileH(STsdbRepo *pRepo) { for (int type = 0; type < TSDB_FILE_TYPE_MAX; type++) { tsdbCloseFile(&(pFGroup->files[type])); } - tfsDecDiskFile(pFGroup->files[0].file.level, pFGroup->files[0].file.level, TSDB_FILE_TYPE_MAX); + if (isRestart) { + tfsDecDiskFile(pFGroup->files[0].file.level, pFGroup->files[0].file.level, TSDB_FILE_TYPE_MAX); + } } } diff --git a/src/tsdb/src/tsdbMain.c b/src/tsdb/src/tsdbMain.c index c7b0a0257b..da1b184c3c 100644 --- a/src/tsdb/src/tsdbMain.c +++ b/src/tsdb/src/tsdbMain.c @@ -151,7 +151,7 @@ int tsdbCloseRepo(TSDB_REPO_T *repo, int toCommit) { pRepo->mem = NULL; pRepo->imem = NULL; - tsdbCloseFileH(pRepo); + tsdbCloseFileH(pRepo, !toCommit); tsdbCloseBufPool(pRepo); tsdbCloseMeta(pRepo); tsdbFreeRepo(pRepo);