[SERVER-70152] PeekableCursor's definition of hasNext() ignores the state of the stashed document Created: 30/Sep/22  Updated: 29/Oct/23  Resolved: 03/Oct/22

Status: Closed
Project: Core Server
Component/s: Testing Infrastructure
Affects Version/s: None
Fix Version/s: 6.2.0-rc0

Type: Bug Priority: Major - P3
Reporter: Max Hirschhorn Assignee: Max Hirschhorn
Resolution: Fixed Votes: 0
Labels: sharding-nyc-subteam1
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-68361 LogTransactionOperationsForShardingHa... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Sharding 2022-10-17
Participants:

 Description   

PeekableCursor#hasNext() does not consider the state of this.stashedDoc. This causes the last document returned by the PeekableCursor to be considered missing by DataConsistencyChecker#getDiff() despite it potentially having the same _id as the cursor from the other cursor.

class PeekableCursor {
    constructor(cursor) {
        this.cursor = cursor;
        this.stashedDoc = undefined;
    }
 
    hasNext() {
        return this.cursor.hasNext();
    }
 
    peekNext() {
        if (this.stashedDoc === undefined) {
            this.stashedDoc = this.cursor.next();
        }
        return this.stashedDoc;
    }
 
    next() {
        const result = (this.stashedDoc === undefined) ? this.cursor.next() : this.stashedDoc;
        this.stashedDoc = undefined;
        return result;
    }
}



 Comments   
Comment by Githook User [ 01/Oct/22 ]

Author:

{'name': 'Max Hirschhorn', 'email': 'max.hirschhorn@mongodb.com', 'username': 'visemet'}

Message: SERVER-70152 Fix PeekableCursor#hasNext() in DataConsistencyChecker.

Changes PeekableCursor#hasNext() to return true when there is a stashed
document still.
Branch: master
https://github.com/mongodb/mongo/commit/424befe581c9aeb29e42f05c0b1439ba2e39af98

Generated at Thu Feb 08 06:15:25 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.