From 5536505f1a82726175c498bb9ca3d39fd60633d0 Mon Sep 17 00:00:00 2001 From: walter Date: Thu, 26 Sep 2024 15:52:43 +0800 Subject: [PATCH] [fix](snapshot) Link binlog files according to consistent rowsets (#41319) In previous implementations, binlog files would be linked according to making snapshot requests. However, sometimes not all requests can be executed directly. For example, when a certain version in missing_version does not exist, it will fallback to the full snapshot. Therefore, it is correct to link binlog files according to consistent rowsets. --- be/src/olap/snapshot_manager.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/be/src/olap/snapshot_manager.cpp b/be/src/olap/snapshot_manager.cpp index f55980ce6c4b0a..6b97591014a25a 100644 --- a/be/src/olap/snapshot_manager.cpp +++ b/be/src/olap/snapshot_manager.cpp @@ -443,13 +443,13 @@ Status SnapshotManager::_create_snapshot_files(const TabletSharedPtr& ref_tablet string snapshot_id; RETURN_IF_ERROR(io::global_local_filesystem()->canonicalize(snapshot_id_path, &snapshot_id)); + std::vector consistent_rowsets; do { TabletMetaSharedPtr new_tablet_meta(new (nothrow) TabletMeta()); if (new_tablet_meta == nullptr) { res = Status::Error("fail to malloc TabletMeta."); break; } - std::vector consistent_rowsets; DeleteBitmap delete_bitmap_snapshot(new_tablet_meta->tablet_id()); /// If set missing_version, try to get all missing version. @@ -660,17 +660,16 @@ Status SnapshotManager::_create_snapshot_files(const TabletSharedPtr& ref_tablet } RowsetBinlogMetasPB rowset_binlog_metas_pb; - if (request.__isset.missing_version) { - res = ref_tablet->get_rowset_binlog_metas(request.missing_version, - &rowset_binlog_metas_pb); - } else { - std::vector missing_versions; - res = ref_tablet->get_rowset_binlog_metas(missing_versions, &rowset_binlog_metas_pb); - } - if (!res.ok()) { - break; + for (auto& rs : consistent_rowsets) { + if (!rs->is_local()) { + continue; + } + res = ref_tablet->get_rowset_binlog_metas(rs->version(), &rowset_binlog_metas_pb); + if (!res.ok()) { + break; + } } - if (rowset_binlog_metas_pb.rowset_binlog_metas_size() == 0) { + if (!res.ok() || rowset_binlog_metas_pb.rowset_binlog_metas_size() == 0) { break; }