]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rbd-mirror: filter group snapshots by mirror_peer_uuid in group_replayer
authorVinayBhaskar-V <vvarada@redhat.com>
Tue, 27 May 2025 13:28:51 +0000 (18:58 +0530)
committerIlya Dryomov <idryomov@gmail.com>
Sun, 28 Sep 2025 18:25:05 +0000 (20:25 +0200)
The group_replayer::Replayer was previously including all remote group
snapshots during synchronization, regardless of whether they were
associated with the current peer's mirror_peer_uuid. This could result
in syncing snapshots that belong to other peers, leading to inconsistent
behavior.

This commit ensures that only remote group snapshots containing the
expected mirror_peer_uuid are processed. Snapshots that do not match
are filtered out early in the replay logic, preventing cross-peer
interference.

Signed-off-by: VinayBhaskar-V <vvarada@redhat.com>
src/tools/rbd_mirror/group_replayer/Replayer.cc

index 19e1f9bb3f621b3e683919665363128e75d91e45..f27045cf0b4d2edd7891f246caf143ace9b20598 100644 (file)
@@ -467,14 +467,32 @@ void Replayer<I>::handle_load_remote_group_snapshots(int r) {
   if (is_replay_interrupted()) {
     return;
   }
-
-  auto last_remote_snap = m_remote_group_snaps.rbegin();
   if (r < 0) {  // may be remote group is deleted?
     derr << "error listing remote mirror group snapshots: " << cpp_strerror(r)
          << dendl;
     handle_replay_complete(r, "failed to list remote group snapshots");
     return;
-  } else if (is_resync_requested()) {
+  }
+  for (auto remote_snap = m_remote_group_snaps.begin();
+       remote_snap != m_remote_group_snaps.end(); ) {
+    auto remote_snap_ns = std::get_if<cls::rbd::GroupSnapshotNamespaceMirror>(
+        &remote_snap->snapshot_namespace);
+    if (remote_snap_ns == nullptr) {
+      ++remote_snap;
+      continue;
+    }
+    if (remote_snap_ns->mirror_peer_uuids.count(m_remote_mirror_peer_uuid) == 0) {
+      dout(10) << "filtering out snapshot " << remote_snap->id
+               << " with no matching mirror_peer_uuid in: "
+               << remote_snap_ns->mirror_peer_uuids << " (expected: "
+               << m_remote_mirror_peer_uuid << ")" << dendl;
+      remote_snap = m_remote_group_snaps.erase(remote_snap);
+    } else {
+      ++remote_snap;
+    }
+  }
+  auto last_remote_snap = m_remote_group_snaps.rbegin();
+  if (is_resync_requested()) {
     dout(10) << "local group resync requested" << dendl;
     auto last_remote_snap_ns = std::get_if<cls::rbd::GroupSnapshotNamespaceMirror>(
         &last_remote_snap->snapshot_namespace);