@@ -182,8 +182,8 @@ ActiveStream::ActiveStream(EventuallyPersistentEngine* e, dcp_producer_t p,
182182 engine(e), producer(p),
183183 payloadType((flags & DCP_ADD_STREAM_FLAG_NO_VALUE) ? KEY_ONLY :
184184 KEY_VALUE),
185- lastSentSnapEndSeqno(0 ), chkptItemsExtractionInProgress(false ) {
186-
185+ lastSentSnapEndSeqno(0 ), chkptItemsExtractionInProgress(false ),
186+ cursorName(n + std::to_string(cursorUID.fetch_add( 1 ))) {
187187 const char * type = " " ;
188188 if (flags_ & DCP_ADD_STREAM_FLAG_TAKEOVER) {
189189 type = " takeover " ;
@@ -338,7 +338,7 @@ void ActiveStream::markDiskSnapshot(uint64_t startSeqno, uint64_t endSeqno) {
338338 try {
339339 CursorRegResult result =
340340 vb->checkpointManager .registerCursorBySeqno (
341- name_ , chkCursorSeqno,
341+ cursorName , chkCursorSeqno,
342342 MustSendCheckpointEnd::NO);
343343
344344 curChkSeqno = result.first ;
@@ -696,7 +696,7 @@ void ActiveStream::addTakeoverStats(ADD_STAT add_stat, const void *cookie) {
696696 item_eviction_policy_t iep = engine->getEpStore ()->getItemEvictionPolicy ();
697697 size_t vb_items = vb->getNumItems (iep);
698698 size_t chk_items = vb_items > 0 ?
699- vb->checkpointManager .getNumItemsForCursor (name_ ) : 0 ;
699+ vb->checkpointManager .getNumItemsForCursor (cursorName ) : 0 ;
700700
701701 size_t del_items = 0 ;
702702 try {
@@ -747,7 +747,7 @@ DcpResponse* ActiveStream::nextQueuedItem() {
747747
748748bool ActiveStream::nextCheckpointItem () {
749749 RCPtr<VBucket> vbucket = engine->getVBucket (vb_);
750- if (vbucket && vbucket->checkpointManager .getNumItemsForCursor (name_ ) > 0 ) {
750+ if (vbucket && vbucket->checkpointManager .getNumItemsForCursor (cursorName ) > 0 ) {
751751 // schedule this stream to build the next checkpoint
752752 producer->scheduleCheckpointProcessorTask (this );
753753 return true ;
@@ -837,7 +837,7 @@ void ActiveStream::getOutstandingItems(RCPtr<VBucket> &vb,
837837 // Commencing item processing - set guard flag.
838838 chkptItemsExtractionInProgress.store (true );
839839
840- vb->checkpointManager .getAllItemsForCursor (name_ , items);
840+ vb->checkpointManager .getAllItemsForCursor (cursorName , items);
841841 if (vb->checkpointManager .getNumCheckpoints () > 1 ) {
842842 engine->getEpStore ()->wakeUpCheckpointRemover ();
843843 }
@@ -1047,7 +1047,8 @@ void ActiveStream::scheduleBackfill_UNLOCKED(bool reschedule) {
10471047 try {
10481048 std::tie (curChkSeqno, tryBackfill) =
10491049 vbucket->checkpointManager .registerCursorBySeqno (
1050- name_, lastReadSeqno.load (),
1050+ cursorName,
1051+ lastReadSeqno.load (),
10511052 MustSendCheckpointEnd::NO);
10521053 } catch (std::exception& error) {
10531054 producer->getLogger ().log (EXTENSION_LOG_WARNING,
@@ -1125,11 +1126,12 @@ void ActiveStream::scheduleBackfill_UNLOCKED(bool reschedule) {
11251126 */
11261127 try {
11271128 CursorRegResult result =
1128- vbucket->checkpointManager .registerCursorBySeqno (
1129- name_, lastReadSeqno.load (),
1130- MustSendCheckpointEnd::NO);
1129+ vbucket->checkpointManager .registerCursorBySeqno (
1130+ cursorName,
1131+ lastReadSeqno.load (),
1132+ MustSendCheckpointEnd::NO);
11311133
1132- curChkSeqno = result.first ;
1134+ curChkSeqno = result.first ;
11331135 } catch (std::exception& error) {
11341136 producer->getLogger ().log (EXTENSION_LOG_WARNING,
11351137 " (vb %" PRIu16 " ) Failed to register "
@@ -1307,7 +1309,7 @@ void ActiveStream::transitionState(stream_state_t newState) {
13071309 {
13081310 RCPtr<VBucket> vb = engine->getVBucket (vb_);
13091311 if (vb) {
1310- vb->checkpointManager .removeCursor (name_ );
1312+ vb->checkpointManager .removeCursor (cursorName );
13111313 }
13121314 break ;
13131315 }
@@ -1330,8 +1332,8 @@ size_t ActiveStream::getItemsRemaining() {
13301332 // Items remaining is the sum of:
13311333 // (a) Items outstanding in checkpoints
13321334 // (b) Items pending in our readyQ, excluding any meta items.
1333- return vbucket->checkpointManager .getNumItemsForCursor (name_ ) +
1334- readyQ_non_meta_items;
1335+ return vbucket->checkpointManager .getNumItemsForCursor (cursorName ) +
1336+ readyQ_non_meta_items;
13351337}
13361338
13371339uint64_t ActiveStream::getLastReadSeqno () const {
@@ -1377,9 +1379,11 @@ void ActiveStream::dropCheckpointCursor_UNLOCKED()
13771379 }
13781380 }
13791381 /* Drop the existing cursor */
1380- vbucket->checkpointManager .removeCursor (name_ );
1382+ vbucket->checkpointManager .removeCursor (cursorName );
13811383}
13821384
1385+ std::atomic<uint64_t > ActiveStream::cursorUID;
1386+
13831387NotifierStream::NotifierStream (EventuallyPersistentEngine* e, dcp_producer_t p,
13841388 const std::string &name, uint32_t flags,
13851389 uint32_t opaque, uint16_t vb, uint64_t st_seqno,
0 commit comments