From edd939991302e8db65dfc39ef3950b7656a6d19e Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Wed, 27 Jan 2021 10:18:14 +0800 Subject: [PATCH] fix tsdb file truncate bug --- src/tsdb/src/tsdbFile.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/tsdb/src/tsdbFile.c b/src/tsdb/src/tsdbFile.c index 6a424b0b7c..ec001eef0e 100644 --- a/src/tsdb/src/tsdbFile.c +++ b/src/tsdb/src/tsdbFile.c @@ -202,7 +202,7 @@ int tsdbScanAndTryFixMFile(STsdbRepo *pRepo) { return -1; } - if (pMFile->info.size > mfstat.st_size) { + if (pMFile->info.size < mfstat.st_size) { if (tsdbOpenMFile(&mf, O_WRONLY) < 0) { return -1; } @@ -221,7 +221,7 @@ int tsdbScanAndTryFixMFile(STsdbRepo *pRepo) { tsdbCloseMFile(&mf); tsdbInfo("vgId:%d file %s is truncated from %" PRId64 " to %" PRId64, REPO_ID(pRepo), TSDB_FILE_FULL_NAME(pMFile), mfstat.st_size, pMFile->info.size); - } else if (pMFile->info.size < mfstat.st_size) { + } else if (pMFile->info.size > mfstat.st_size) { tsdbError("vgId:%d meta file %s has wrong size %" PRId64 " expected %" PRId64 ", report to upper layer to fix it", REPO_ID(pRepo), TSDB_FILE_FULL_NAME(pMFile), mfstat.st_size, pMFile->info.size); pRepo->state |= TSDB_STATE_BAD_META; @@ -428,7 +428,7 @@ static int tsdbScanAndTryFixDFile(STsdbRepo *pRepo, SDFile *pDFile) { return -1; } - if (pDFile->info.size > dfstat.st_size) { + if (pDFile->info.size < dfstat.st_size) { if (tsdbOpenDFile(&df, O_WRONLY) < 0) { return -1; } @@ -447,7 +447,7 @@ static int tsdbScanAndTryFixDFile(STsdbRepo *pRepo, SDFile *pDFile) { tsdbCloseDFile(&df); tsdbInfo("vgId:%d file %s is truncated from %" PRId64 " to %" PRId64, REPO_ID(pRepo), TSDB_FILE_FULL_NAME(pDFile), dfstat.st_size, pDFile->info.size); - } else if (pDFile->info.size < dfstat.st_size) { + } else if (pDFile->info.size > dfstat.st_size) { tsdbError("vgId:%d data file %s has wrong size %" PRId64 " expected %" PRId64 ", report to upper layer to fix it", REPO_ID(pRepo), TSDB_FILE_FULL_NAME(pDFile), dfstat.st_size, pDFile->info.size); pRepo->state |= TSDB_STATE_BAD_DATA; -- GitLab