diff --git a/src/inc/taoserror.h b/src/inc/taoserror.h index 84a214df8b4d3ecbe1b68237fb5704f66ec0ec0e..e29ca02036478b5c5831d6d49835cf72b43ea8ac 100644 --- a/src/inc/taoserror.h +++ b/src/inc/taoserror.h @@ -271,6 +271,7 @@ int32_t* taosGetErrno(); #define TSDB_CODE_TDB_MESSED_MSG TAOS_DEF_ERROR_CODE(0, 0x0614) //"TSDB messed message") #define TSDB_CODE_TDB_IVLD_TAG_VAL TAOS_DEF_ERROR_CODE(0, 0x0615) //"TSDB invalid tag value") #define TSDB_CODE_TDB_NO_CACHE_LAST_ROW TAOS_DEF_ERROR_CODE(0, 0x0616) //"TSDB no cache last row data") +#define TSDB_CODE_TDB_INCOMPLETE_DFILESET TAOS_DEF_ERROR_CODE(0, 0x0617) //"TSDB incomplete DFileSet") // query #define TSDB_CODE_QRY_INVALID_QHANDLE TAOS_DEF_ERROR_CODE(0, 0x0700) //"Invalid handle") diff --git a/src/tsdb/src/tsdbFS.c b/src/tsdb/src/tsdbFS.c index 2fa60d8dbeb160d8de10a87ec292b46098556756..a2e74e8b9fe7e1afcbe4f4eee806d8ac19132a44 100644 --- a/src/tsdb/src/tsdbFS.c +++ b/src/tsdb/src/tsdbFS.c @@ -1250,9 +1250,17 @@ static int tsdbRestoreDFileSet(STsdbRepo *pRepo) { ++nDFiles; pDFile->f = *pf; // (1) the array ends - if ((index == fArraySize - 1) && tsdbIsDFileSetValid(nDFiles)) { - tsdbInfo("vgId:%d DFileSet %d is fetched, nDFiles=%" PRIu8, REPO_ID(pRepo), fset.fid, nDFiles); - isOneFSetFinish = true; + if (index == fArraySize - 1) { + if (tsdbIsDFileSetValid(nDFiles)) { + tsdbInfo("vgId:%d DFileSet %d is fetched, nDFiles=%" PRIu8, REPO_ID(pRepo), fset.fid, nDFiles); + isOneFSetFinish = true; + } else { + // return error in case of removing uncomplete DFileSets + terrno = TSDB_CODE_TDB_INCOMPLETE_DFILESET; + tsdbError("vgId:%d incomplete DFileSet, fid:%d, nDFiles=%" PRIu8, REPO_ID(pRepo), fset.fid, nDFiles); + taosArrayDestroy(fArray); + return -1; + } } } else { // (2) encounter different fid @@ -1260,6 +1268,12 @@ static int tsdbRestoreDFileSet(STsdbRepo *pRepo) { tsdbInfo("vgId:%d DFileSet %d is fetched, nDFiles=%" PRIu8, REPO_ID(pRepo), fset.fid, nDFiles); isOneFSetFinish = true; } else { + // return error in case of removing uncomplete DFileSets + terrno = TSDB_CODE_TDB_INCOMPLETE_DFILESET; + tsdbError("vgId:%d incomplete DFileSet, fid:%d, nDFiles=%" PRIu8, REPO_ID(pRepo), fset.fid, nDFiles); + taosArrayDestroy(fArray); + return -1; +#if 0 // next FSet memset(&fset, 0, sizeof(SDFileSet)); TSDB_FSET_SET_CLOSED(&fset); @@ -1268,6 +1282,7 @@ static int tsdbRestoreDFileSet(STsdbRepo *pRepo) { pDFile->f = *pf; isOneFSetFinish = false; continue; +#endif } } } diff --git a/src/util/src/terror.c b/src/util/src/terror.c index ce4d981c9aec201564491c9bbc82f3b2e2ebe0e1..379b7530fa5a898938b9bf0b552e09ab4fbc70b8 100644 --- a/src/util/src/terror.c +++ b/src/util/src/terror.c @@ -278,6 +278,8 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TDB_IVD_CREATE_TABLE_INFO, "Invalid information t TAOS_DEFINE_ERROR(TSDB_CODE_TDB_NO_AVAIL_DISK, "No available disk") TAOS_DEFINE_ERROR(TSDB_CODE_TDB_MESSED_MSG, "TSDB messed message") TAOS_DEFINE_ERROR(TSDB_CODE_TDB_IVLD_TAG_VAL, "TSDB invalid tag value") +TAOS_DEFINE_ERROR(TSDB_CODE_TDB_NO_CACHE_LAST_ROW, "TSDB no cache last row data") +TAOS_DEFINE_ERROR(TSDB_CODE_TDB_INCOMPLETE_DFILESET, "Incomplete DFileSet") // query TAOS_DEFINE_ERROR(TSDB_CODE_QRY_INVALID_QHANDLE, "Invalid handle")