-
Type: New Feature
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: libmongoc
-
None
ReadConcern SHOULD be specifiable at the Client, Database, and Collection levels. Unless specified, the value MUST be inherited from its parent and SHOULD NOT be modifiable on an existing Client, Database, and Collection. In addition, a driver MAY allow it to be specified on a per-operation basis in accordance with the CRUD specification.
mongoc will support setting readConcern on:
- mongoc_collection_t
- mongoc_database_t
- mongoc_client_t
mongoc will not support setting readConcern on per-operation basis, and will therefore not be adding extended versions of helpers that could otherwise take readConcern.
The following helpers (that support readConcern in MongoDB 3.2+) are currently implemented in mongoc:
- mongoc_collection_count
- mongoc_collection_find
- mongoc_collection_aggregate
When using these helpers, readConcern must be set on the collection level, e.g.:
mongoc_collection_set_read_concern (collection, read_concern); mongoc_collection_find (collection, MONGOC_QUERY_NONE, 0, 0, 0, NULL, NULL, read_prefs);
Other currently known commands that support readConcern, but don't have helpers in mongoc are:
- mapReduce when the result is inline
- distinct
- parallelCollectionScan
- geoNear
- geoSearch
The following are new (public API) functions handling read_concern:
#define MONGOC_READ_CONCERN_LEVEL_LOCAL "local" #define MONGOC_READ_CONCERN_LEVEL_MAJORITY "majority" typedef struct _mongoc_read_concern_t mongoc_read_concern_t;
mongoc_read_concern_t *mongoc_read_concern_new (void); mongoc_read_concern_t *mongoc_read_concern_copy (const mongoc_read_concern_t *read_concern); void mongoc_read_concern_destroy (mongoc_read_concern_t *read_concern); const char *mongoc_read_concern_get_level (const mongoc_read_concern_t *read_concern); bool mongoc_read_concern_set_level (mongoc_read_concern_t *read_concern, const char *level);
const mongoc_read_concern_t *mongoc_client_get_read_concern (const mongoc_client_t *client); void mongoc_client_set_read_concern (mongoc_client_t *client, const mongoc_read_concern_t *read_concern);
const mongoc_read_concern_t *mongoc_database_get_read_concern (const mongoc_database_t *database); void mongoc_database_set_read_concern (mongoc_database_t *database, const mongoc_read_concern_t *read_concern);
const mongoc_read_concern_t *mongoc_collection_get_read_concern (const mongoc_collection_t *collection); void mongoc_collection_set_read_concern (mongoc_collection_t *collection, const mongoc_read_concern_t *read_concern);
const mongoc_read_concern_t *mongoc_uri_get_read_concern (const mongoc_uri_t *uri);
Note: To use this feature in MongoDB 3.2 you must start mongod with --enableMajorityReadConcern
Note that the comments on this ticket assumed that we would have to support readConcern as an option to the find helper, and therefore requiring a new extended version of that helper.
This is however not correct and was based on misunderstanding of the specification.
- depends on
-
CDRIVER-838 Support find, getMore and killCursor commands
- Closed
-
CDRIVER-1006 Document readConcernLevel MongoDB URI option
- Closed
-
CDRIVER-1007 Document new read_concern functions
- Closed
- is depended on by
-
CXX-695 Support "read committed" isolation level where "committed" means confimed by the voting majority of a replica set
- Closed
-
DRIVERS-254 Add support for the readConcern option.
- Closed
- related to
-
CDRIVER-1031 ReadConcern should be inherited from a parent when not set
- Closed
-
CDRIVER-1010 Document helpers that use readConcern
- Closed