From: VinayBhaskar-V Date: Tue, 27 May 2025 13:28:51 +0000 (+0530) Subject: rbd-mirror: filter group snapshots by mirror_peer_uuid in group_replayer X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=4518da90b9a404356490b856354c2e555eb17060;p=ceph-ci.git rbd-mirror: filter group snapshots by mirror_peer_uuid in group_replayer 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 --- diff --git a/src/tools/rbd_mirror/group_replayer/Replayer.cc b/src/tools/rbd_mirror/group_replayer/Replayer.cc index 19e1f9bb3f6..f27045cf0b4 100644 --- a/src/tools/rbd_mirror/group_replayer/Replayer.cc +++ b/src/tools/rbd_mirror/group_replayer/Replayer.cc @@ -467,14 +467,32 @@ void Replayer::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( + &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( &last_remote_snap->snapshot_namespace);