Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-4468

Investigate NODE-4467 - Cursor option oplogReplay ignored starting from version 4.0

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
    • 2
    • Not Needed

      NODE-4467 Description

      What problem are you facing?

      When trying to use a tailable cursor, it seems the flag `oplogReplay` is being ignore, based on `currentOp` command.

      What driver and relevant dependency versions are you using?

      No additional dependencies.

      Steps to reproduce?

      This is a complete example code. The same code can be used in different driver versions. When running this code using driver version 3.7.3 it works as expected, but starting from version 4.0 I can't see the oplogReplay option being applied which causes the query to take way longer.

      const { MongoClient } = require('mongodb');
      
      (async function () {
      	const client = new MongoClient('mongodb://localhost:27017', {
      		maxPoolSize: 1,
      	});
      
      	await client.connect();
      
      	const db = client.db('local');
      
      	const _baseOplogSelector = {
      		ns: new RegExp('^(?:rocketchat.)'),
      		$or: [
      			{ op: { $in: ['i', 'u', 'd'] } },
      		],
      	};
      
      	const lastEntry = await db.collection('oplog.rs').findOne(_baseOplogSelector,
      		{projection: {ts: 1}, sort: {$natural: -1}});
      
      	const cursor = db.collection('oplog.rs').find({
      		..._baseOplogSelector,
      		ts: { '$gt' : lastEntry.ts }
      	}, {
      		tailable: true,
      		awaitData: true,
      	});
      
      	cursor.addCursorFlag('oplogReplay', true);
      
      	console.log('get doc');
      
      	const doc = await cursor.next();
      
      	console.log('doc ->', doc);
      
      	client.close();
      })();
      
      

       

      I've attached two different results of db.currentOp(), when using driver version 3.7.3 and 4.0.1

        1. currentOp-4.0.1.log
          3 kB
        2. currentOp-3.7.3.log
          3 kB

            Assignee:
            durran.jordan@mongodb.com Durran Jordan
            Reporter:
            dbeng-pm-bot PM Bot
            Durran Jordan
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: