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

Some options not applied for OP_MSG without sessions

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 1.17.0-beta2, 1.17.0
    • Affects Version/s: None
    • Component/s: libmongoc
    • None

      mongoc_cmd_parts_assemble assembles options and the base command document into a final command to send.

      parts->body is the base command, like

      {insert: "coll"}

      parts->assembled_body is the base command with options set, like:

      {insert: "coll", "readConcern": { "level": "majority" }}
      

      parts->assembled.command is the final assembled command to send. This either points to parts->body if no options are required to be appended to the base command, or is set to parts->assembled_body otherwise. (I think perhaps this is a micro optimization, to avoid copying the command if we don't need to.)

      So, at the start of the mongoc_cmd_parts_assemble there is:

      parts->assembled.command = parts->body;
      

      And whenever an option is set, you're supposed to call
      _mongoc_cmd_parts_ensure_copied, which switches it over:

      parts->assembled.command = &parts->assembled_body;
      

      My guess is that this is a micro-optimization, to avoid copying parts->body if no options were set and nothing changed. However, we don't always call _mongoc_cmd_parts_ensure_copied every time options are set, meaning we might omit sending them. I don't think it's currently possible for this to surface because this only applies when:

      • no $lsid (session ID) is appended
      • we're using OP_MSG (so, post 3.6)
      • user manually specifies $db in the command document (which is probably pretty rare)

      Because of CDRIVER-3070, we always (incorrectly) assume a 3.6+ server supports sessions and append the $lsid. When that's fixed, we'll need to fix this.

            Assignee:
            roberto.sanchez@mongodb.com Roberto Sanchez
            Reporter:
            kevin.albertson@mongodb.com Kevin Albertson
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: