[SERVER-35484] Active cursor with Session disappears after a few minutes Created: 07/Jun/18  Updated: 28/Jun/18  Resolved: 08/Jun/18

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: 4.0.0-rc3
Fix Version/s: None

Type: Question Priority: Major - P3
Reporter: Daniel Aprahamian (Inactive) Assignee: Misha Tyulenev
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by NODE-1482 Cursor not found issue Closed
Duplicate
duplicates SERVER-34810 Session cache refresh can erroneously... Closed
Participants:

 Description   

Hi all,

I have been investigating NODE-1482, and I have found that, when using sessions, a cursor will disappear after a few minutes and cause further getMores to error.

Reproduction steps:

1. Set up a ReplicaSet
2. Insert 10000 records into test.test
3. Run the following Node Script Using NodeJS >= 8:

'use strict';
 
const {MongoClient} = require('mongodb');
 
const sleep = ms => new Promise(r => setTimeout(r, ms));
 
(async () => {
  const client = await MongoClient.connect('mongodb://localhost:27017/?replSet=rs', { monitorCommands: true });
  client.on('commandStarted', e => console.log(JSON.stringify(e.command)));
 
  const collection = client.db('test').collection('test');
 
  const count = await collection.count();
 
  console.log(count);
 
  console.log('querying');
  const time = process.hrtime()
  const cursor = collection.find({}).batchSize(1);
  try {
    for (let i = 0; i < 100000; i++) {
      await cursor.next();
      await sleep(1000);
    }
 
  } catch (e) {
    console.error(e);
  }
 
  console.log('shutting down');
  console.log(process.hrtime(time));
  await cursor.close();
  await client.close();
  console.log('done');
  process.exit(0);
})();

I'm finding that after about 2 minutes, the getMore will error with cursor X not found. As far as I can tell, we are not sending a killCursor or an endSession command.

Since users are reporting that this only started happening once we started adding lsid to our find and getMore commands, I suspect this has something to do with sessions.

Is this a bug, or expected behavior?

Thanks,
Dan



 Comments   
Comment by Misha Tyulenev [ 08/Jun/18 ]

kelsey.schubert thats correct

Comment by Kelsey Schubert [ 07/Jun/18 ]

dup of SERVER-34810?

Generated at Thu Feb 08 04:39:57 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.