]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd-mirror: edge-condition for promote/demote during daemon failover 21657/head
authorJason Dillaman <dillaman@redhat.com>
Thu, 26 Apr 2018 04:09:51 +0000 (00:09 -0400)
committerJason Dillaman <dillaman@redhat.com>
Thu, 26 Apr 2018 04:11:28 +0000 (00:11 -0400)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/tools/rbd_mirror/ImageReplayer.cc

index de6ae330860157c5151d244457520390cf90b73c..165a37088017f652cd1c10aaee5be47690235265 100644 (file)
@@ -1070,9 +1070,22 @@ void ImageReplayer<I>::allocate_local_tag() {
   } else if (mirror_uuid == m_local_mirror_uuid) {
     mirror_uuid = librbd::Journal<>::LOCAL_MIRROR_UUID;
   } else if (mirror_uuid == librbd::Journal<>::ORPHAN_MIRROR_UUID) {
-    dout(5) << "encountered image demotion: stopping" << dendl;
-    Mutex::Locker locker(m_lock);
-    m_stop_requested = true;
+    // handle possible edge condition where daemon can failover and
+    // the local image has already been promoted/demoted
+    auto local_tag_data = m_local_journal->get_tag_data();
+    if (local_tag_data.mirror_uuid == librbd::Journal<>::ORPHAN_MIRROR_UUID &&
+        (local_tag_data.predecessor.commit_valid &&
+         local_tag_data.predecessor.mirror_uuid ==
+           librbd::Journal<>::LOCAL_MIRROR_UUID)) {
+      dout(15) << "skipping stale demotion event" << dendl;
+      handle_process_entry_safe(m_replay_entry, 0);
+      handle_replay_ready();
+      return;
+    } else {
+      dout(5) << "encountered image demotion: stopping" << dendl;
+      Mutex::Locker locker(m_lock);
+      m_stop_requested = true;
+    }
   }
 
   librbd::journal::TagPredecessor predecessor(m_replay_tag_data.predecessor);