[CDRIVER-2506] getMore doesn't always use same implicit session as find/aggregate/etc. Created: 13/Feb/18  Updated: 28/Oct/23  Resolved: 15/Feb/18

Status: Closed
Project: C Driver
Component/s: libmongoc
Affects Version/s: 1.9.0
Fix Version/s: 1.9.3

Type: Bug Priority: Major - P3
Reporter: A. Jesse Jiryu Davis Assignee: A. Jesse Jiryu Davis
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Problem/Incident
is caused by CDRIVER-2449 Session ID is included in authenticat... Closed
Related
related to PHPC-1152 Aggregate may fail to use the same se... Closed

 Description   

The sessions spec says:

When an operation using a session returns a cursor, all subsequent GETMORE commands for that cursor MUST be run using the same session ID.

mongoc_cursor_t does this when an explicit session is passed in "opts", but when it uses an implicit session this behavior isn't guaranteed.

Our tests passed by accident, because the session pool is LIFO, and in the single-threaded case it usually only has one lsid anyway:

cursor = mongoc_collection_find_with_opts (...);
mongoc_cursor_next (...); /* acquire and release implicit session */
mongoc_cursor_next (...); /* acquire and release SAME implicit session */

However, if another session were pushed into the pool between the initial "find" and the first "getMore", or between any pair of subsequence getMores, then its new lsid would be used for the next "getMore" instead. If auth is enabled, this will result in a server error code 13, "Cursor session id is not the same as the operation context's session id".



 Comments   
Comment by Githook User [ 02/Mar/18 ]

Author:

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

Message: CDRIVER-2506 a cursor always uses the same lsid
Branch: debian
https://github.com/mongodb/mongo-c-driver/commit/afc62d1383c7efbf35ac5d237957e578ea546b33

Comment by Githook User [ 02/Mar/18 ]

Author:

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

Message: CDRIVER-2506 a cursor always uses the same lsid
Branch: r1.9-dfsg
https://github.com/mongodb/mongo-c-driver/commit/afc62d1383c7efbf35ac5d237957e578ea546b33

Comment by Githook User [ 15/Feb/18 ]

Author:

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

Message: CDRIVER-2506 a cursor always uses the same lsid
Branch: r1.9
https://github.com/mongodb/mongo-c-driver/commit/afc62d1383c7efbf35ac5d237957e578ea546b33

Comment by Githook User [ 15/Feb/18 ]

Author:

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

Message: CDRIVER-2506 a cursor always uses the same lsid

  1. Conflicts:
  2. src/mongoc/mongoc-cmd.c
    Branch: r1.9
    https://github.com/mongodb/mongo-c-driver/commit/2283e83972724e33b4ff605f1de6405240c8be28
Comment by Githook User [ 15/Feb/18 ]

Author:

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

Message: CDRIVER-2506 a cursor always uses the same lsid
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/45f3c49f81f15459a74de82e543bd4b61f574d5a

Comment by A. Jesse Jiryu Davis [ 13/Feb/18 ]

Yes I think it will.

Comment by Jeremy Mikola [ 13/Feb/18 ]

jesse: Will this be backported to 1.9.x? It seems like something we'd want to address in PHPC 1.4.1, since most users will be using implicit sessions on MongoDB 3.6.

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