@@ -268,7 +268,8 @@ ActiveStream::ActiveStream(EventuallyPersistentEngine* e,
268268 chkptItemsExtractionInProgress(false ),
269269 includeValue(includeVal),
270270 includeXattributes(includeXattrs),
271- filter(std::move(filter)) {
271+ filter(std::move(filter)),
272+ cursorName(n + std::to_string(cursorUID.fetch_add(1 ))) {
272273 const char * type = " " ;
273274 if (flags_ & DCP_ADD_STREAM_FLAG_TAKEOVER) {
274275 type = " takeover " ;
@@ -364,7 +365,7 @@ void ActiveStream::registerCursor(CheckpointManager& chkptmgr,
364365 uint64_t lastProcessedSeqno) {
365366 try {
366367 CursorRegResult result = chkptmgr.registerCursorBySeqno (
367- name_ , lastProcessedSeqno, MustSendCheckpointEnd::NO);
368+ cursorName , lastProcessedSeqno, MustSendCheckpointEnd::NO);
368369 /*
369370 * MB-22960: Due to cursor dropping we re-register the replication
370371 * cursor only during backfill when we mark the disk snapshot. However
@@ -814,8 +815,9 @@ void ActiveStream::addTakeoverStats(ADD_STAT add_stat, const void *cookie,
814815 add_stat, cookie);
815816
816817 size_t vb_items = vb.getNumItems ();
817- size_t chk_items = vb_items > 0 ?
818- vb.checkpointManager .getNumItemsForCursor (name_) : 0 ;
818+ size_t chk_items =
819+ vb_items > 0 ? vb.checkpointManager .getNumItemsForCursor (cursorName)
820+ : 0 ;
819821
820822 size_t del_items = 0 ;
821823 try {
@@ -866,7 +868,8 @@ DcpResponse* ActiveStream::nextQueuedItem() {
866868
867869bool ActiveStream::nextCheckpointItem () {
868870 VBucketPtr vbucket = engine->getVBucket (vb_);
869- if (vbucket && vbucket->checkpointManager .getNumItemsForCursor (name_) > 0 ) {
871+ if (vbucket &&
872+ vbucket->checkpointManager .getNumItemsForCursor (cursorName) > 0 ) {
870873 // schedule this stream to build the next checkpoint
871874 producer->scheduleCheckpointProcessorTask (this );
872875 return true ;
@@ -957,7 +960,7 @@ void ActiveStream::getOutstandingItems(VBucketPtr &vb,
957960 chkptItemsExtractionInProgress.store (true );
958961
959962 hrtime_t _begin_ = gethrtime ();
960- vb->checkpointManager .getAllItemsForCursor (name_ , items);
963+ vb->checkpointManager .getAllItemsForCursor (cursorName , items);
961964 engine->getEpStats ().dcpCursorsGetItemsHisto .add (
962965 (gethrtime () - _begin_) / 1000 );
963966
@@ -1195,7 +1198,8 @@ void ActiveStream::scheduleBackfill_UNLOCKED(bool reschedule) {
11951198 try {
11961199 std::tie (curChkSeqno, tryBackfill) =
11971200 vbucket->checkpointManager .registerCursorBySeqno (
1198- name_, lastReadSeqno.load (),
1201+ cursorName,
1202+ lastReadSeqno.load (),
11991203 MustSendCheckpointEnd::NO);
12001204 } catch (std::exception& error) {
12011205 producer->getLogger ().log (EXTENSION_LOG_WARNING,
@@ -1273,11 +1277,12 @@ void ActiveStream::scheduleBackfill_UNLOCKED(bool reschedule) {
12731277 */
12741278 try {
12751279 CursorRegResult result =
1276- vbucket->checkpointManager .registerCursorBySeqno (
1277- name_, lastReadSeqno.load (),
1278- MustSendCheckpointEnd::NO);
1280+ vbucket->checkpointManager .registerCursorBySeqno (
1281+ cursorName,
1282+ lastReadSeqno.load (),
1283+ MustSendCheckpointEnd::NO);
12791284
1280- curChkSeqno = result.first ;
1285+ curChkSeqno = result.first ;
12811286 } catch (std::exception& error) {
12821287 producer->getLogger ().log (EXTENSION_LOG_WARNING,
12831288 " (vb %" PRIu16 " ) Failed to register "
@@ -1469,7 +1474,7 @@ void ActiveStream::transitionState(StreamState newState) {
14691474 {
14701475 VBucketPtr vb = engine->getVBucket (vb_);
14711476 if (vb) {
1472- vb->checkpointManager .removeCursor (name_ );
1477+ vb->checkpointManager .removeCursor (cursorName );
14731478 }
14741479 break ;
14751480 }
@@ -1493,8 +1498,8 @@ size_t ActiveStream::getItemsRemaining() {
14931498 // Items remaining is the sum of:
14941499 // (a) Items outstanding in checkpoints
14951500 // (b) Items pending in our readyQ, excluding any meta items.
1496- return vbucket->checkpointManager .getNumItemsForCursor (name_ ) +
1497- readyQ_non_meta_items;
1501+ return vbucket->checkpointManager .getNumItemsForCursor (cursorName ) +
1502+ readyQ_non_meta_items;
14981503}
14991504
15001505uint64_t ActiveStream::getLastReadSeqno () const {
@@ -1534,7 +1539,7 @@ bool ActiveStream::dropCheckpointCursor_UNLOCKED() {
15341539 }
15351540 }
15361541 /* Drop the existing cursor */
1537- return vbucket->checkpointManager .removeCursor (name_ );
1542+ return vbucket->checkpointManager .removeCursor (cursorName );
15381543}
15391544
15401545EXTENSION_LOG_LEVEL ActiveStream::getTransitionStateLogLevel (
@@ -1576,6 +1581,8 @@ bool ActiveStream::queueResponse(DcpResponse* resp) const {
15761581 return true ;
15771582}
15781583
1584+ std::atomic<uint64_t > ActiveStream::cursorUID;
1585+
15791586NotifierStream::NotifierStream (EventuallyPersistentEngine* e,
15801587 dcp_producer_t p,
15811588 const std::string& name,
0 commit comments