fix: tsdb snapshot bug
This commit is contained in:
parent
9083d3c03b
commit
32c5b6a947
|
@ -551,8 +551,8 @@ struct STsdbSnapWriter {
|
||||||
int32_t fid;
|
int32_t fid;
|
||||||
STFileSet* fset;
|
STFileSet* fset;
|
||||||
SDiskID did;
|
SDiskID did;
|
||||||
bool hasData;
|
bool hasData; // if have time series data
|
||||||
bool hasTomb;
|
bool hasTomb; // if have tomb data
|
||||||
|
|
||||||
// reader
|
// reader
|
||||||
SDataFileReader* dataReader;
|
SDataFileReader* dataReader;
|
||||||
|
@ -630,6 +630,15 @@ static int32_t tsdbSnapWriteFileSetOpenReader(STsdbSnapWriter* writer) {
|
||||||
|
|
||||||
dataFileReaderConfig.files[ftype].exist = true;
|
dataFileReaderConfig.files[ftype].exist = true;
|
||||||
dataFileReaderConfig.files[ftype].file = writer->ctx->fset->farr[ftype]->f[0];
|
dataFileReaderConfig.files[ftype].file = writer->ctx->fset->farr[ftype]->f[0];
|
||||||
|
|
||||||
|
STFileOp fileOp = {
|
||||||
|
.optype = TSDB_FOP_REMOVE,
|
||||||
|
.fid = writer->ctx->fset->fid,
|
||||||
|
.of = writer->ctx->fset->farr[ftype]->f[0],
|
||||||
|
};
|
||||||
|
|
||||||
|
code = TARRAY2_APPEND(writer->fopArr, fileOp);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
}
|
}
|
||||||
|
|
||||||
code = tsdbDataFileReaderOpen(NULL, &dataFileReaderConfig, &writer->ctx->dataReader);
|
code = tsdbDataFileReaderOpen(NULL, &dataFileReaderConfig, &writer->ctx->dataReader);
|
||||||
|
@ -653,6 +662,15 @@ static int32_t tsdbSnapWriteFileSetOpenReader(STsdbSnapWriter* writer) {
|
||||||
|
|
||||||
code = TARRAY2_APPEND(writer->ctx->sttReaderArr, reader);
|
code = TARRAY2_APPEND(writer->ctx->sttReaderArr, reader);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
|
STFileOp fileOp = {
|
||||||
|
.optype = TSDB_FOP_REMOVE,
|
||||||
|
.fid = fobj->f->fid,
|
||||||
|
.of = fobj->f[0],
|
||||||
|
};
|
||||||
|
|
||||||
|
code = TARRAY2_APPEND(writer->fopArr, fileOp);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -862,6 +880,7 @@ static int32_t tsdbSnapWriteFileSetEnd(STsdbSnapWriter* writer) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int32_t lino = 0;
|
int32_t lino = 0;
|
||||||
|
|
||||||
|
// end timeseries data write
|
||||||
SRowInfo row = {
|
SRowInfo row = {
|
||||||
.suid = INT64_MAX,
|
.suid = INT64_MAX,
|
||||||
.uid = INT64_MAX,
|
.uid = INT64_MAX,
|
||||||
|
@ -870,6 +889,7 @@ static int32_t tsdbSnapWriteFileSetEnd(STsdbSnapWriter* writer) {
|
||||||
code = tsdbSnapWriteTimeSeriesRow(writer, &row);
|
code = tsdbSnapWriteTimeSeriesRow(writer, &row);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
|
// end tombstone data write
|
||||||
STombRecord record = {
|
STombRecord record = {
|
||||||
.suid = INT64_MAX,
|
.suid = INT64_MAX,
|
||||||
.uid = INT64_MAX,
|
.uid = INT64_MAX,
|
||||||
|
@ -1008,6 +1028,10 @@ int32_t tsdbSnapWriterOpen(STsdb* pTsdb, int64_t sver, int64_t ever, STsdbSnapWr
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int32_t lino = 0;
|
int32_t lino = 0;
|
||||||
|
|
||||||
|
// disable background tasks
|
||||||
|
tsdbFSDisableBgTask(pTsdb->pFS);
|
||||||
|
|
||||||
|
// start to write
|
||||||
writer[0] = taosMemoryCalloc(1, sizeof(*writer[0]));
|
writer[0] = taosMemoryCalloc(1, sizeof(*writer[0]));
|
||||||
if (writer[0] == NULL) return TSDB_CODE_OUT_OF_MEMORY;
|
if (writer[0] == NULL) return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
|
@ -1026,8 +1050,6 @@ int32_t tsdbSnapWriterOpen(STsdb* pTsdb, int64_t sver, int64_t ever, STsdbSnapWr
|
||||||
code = tsdbFSCreateCopySnapshot(pTsdb->pFS, &writer[0]->fsetArr);
|
code = tsdbFSCreateCopySnapshot(pTsdb->pFS, &writer[0]->fsetArr);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
tsdbFSDisableBgTask(pTsdb->pFS);
|
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
if (code) {
|
if (code) {
|
||||||
tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
|
tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
|
||||||
|
|
Loading…
Reference in New Issue