Unexpected: tailable cursors are renewed automatically when maxDoc is reached (if maxDoc >= 0)

18 views
Skip to first unread message

Jean-Baptiste Giraudeau

unread,
Sep 1, 2017, 11:25:46 AM9/1/17
to ReactiveMongo - http://reactivemongo.org

Hi,

Tailable cursors are renewed automatically when maxDoc is reached (if maxDocs >= 0),
cf: https://github.com/ReactiveMongo/ReactiveMongo/blob/17044edf1e728deacc7865c0604fbcfbfe865e99/driver/src/main/scala/api/cursor.scala#L555

It looks like a quite old behavior (implemented in https://github.com/ReactiveMongo/ReactiveMongo/commit/c94d731dd35ed4a2c0bf37b032d76ba34f806554)
that probably got unnoticed because of default values for "maxDocs" being negative or very high (Int.MaxValue).

This is a very surprising behavior: this means the cursor will cycle on the first ''maxDocs" documents of the collections, indefinitely.

I would prefer that:
 - tailable cursors end like normal cursors when maxDocs is reached or continue indefinitely (on same cursor) when maxDocs < 0
 - default value for maxDocs in ReactiveMongo-Streaming should be -1, instead of Int.MaxValue. 

It it ok to open a PR to implement the above?

-
jb

Cédric Chantepie

unread,
Sep 1, 2017, 1:42:16 PM9/1/17
to ReactiveMongo - http://reactivemongo.org
I feel there several topics mixed there.


On Friday, 1 September 2017 17:25:46 UTC+2, Jean-Baptiste Giraudeau wrote:

Hi,

Tailable cursors are renewed automatically when maxDoc is reached (if maxDocs >= 0),
cf: https://github.com/ReactiveMongo/ReactiveMongo/blob/17044edf1e728deacc7865c0604fbcfbfe865e99/driver/src/main/scala/api/cursor.scala#L555

It looks like a quite old behavior (implemented in https://github.com/ReactiveMongo/ReactiveMongo/commit/c94d731dd35ed4a2c0bf37b032d76ba34f806554)
that probably got unnoticed because of default values for "maxDocs" being negative or very high (Int.MaxValue).

This is a very surprising behavior: this means the cursor will cycle on the first ''maxDocs" documents of the collections, indefinitely.
I would prefer that:
 - tailable cursors end like normal cursors when maxDocs is reached or continue indefinitely (on same cursor) when maxDocs < 0

Any change there first requires an isolated test case, with a capped collection, to demonstrate the behaviour (which is covered by the unit tests).
 
 - default value for maxDocs in ReactiveMongo-Streaming should be -1, instead of Int.MaxValue. 

That's another concern (on a separate repository).

The driver is already using -1 as default value, "normalized" as MaxValue, so Streaming can also use -1 as default value.
This point is actionable as PR, as unit tests using default values are already includes.

Reply all
Reply to author
Forward
Message has been deleted
0 new messages