diff --git a/src/tsdb/inc/tsdbFile.h b/src/tsdb/inc/tsdbFile.h index 6d1e0cf2461a28dbcf481c7dc93d651551c0453d..ea5cc60d446fcc1f7d589e24f04771ef54a14b3f 100644 --- a/src/tsdb/inc/tsdbFile.h +++ b/src/tsdb/inc/tsdbFile.h @@ -257,7 +257,13 @@ static FORCE_INLINE int tsdbAppendDFile(SDFile* pDFile, void* buf, int64_t nbyte return -1; } - ASSERT(pDFile->info.size == toffset); + //bug fix. To avoid data corruption, + //the end offset of current file should be checked with file size, + //if not equal, known as file corrupted and return error. + if (pDFile->info.size != toffset) { + terrno = TSDB_CODE_TDB_FILE_CORRUPTED; + return -1; + } if (offset) { *offset = toffset;