From 4254a77c40d6f3502099637c4a43c9ab9ed53990 Mon Sep 17 00:00:00 2001 From: w41ter Date: Thu, 26 Sep 2024 01:50:39 +0000 Subject: [PATCH] [fix](snapshot) Link binlog files according to consistent rowsets In previous implementations, binlog files would be linked according to making snapshot request. 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 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 e0bfaf704dd7e7..2cfa9a8e8b763d 100644 --- a/be/src/olap/snapshot_manager.cpp +++ b/be/src/olap/snapshot_manager.cpp @@ -411,13 +411,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. @@ -628,17 +628,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; }