MB-19673: Log the actual last seqno sent before closing the stream. 57/64157/5
authorManu Dhundi <manu@couchbase.com>
Mon, 16 May 2016 23:33:09 +0000 (16:33 -0700)
committerDave Rigby <daver@couchbase.com>
Thu, 19 May 2016 07:56:15 +0000 (07:56 +0000)
(Note: backport of MB-19627 to 3.0.x)

When a DCP stream closes, we log the last sent seqno at the time when
stream transitions to dead state. However, we further stream items in
the readyQ from  dead state as well. This commit adds the correct
last seqno sent.

Change-Id: I0f0bfd199544dc5bf20e0ca97b3c5ea8d207c6a8
Reviewed-on: http://review.couchbase.org/64157
Well-Formed: buildbot <build@couchbase.com>
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Manu Dhundi <manu@couchbase.com>
src/dcp-stream.cc

index 58873fd..7f9b5e5 100644 (file)
@@ -547,7 +547,19 @@ DcpResponse* ActiveStream::takeoverWaitPhase() {
 }
 
 DcpResponse* ActiveStream::deadPhase() {
-    return nextQueuedItem();
+    DcpResponse* resp = nextQueuedItem();
+    if (!resp) {
+        LOG(EXTENSION_LOG_WARNING,
+            "(vb %" PRIu16 ") Stream closed, "
+            "%" PRIu64 " items sent from backfill phase, "
+            "%" PRIu64 " items sent from memory phase, "
+            "%" PRIu64 " was last seqno sent",
+            vb_,
+            uint64_t(itemsFromBackfill),
+            uint64_t(itemsFromMemory),
+            lastSentSeqno.load());
+    }
+    return resp;
 }
 
 void ActiveStream::addStats(ADD_STAT add_stat, const void *c) {
@@ -831,10 +843,12 @@ void ActiveStream::endStream(end_stream_status_t reason) {
             pushToReadyQ(new StreamEndResponse(opaque_, reason, vb_));
         }
         transitionState(STREAM_DEAD);
-        LOG(EXTENSION_LOG_WARNING, "%s (vb %d) Stream closing, %llu items sent"
-            " from disk, %llu items sent from memory, %llu was last seqno sent"
-            " %s is the reason", producer->logHeader(), vb_, itemsFromBackfill,
-            itemsFromMemory.load(), lastSentSeqno.load(),
+        LOG(EXTENSION_LOG_WARNING,
+            "(vb %" PRIu16 ") Stream closing, "
+            "sent until seqno %" PRIu64 " "
+            "reason: %s",
+            vb_,
+            lastSentSeqno.load(),
             getEndStreamStatusStr(reason));
     }
 }