]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
journal: possible race condition during live replay
authorJason Dillaman <dillaman@redhat.com>
Thu, 7 Apr 2016 21:34:37 +0000 (17:34 -0400)
committerJason Dillaman <dillaman@redhat.com>
Wed, 13 Apr 2016 01:29:12 +0000 (21:29 -0400)
When two objects are being actively watched, it was possible for
the watch context to complete before the second watch was
associated.

Fixes: http://tracker.ceph.com/issues/15352
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/journal/JournalPlayer.cc
src/journal/ObjectPlayer.cc

index 0d6b1776ac49ffae558069637d15efca7cfeca94..0244d9ad37da28548b40f36cabfa2fde70173deb 100644 (file)
@@ -535,16 +535,18 @@ void JournalPlayer::schedule_watch() {
   // poll first splay offset and active splay offset since
   // new records should only appear in those two objects
   C_Watch *ctx = new C_Watch(this);
-  ObjectPlayerPtr object_player = get_object_player();
-  object_player->watch(ctx, m_watch_interval);
 
+  ObjectPlayerPtr object_player = get_object_player();
   uint8_t splay_width = m_journal_metadata->get_splay_width();
   if (object_player->get_object_number() % splay_width != 0) {
     ++ctx->pending_fetches;
 
-    object_player = m_object_players.begin()->second.begin()->second;
-    object_player->watch(ctx, m_watch_interval);
+    ObjectPlayerPtr first_object_player =
+      m_object_players.begin()->second.begin()->second;
+    first_object_player->watch(ctx, m_watch_interval);
   }
+
+  object_player->watch(ctx, m_watch_interval);
   m_watch_scheduled = true;
 }
 
index db49d46ade2782a9987621ff4e77ec4caf985941..c299792f276e209faa36147a237c853d15e38508 100644 (file)
@@ -32,6 +32,7 @@ ObjectPlayer::~ObjectPlayer() {
     Mutex::Locker timer_locker(m_timer_lock);
     Mutex::Locker locker(m_lock);
     assert(!m_fetch_in_progress);
+    assert(!m_watch_in_progress);
     assert(m_watch_ctx == NULL);
   }
 }