MB-17889: No notify from streamRequest 52/60352/3 v3.1.4
authorJim Walker <jim@couchbase.com>
Mon, 22 Feb 2016 21:01:09 +0000 (21:01 +0000)
committerChiyoung Seo <chiyoung@couchbase.com>
Tue, 23 Feb 2016 18:11:09 +0000 (18:11 +0000)
The 3.1.3 (i.e. before the DCP churn) didn't ever notify from
streamRequest, so that is reverted and helps to bring
view_query latency down (view engine is constantly creating
streams).

A second tweak is to not call stream->next whilst holding
the streamMutex. This can block streamRequest again
affecting the view-engine's DCP stream requests.

Change-Id: I5b57fd7998003251fb32897f37c8a2f15f687a13
Reviewed-on: http://review.couchbase.org/60352
Reviewed-by: Manu Dhundi <manu@couchbase.com>
Tested-by: buildbot <build@couchbase.com>
Well-Formed: buildbot <build@couchbase.com>
Reviewed-by: Dave Rigby <daver@couchbase.com>
Reviewed-by: Chiyoung Seo <chiyoung@couchbase.com>
src/dcp-producer.cc

index 47a4e84..75d7115 100644 (file)
@@ -268,7 +268,7 @@ ENGINE_ERROR_CODE DcpProducer::streamRequest(uint32_t flags,
         static_cast<ActiveStream*>(streams[vbucket].get())->setActive();
     }
 
-    notifyStreamReady(vbucket, false/*unused for DCP*/);
+    ready.pushUnique(vbucket);
 
     if (add_vb_conn_map) {
         connection_t conn(this);
@@ -627,15 +627,18 @@ DcpResponse* DcpProducer::getNextItem() {
             }
 
             DcpResponse* op = NULL;
+            stream_t stream;
             {
                 ReaderLockHolder rlh(streamsMutex);
                 std::map<uint16_t, stream_t>::iterator it = streams.find(vbucket);
                 if (it == streams.end()) {
                     continue;
                 }
-                op = it->second->next();
+                stream.reset(it->second);
             }
 
+            op = stream->next();
+
             if (!op) {
                 // stream is empty, try another vbucket.
                 continue;