Merge pull request #28289 from taosdata/fix/TS-5519-main

enh: change tsdb snapshot strategy to accelerate the snapshot process
This commit is contained in:
Hongze Cheng 2024-10-10 17:15:03 +08:00 committed by GitHub
commit 50ecf90d58
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 16 additions and 1 deletions

View File

@ -623,6 +623,7 @@ static int32_t tsdbSnapWriteFileSetOpenReader(STsdbSnapWriter* writer) {
int32_t lino = 0; int32_t lino = 0;
if (writer->ctx->fset) { if (writer->ctx->fset) {
#if 0
// open data reader // open data reader
SDataFileReaderConfig dataFileReaderConfig = { SDataFileReaderConfig dataFileReaderConfig = {
.tsdb = writer->tsdb, .tsdb = writer->tsdb,
@ -650,6 +651,7 @@ static int32_t tsdbSnapWriteFileSetOpenReader(STsdbSnapWriter* writer) {
code = tsdbDataFileReaderOpen(NULL, &dataFileReaderConfig, &writer->ctx->dataReader); code = tsdbDataFileReaderOpen(NULL, &dataFileReaderConfig, &writer->ctx->dataReader);
TSDB_CHECK_CODE(code, lino, _exit); TSDB_CHECK_CODE(code, lino, _exit);
#endif
// open stt reader array // open stt reader array
SSttLvl* lvl; SSttLvl* lvl;
@ -791,6 +793,15 @@ static int32_t tsdbSnapWriteFileSetOpenWriter(STsdbSnapWriter* writer) {
.did = writer->ctx->did, .did = writer->ctx->did,
.level = 0, .level = 0,
}; };
// merge stt files to either data or a new stt file
if (writer->ctx->fset) {
for (int32_t ftype = 0; ftype < TSDB_FTYPE_MAX; ++ftype) {
if (writer->ctx->fset->farr[ftype] != NULL) {
config.files[ftype].exist = true;
config.files[ftype].file = writer->ctx->fset->farr[ftype]->f[0];
}
}
}
code = tsdbFSetWriterOpen(&config, &writer->ctx->fsetWriter); code = tsdbFSetWriterOpen(&config, &writer->ctx->fsetWriter);
TSDB_CHECK_CODE(code, lino, _exit); TSDB_CHECK_CODE(code, lino, _exit);
@ -842,6 +853,8 @@ static int32_t tsdbSnapWriteFileSetBegin(STsdbSnapWriter* writer, int32_t fid) {
_exit: _exit:
if (code) { if (code) {
TSDB_ERROR_LOG(TD_VID(writer->tsdb->pVnode), lino, code); TSDB_ERROR_LOG(TD_VID(writer->tsdb->pVnode), lino, code);
} else {
tsdbInfo("vgId:%d %s succeeded, fid:%d", TD_VID(writer->tsdb->pVnode), __func__, fid);
} }
return code; return code;
} }
@ -922,6 +935,8 @@ static int32_t tsdbSnapWriteFileSetEnd(STsdbSnapWriter* writer) {
_exit: _exit:
if (code) { if (code) {
TSDB_ERROR_LOG(TD_VID(writer->tsdb->pVnode), lino, code); TSDB_ERROR_LOG(TD_VID(writer->tsdb->pVnode), lino, code);
} else {
tsdbInfo("vgId:%d %s succeeded, fid:%d", TD_VID(writer->tsdb->pVnode), __func__, writer->ctx->fid);
} }
return code; return code;
} }
@ -1175,7 +1190,7 @@ _exit:
if (code) { if (code) {
TSDB_ERROR_LOG(TD_VID(tsdb->pVnode), lino, code); TSDB_ERROR_LOG(TD_VID(tsdb->pVnode), lino, code);
} else { } else {
tsdbInfo("vgId:%d %s done", TD_VID(tsdb->pVnode), __func__); tsdbInfo("vgId:%d %s done, rollback:%d", TD_VID(tsdb->pVnode), __func__, rollback);
} }
return code; return code;
} }