-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: 2.0.2
-
Component/s: None
-
Labels:
-
Environment:node --version: v0.10.32
MongoDB node driver version: 2.0.3
MongoDB version: 2.6.4 (OS X)
-
Empty show more show less
Full repro:
Standalone mongod on localhost:
// mongodb 2.6.4, config file storage: dbPath: "/data/db/264" systemLog: destination: file path: "/data/db/264/mongodb.log" processManagement: fork: true
Create data:
// bulk insert a bunch of data into twitter.tweets use twitter; var bulk = db.tweets.initializeUnorderedBulkOp(); start = new Date(); for(var i = 0; i < 500000; i++){bulk.insert({"_id" : i, id : new ObjectId()})}; bulk.execute({w:1}); end = new Date(); print(end - start);
Simple app to iterate a cursor with foreach:
// Test app.js - using mongo native 2.0.x driver var MongoClient = require('mongodb').MongoClient; var mongoUrl = 'mongodb://localhost/twitter'; MongoClient.connect(mongoUrl, function(err, db) { if (err) return console.error(err); var collection = db.collection('tweets'); // 200k limit needed to trigger with single field projection, lesser limits are OK collection.find({}, {"_id" : 0, id : 1}).limit(200000).forEach(function(tweet) { // note: setting batch size low, like so triggers the dead cursor messages early // collection.find({}, {"_id" : 0, id : 1}).batchSize(8000).limit(200000).forEach(function(tweet) { // otherwise it errors when it hits the 4MiB limit (see log lines from mongod later) console.log(tweet.id); }, function(err) { if (err) console.error(err); db.close(); }); });
Relevant errors from the app:
// log lines from the app (always fails at same point): 5446942542aa4250a78f4c35 5446942542aa4250a78f4c36 5446942542aa4250a78f4c37 { [MongoError: cursor is dead] name: 'MongoError', message: 'cursor is dead' } { [MongoError: cursor is dead] name: 'MongoError', message: 'cursor is dead' } { [MongoError: cursor is dead] name: 'MongoError', message: 'cursor is dead' } { [MongoError: cursor is dead] name: 'MongoError', message: 'cursor is dead' } { [MongoError: cursor is dead] name: 'MongoError', message: 'cursor is dead' } { [MongoError: cursor is dead] name: 'MongoError', message: 'cursor is dead' } { [MongoError: cursor is dead] name: 'MongoError', message: 'cursor is dead' }
MongoDB Log Lines:
// log lines from mongod - note reslen
2014-10-21T18:50:32.548+0100 [conn50] query twitter.tweets planSummary: COLLSCAN cursorid:30362014860 ntoreturn:200000 ntoskip:0 nscanned:199728 nscannedObjects:199728 keyUpdates:0 numYields:0 locks(micros) r:120400 nreturned:199728 reslen:4194308 120ms
2014-10-21T18:55:01.597+0100 [conn56] query twitter.tweets planSummary: COLLSCAN cursorid:31266586339 ntoreturn:200000 ntoskip:0 nscanned:199728 nscannedObjects:199728 keyUpdates:0 numYields:0 locks(micros) r:109383 nreturned:199728 reslen:4194308 109ms
Note: tried with each rather than forEach - same result.