Details

    • Type: Sub-task
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.4.0
    • Component/s: libmongoc
    • Labels:
      None
    • Sprint:
      C Driver 2016 sprint 5, C Driver 2016 sprint 6, C Driver 2016 sprint 7

      Description

      I'm accepting Pull Request 358, which adds mongoc_collection_aggregate_with_write_concern, but I noticed a problem. The algorithm there is:

      • Select a server
      • If its wire version is 5+ and the user passed a write concern, append it to the command document
      • Create a cursor with the command document

      Then, as always, when the user runs mongoc_cursor_next, its algorithm is:

      • Select a server
      • Send the command document to the server

      But the two selections may select different members of the replica set or different mongos servers in a sharded cluster, and these servers may have different wire versions!

      Instead, let's add a mongoc_write_concern_t to mongoc_cursor_t, similar to the read prefs and read concern it has already. Whenever a cursor is created, if and only if it's created by one of the command helpers whose names end in _with_write_concern, set the cursor's write concern. Don't append it to the command document yet.

      Then, when the user calls mongoc_cursor_next it calls _mongoc_cursor_cursorid_refresh_from_command which calls _mongoc_cursor_run_command. In there we get a server stream and know its wire version for certain. If it's 5+ and cursor->write_concern is not NULL or the default, append the write concern to the command before the call to mongoc_cluster_run_command_monitored.

        Attachments

          Activity

            People

            Assignee:
            fiona.rowan Fiona Rowan
            Reporter:
            jesse A. Jesse Jiryu Davis
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: