]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd-mirror: edge-condition for promote/demote during daemon failover 21741/head
authorJason Dillaman <dillaman@redhat.com>
Thu, 26 Apr 2018 04:09:51 +0000 (00:09 -0400)
committerPrashant D <pdhange@redhat.com>
Mon, 30 Apr 2018 12:37:12 +0000 (08:37 -0400)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
(cherry picked from commit 408e4ad7895daac3250c4fbd840c838ae88fd381)

src/tools/rbd_mirror/ImageReplayer.cc

index f107068330018ab609efeaf484832429e2e34106..cb5ff818088128d9666888be7bb4e396ce39381f 100644 (file)
@@ -1096,9 +1096,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);