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

Cursor option oplogReplay ignored starting from version 4.0

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 4.9.0
    • Affects Version/s: None
    • Component/s: None
    • 0
    • Not Needed

      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-3.7.3.log
          3 kB
        2. currentOp-4.0.1.log
          3 kB

            Assignee:
            durran.jordan@mongodb.com Durran Jordan
            Reporter:
            chinello@gmail.com Diego Sampaio
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: