[CDRIVER-66] Tailable cursors not supported correctly Created: 22/Apr/11  Updated: 19/Oct/16  Resolved: 11/Jul/11

Status: Closed
Project: C Driver
Component/s: None
Affects Version/s: 0.3
Fix Version/s: 0.4

Type: Bug Priority: Major - P3
Reporter: Steve Green Assignee: Kyle Banker
Resolution: Done Votes: 0
Labels: query
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Windows Server 2008 R2, Mongo v1.6.5 64 bit


Attachments: Text File mongo.c     Text File mongo.c     Text File mongo.h    

 Description   

When the data currently in the cursor is exhausted, the mongo_cursor_next routine will call the 'private' mongo_cursor_get_more routine to see if there is any additional data. If not, mongo_cursor_next returns 0. At this point, the cursor never has a chance to get any more data (without a requery) because this code in mongo_cursor_next prevents another call to mongo_cursor_get_more.

/* no data */
if (!cursor->mm || cursor->mm->fields.num == 0)
return 0;

I found that if I make the mongo_cursor_get_more routine 'public', i.e., put it in mongo.h, and then add this code

if ( mongo_cursor_get_more( m_pCursor ) )
bson_init( &m_pCursor->current, &m_pCursor->mm->objs, 0 );

prior to calling mongo_query_next, I get the desired results. This seems like a pretty vulgar hack to me...

If there was a way to tell that a cursor was 'tailable' from the cursor structure, the above logic could be worked into the mongo_cursor_next routine.



 Comments   
Comment by auto [ 11/Jul/11 ]

Author:

{u'login': u'banker', u'name': u'Kyle Banker', u'email': u'kylebanker@gmail.com'}

Message: CDRIVER-66 fixed tailable cursors
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/ae504577885199417692f6a2082fd9c83a3f214f

Comment by auto [ 11/Jul/11 ]

Author:

{u'login': u'banker', u'name': u'Kyle Banker', u'email': u'kylebanker@gmail.com'}

Message: CDRIVER-66 more tests and fixes for tailable.
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/cb25f6e0c657bdc1c0dcbef2f209158e9225e7a5

Comment by auto [ 08/Jul/11 ]

Author:

{u'login': u'banker', u'name': u'Kyle Banker', u'email': u'kylebanker@gmail.com'}

Message: CDRIVER-66 initial fixes for tailable cursors
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/ee088910b8f1e0f2bcead48dca6c39b02914b902

Comment by Kyle Banker [ 27/Apr/11 ]

Thanks for the patches. Will apply soon.

Kyle

Comment by Steve Green [ 27/Apr/11 ]

There was a bug in the previous version of mongo.c in the mongo_cursor_next routine. This version of the file fixes that bug.

Comment by Steve Green [ 25/Apr/11 ]

I've made a patch to address this issue, although I'm not sure that it is the most desirable way to solve the problem. In short, I've added an options field to the mongo_cursor struct that stores the options that were passed to mongo_find. These flags are then used when determining the proper action in the mongo_cursor_next routine. I've attached new versions of mongo.h and mongo.c

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