mongodb - Aggregate pipleline Error: getMore: cursor didn't exist on server, possible restart or timeout -


i facing issue mongodb. code this

for(loop) {     var cursorquery = db.beacon_0000.aggregate([         {             $match: {                 ...             }         },         {             $project: {                 ...             }         },         {             $group: {                 ...             }         },         {             $sort: {                 ...             }             }     ], {allowdiskuse: true} );      ...     while(cursorquery.hasnext()) {         var cursor = cursorquery.next();         ...     } } 

i run above query via command , mongo shell as

$ mongo dbname file.js 

after while cursor didn't exist on server error @ line cursorquery.hasnext().

in find query if error, can resolve adding addoption(dbquery.option.notimeout) option not seem available aggregate

please let me know how can resolve or workaround issue.

just provide additional update: when use

var cursor = db.collection..aggregate([ ...], {allowdiskuse: true} ).addoption(dbquery.option.notimeout) 

i error e query typeerror: object # has no method 'addoption'

however when use

var cursor = db.collection..find({...}, {...}).addoption(dbquery.option.notimeout) 

it works fine.

checking aggregate doc https://docs.mongodb.com/v3.0/reference/method/db.collection.aggregate/ says: returns:a cursor documents produced final stage of aggregation pipeline operation

and checking cursor doc https://docs.mongodb.com/v3.0/reference/method/cursor.addoption/#cursor.addoption

there no suggestion aggregate cursor different find cursor , former not support dbquery.option.notimeout.

so there bug @ mongodb this. way fix or have workaround.

note mongodb version 3.0

you have sort of answered yourself.


adding option addoption(dbquery.option.notimeout) indeed fix issue when using find because stops cursor timing out , therefore exist when try .hasnext()

however cursor aggregation not have option can't stop timing out unfortunately.


Comments