13

I am using mongodb's (mongoose module) with node js
and i am processing around 1,00,00,000 documents in (1000 bunch each) using limit and skip functionalities.
my processing fine but after some time it gives me an error.

{ MongoError: Cursor not found, cursor id: 62783806111
    at Function.MongoError.create (/home/admin/Pictures/duplicayProj1/node_modules/mongoose/node_modules/mongodb-core/lib/error.js:31:11)
    at /home/admin/Pictures/duplicayProj1/node_modules/mongoose/node_modules/mongodb-core/lib/connection/pool.js:483:72
    at authenticateStragglers (/home/admin/Pictures/duplicayProj1/node_modules/mongoose/node_modules/mongodb-core/lib/connection/pool.js:429:16)
    at Connection.messageHandler (/home/admin/Pictures/duplicayProj1/node_modules/mongoose/node_modules/mongodb-core/lib/connection/pool.js:463:5)
    at Socket.<anonymous> (/home/admin/Pictures/duplicayProj1/node_modules/mongoose/node_modules/mongodb-core/lib/connection/connection.js:339:20)
    at emitOne (events.js:115:13)
    at Socket.emit (events.js:210:7)
    at addChunk (_stream_readable.js:252:12)
    at readableAddChunk (_stream_readable.js:239:11)
    at Socket.Readable.push (_stream_readable.js:197:10)
    at TCP.onread (net.js:589:20)
  name: 'MongoError',
  message: 'Cursor not found, cursor id: 62783806111',
  ok: 0,
  errmsg: 'Cursor not found, cursor id: 62783806111',
  code: 43 }

can any one tell me what's the actual problem because i am not using any keywords matches with cursor.
Thanks in advance

Mohammad Zeeshan
  • 825
  • 1
  • 9
  • 20

1 Answers1

8

This normally happens because your cursor timeouts if it is idle for too long. Check out noCursorTimeout. Just make sure you close the cursor when you are finished.

hahcho
  • 1,369
  • 9
  • 17
  • I have the same problem with mongo 3.6.2 and mongoose 5.0.10, but only with 20,000 documents. Not a cursor timeout since I'm using it constantly. Just dies. – Jackpile Mar 24 '18 at 18:21
  • @Jackpile die you find a solution? I have the same problem – ThommyH Apr 12 '18 at 16:01
  • @hakcho I cannot find .noCursorTimeout() method available anywhere via Typescript with Node for Mongoose. It's only found with GridFSBucketFindOptions. Oh perhaps http://mongoosejs.com/docs/api.html#querycursor_QueryCursor-addCursorFlag. – Jackpile May 11 '18 at 23:55
  • @Jackpile I linked to mongo documentation. Different drivers or libs will have different ways of setting this. I mentioned it because I had the same issue while processing data in a Python script. What you have linked seams to be the way you set `noCusorTimeout` for cursors in mongoose. – hahcho May 12 '18 at 10:04
  • @hakcho Thanks, yes, my original question was based on Mongoose trouble. I hope this flag fixes this issue, not had a chance to test yet. – Jackpile May 12 '18 at 13:49
  • what is the solution for this issue? – Suraj Dalvi Sep 17 '20 at 07:51
  • @SurajDalvi the solution is noCursorTimeout as I tested it and got proper result – Mohammad Zeeshan Mar 30 '21 at 13:20