[CDRIVER-1530] Tailable cursor only works with MONGOC_QUERY_AWAIT_DATA Created: 08/Sep/16  Updated: 21/Sep/16  Resolved: 12/Sep/16

Status: Closed
Project: C Driver
Component/s: None
Affects Version/s: 1.4.0
Fix Version/s: 1.4.1, 1.5.0

Type: Bug Priority: Major - P3
Reporter: Andrew Ryder (Inactive) Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Text File mongoc-tail.c    
Issue Links:
Duplicate
Related
related to PHPC-586 Create regression tests for tailable ... Closed
Case:

 Description   

Tailable cursors without the MONGOC_QUERY_AWAIT_DATA flag seem to close out when connected to a MongoDB 3.2. This behavior is not observed when connected to 3.0 or earlier MongoDB. It is not clear if earlier versions of the driver are affected also.

Attempting to read a tailable cursor repeatedly without the above flag generates the error "Cannot advance a completed or failed cursor."

The documentation for tailable cursors shows the first example without this flag so it seems like it's an acceptable thing to do:
https://github.com/mongodb/specifications/blob/master/source/find_getmore_killcursors_commands.rst#tailable-cursors

Looking through the code for the C Driver though it appears that merely having no payload in getMore results will cause the cursor to be marked as "done". Reading from such a marked cursor triggers an error on the next getMore attempt (the same error as mentioned above). This seems to be the wrong behavior, but I'm not sure.

See attached code, which is a slight modification of the Github example for using tailable cursors in the C driver.



 Comments   
Comment by Githook User [ 12/Sep/16 ]

Author:

{u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@mongodb.com'}

Message: CDRIVER-1530 mention ticket number in test code
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/08e5cf4acaa694e682a7c9979657532435d722c3

Comment by Githook User [ 12/Sep/16 ]

Author:

{u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@mongodb.com'}

Message: CDRIVER-1530 mention ticket number in test code
Branch: r1.4
https://github.com/mongodb/mongo-c-driver/commit/053367df0bf0d856bde2dd7ea84655da5b8ca0b7

Comment by Githook User [ 12/Sep/16 ]

Author:

{u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@mongodb.com'}

Message: CDRIVER-1530 test tailable mongoc_cursor_more
Branch: r1.4
https://github.com/mongodb/mongo-c-driver/commit/beeb029ff31e176ff0e2617d19a06640cb6573b4

Comment by Githook User [ 12/Sep/16 ]

Author:

{u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@mongodb.com'}

Message: CDRIVER-1530 fix cursor_next and tailable find cmd
Branch: r1.4
https://github.com/mongodb/mongo-c-driver/commit/d117efb44de073099b03c35c94990dbbb9a97dbc

Comment by Githook User [ 12/Sep/16 ]

Author:

{u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@mongodb.com'}

Message: CDRIVER-1530 test tailable mongoc_cursor_more
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/7d0b38206efb4c46bf344a265a2f1bf70c703473

Comment by Githook User [ 12/Sep/16 ]

Author:

{u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@mongodb.com'}

Message: CDRIVER-1530 fix cursor_next and tailable find cmd
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/14b72bfe0f299d783d59ea0bb6cca15bebe84b2d

Generated at Wed Feb 07 21:12:49 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.