diff --git a/src/tsdb/inc/tsdbFile.h b/src/tsdb/inc/tsdbFile.h index 75e95631513e354960df5119b25ac3b6620a29d8..4ad1e5b3173a2fb4bea9135ea1766e36feb449e2 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, close the data file in advance. + //ASSERT(pDFile->info.size == toffset); + if (pDFile->info.size != toffset) { + tsdbCloseDFile(pDFile); + terrno = TAOS_SYSTEM_ERROR(errno); + return -1; + } if (offset) { *offset = toffset;