MB-19503: Fix ConnMap so notifications don't go missing. 34/63934/4
authorJim Walker <jim@couchbase.com>
Wed, 11 May 2016 15:26:47 +0000 (16:26 +0100)
committerDave Rigby <daver@couchbase.com>
Fri, 13 May 2016 15:09:07 +0000 (15:09 +0000)
There's a reliance on an atomic bool and cmpxchg to
prevent the producer of notification from queueing
himself if he's already got a notification scheduled.

There's an ordering issue though where the producers code
can execute, see the flag is true and not bother queueing
a notification, yet the consumer side is about to clear the
flag and finish. The notification thus never gets queued
and the producer side thinks he will get a notification.

In my terminology:
producer is ConnMap::notifyPausedConnection
consumer is ConnMap::notifyAllPausedConnections

Change-Id: Id324b6369c5ee3a6b6758a7a93e017a4ff7c4a78
Reviewed-on: http://review.couchbase.org/63934
Well-Formed: buildbot <build@couchbase.com>
Reviewed-by: Dave Rigby <daver@couchbase.com>
Tested-by: buildbot <build@couchbase.com>
src/connmap.cc

index 7eb96e0..824f447 100644 (file)
@@ -250,10 +250,10 @@ void ConnMap::notifyAllPausedConnections() {
         connection_t &conn = queue.front();
         Notifiable *tp = dynamic_cast<Notifiable*>(conn.get());
         if (tp && tp->isPaused() && conn->isReserved()) {
+            tp->setNotificationScheduled(false);
             engine.notifyIOComplete(conn->getCookie(), ENGINE_SUCCESS);
             tp->setNotifySent(true);
         }
-        tp->setNotificationScheduled(false);
         queue.pop();
     }
 }