]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test/rbd-mirror: pool watcher registration error might result in race 37209/head
authorJason Dillaman <dillaman@redhat.com>
Wed, 5 Aug 2020 16:36:26 +0000 (12:36 -0400)
committerNathan Cutler <ncutler@suse.com>
Thu, 17 Sep 2020 05:12:43 +0000 (07:12 +0200)
The init finish context should be swapped out before it attempts to
re-register the watcher. This affects the test case which mocks the
timer to fire immediately instead of after 30 seconds.

Fixes: https://tracker.ceph.com/issues/46669
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
(cherry picked from commit c89d31ebf6c412d609123979c63ebc600b70e179)

Conflicts:
src/tools/rbd_mirror/PoolWatcher.cc
- nautilus uses Mutex::Locker where master has std::lock_guard

src/tools/rbd_mirror/PoolWatcher.cc

index b5c62b7b2d646f8b45d9fd283d145053d7e585f5..81810ea134ea260e68f560b47242af530e4ba6a4 100644 (file)
@@ -173,10 +173,12 @@ void PoolWatcher<I>::handle_register_watcher(int r) {
     std::swap(on_init_finish, m_on_init_finish);
   } else if (r == -ENOENT) {
     dout(5) << "mirroring directory does not exist" << dendl;
-    schedule_refresh_images(30);
+    {
+      Mutex::Locker locker(m_lock);
+      std::swap(on_init_finish, m_on_init_finish);
+    }
 
-    Mutex::Locker locker(m_lock);
-    std::swap(on_init_finish, m_on_init_finish);
+    schedule_refresh_images(30);
   } else {
     derr << "unexpected error registering mirroring directory watch: "
          << cpp_strerror(r) << dendl;