Uploaded image for project: 'C Driver'
  1. C Driver
  2. CDRIVER-2777

mongoc_collection_watch prefers collection readConcern to the one in "opts"

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 1.13.0
    • Affects Version/s: None
    • Component/s: libmongoc
    • None

      Probably since change streams were implemented in 1.9.0 (CDRIVER-2233), they prefer the collection readConcern over the readConcern passed in "opts".

      Details: _mongoc_change_stream_new_from_collection sets stream->read_concern to the collection's read concern, and copies the user-supplied options to stream->opts. Then in _make_cursor, we copy stream->opts to a local variable "command_opts", resulting in something like:

      {"readConcern": {"level": "user supplied level"}, "serverId": 1, "sessionId": 1809617486}
      

      We then append stream->read_concern to command_opts:

      {"readConcern": {"level": "user supplied level"}, "serverId": 1, "sessionId": 1809617486, "readConcern": {"level": "from collection"}}
      

      Now command_opts has two readConcern fields. A few layers deeper we call _mongoc_read_write_opts_parse, which is generated from IDL (CDRIVER-2373). For speed and simplicity, I deliberately implemented last-field-wins for duplicate fields in the IDL parsers instead of adding any logic to detect duplicates. In this case the readConcern from the collection is last, and that is the readConcern used.

            Assignee:
            jesse@mongodb.com A. Jesse Jiryu Davis
            Reporter:
            jesse@mongodb.com A. Jesse Jiryu Davis
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: