[CDRIVER-3612] mongoc_collection_estimated_document_count should not accept an explicit session Created: 10/Apr/20  Updated: 28/Oct/23  Resolved: 29/Jun/20

Status: Closed
Project: C Driver
Component/s: None
Affects Version/s: None
Fix Version/s: 1.17.0-rc0, 1.17.0

Type: Bug Priority: Major - P3
Reporter: Kaitlin Mahar Assignee: Roberto Sanchez
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

According to the sessions spec, estimatedDocumentCount should not support an explicit session parameter: https://github.com/mongodb/specifications/blob/master/source/sessions/driver-sessions.rst#new-collection-methods-that-take-an-explicit-session

However, I am able to pass one in by appending it to the options bson_t and I've confirmed via command monitoring that the id for the session I specified is being used.

The docs section on sessions also makes it seem like you can use this method in a transaction: http://mongoc.org/libmongoc/current/mongoc_collection_estimated_document_count.html



 Comments   
Comment by Githook User [ 11/Jul/20 ]

Author:

{'name': 'Roberto C. Sánchez', 'email': 'roberto@connexer.com', 'username': 'rcsanchez97'}

Message: CDRIVER-3612 do not accept explicit session for collection count
Branch: r1.17
https://github.com/mongodb/mongo-c-driver/commit/402189f4b5bd76d51e58aaf195e40cf0aa7cb2b2

Comment by Githook User [ 29/Jun/20 ]

Author:

{'name': 'Roberto C. Sánchez', 'email': 'roberto@connexer.com', 'username': 'rcsanchez97'}

Message: CDRIVER-3612 do not accept explicit session for collection count
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/fa7a96ef92d698622b9641e7c3c6a0ca67fb85c7

Comment by Githook User [ 26/Jun/20 ]

Author:

{'name': 'Roberto C. Sánchez', 'email': 'roberto@connexer.com', 'username': 'rcsanchez97'}

Message: CDRIVER-3612 do not accept explicit session for collection count
Branch: cdriver-3612
https://github.com/mongodb/mongo-c-driver/commit/721e667e07ddf664d9bec65554409f789b6539fe

Comment by Kevin Albertson [ 26/Jun/20 ]

Given some new information, I now think we should not be changing the behavior of the deprecated helper mongoc_collection_count_with_opts.

There are spec tests that expect the deprecated count helper to accept an explicit session:

The spec only says that the estimated document count helper should not support an explicit session, and does not say that the deprecated count helpers should be changed in a behavioral backwards breaking way. If we supported an explicit session before, we should probably continue to support an explicit session.

Other drivers accept a session argument for their deprecated count helpers. See pymongo and the Java 3.12 driver deprecated helpers.

Given all that, I think we should be leaving the deprecated count helper untouched and relying on the server to error.

Comment by Kevin Albertson [ 11/Jun/20 ]

We should explicitly raise a client side error if we detect an explicit session passed. The deprecated mongoc_collection_count_with_opts appears to accept a session as well, and documents it. It should also reject an explicit session.

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