]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd_mirror: fix cross namespace group snapshot mirroring
authorPrasanna Kumar Kalever <prasanna.kalever@redhat.com>
Thu, 3 Apr 2025 10:47:39 +0000 (16:17 +0530)
committerPrasanna Kumar Kalever <prasanna.kalever@redhat.com>
Thu, 24 Apr 2025 15:56:38 +0000 (21:26 +0530)
In case if group belongs to non-default namespace, the mirror daemon on
secondary is setting an empty mirror peer uuid on non primary demote snapshot.
And when previous secondary turns into primary (by an explicit promote request)
the previous i.e. non primary demote snapshot is getting unlinked as part of
the promote request as there is no mirror peer uuid set on it. Because the
previous dependent snapshot is removed, there are split-brain errors leading
to recent test failures.

This fix makesure to set the right mirror peer uuid on the non primary demote
snapshot even if the group belong to non-default namespace.

Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
src/tools/rbd_mirror/group_replayer/Replayer.cc

index 6805a30db6bc076ff8049b29eee90915a943e1e5..8c323ea9e940a6861b9d0e077572dad2a592ae46 100644 (file)
@@ -767,10 +767,16 @@ void Replayer<I>::create_mirror_snapshot(
   int r;
   std::set<std::string> mirror_peer_uuids;
   if (snap_state == cls::rbd::MIRROR_SNAPSHOT_STATE_NON_PRIMARY_DEMOTED) {
+    librados::IoCtx default_ns_io_ctx;
+    default_ns_io_ctx.dup(m_local_io_ctx);
+    default_ns_io_ctx.set_namespace("");
     std::vector<cls::rbd::MirrorPeer> mirror_peers;
-    r = librbd::cls_client::mirror_peer_list(&m_local_io_ctx, &mirror_peers);
+    r = librbd::cls_client::mirror_peer_list(&default_ns_io_ctx, &mirror_peers);
     if (r < 0) {
-      derr << "failed to list peers: " << cpp_strerror(r) << dendl;
+      derr << "failed to list mirror peers: " << cpp_strerror(r) << dendl;
+      locker.unlock();
+      on_finish->complete(r);
+      return;
     }
 
     for (auto &peer : mirror_peers) {