-
Type:
Bug
-
Resolution: Won't Do
-
Priority:
Major - P3
-
None
-
Affects Version/s: 2.6.8, 3.0.1
-
Component/s: Querying
-
Query
-
ALL
-
None
-
3
-
None
-
None
-
None
-
None
-
None
-
None
For regular (non-tailable) cursors, a negative ntoreturn value instructs the server to generate at most one batch of results. After generating the first batch, the server is expected to close the cursor and pass a cursorid of 0 back to the client.
The server ignores that the ntoreturn value is negative for tailable cursors, and is willing to send multiple batches of results (i.e. at least one getMore) back to the client. You can reproduce this behavior with the script below:
// Increase logLevel so that the logs indicate when a getMore occurs. db.adminCommand({setParameter: 1, logLevel: 1}); t = db.t; t.drop(); db.createCollection("t", {capped: true, size: 2048}); t.insert({a: 1}); var cursor = t.find().addOption(DBQuery.Option.tailable).limit(-3); cursor.next(); t.insert({a: 1}); cursor.next(); // This triggers a getMore, but it should not.