I’m testing this parameter and I really want to know how cursorTimeoutMillis parameter works.
I expected that if I set this parameter to 10 seconds,
the cursor would time out in 10 seconds when it is in idle state, but nothing happened. The following is my scenario.
before testing, I prepared my test data like this
for (var i = 1; i <= 101; i++) {
db.testCollection.insert( { x : i } )
}
var documentSize = 16 * 1024 * 1024-32; // 16MB
var largeData = new Array(documentSize).join('y');
db.testCollection.insert({ data: largeData });
after creating data, I made my cursor .
> db.adminCommand({"getParameter":1,"cursorTimeoutMillis":1})
{ "cursorTimeoutMillis" : NumberLong(10000), "ok" : 1 }
var myCursor = db.testCollection.find();
var count = 0;
while (myCursor.hasNext()) {
var document = myCursor.next();
count++;
if (count > 101) {
sleep(60000); ------> At this point, I expected this cursor should be expired.
printjson(count)
var a = document;
}
else {
printjson(count,document)
}
}
however, this cursor never expired. it ends normally without a cursor timeout.
I don’t understand. What’s the problem?