Uploaded image for project: 'Drivers'
  1. Drivers
  2. DRIVERS-955

How should drivers report write concern error returned as part of a command error

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • None

      Typically, write concern errors are only be returned as part of the response to write commands, and in those cases the response will always be ok: 1.

      There are some other cases in which a write concern error can be returned outside of such a context, such as aggregate with $merge (see SERVER-44827). In those cases, a write concern error can be included in both ok: 0 (i.e. command error) and ok: 1 responses. It is unclear how statically typed drivers (which have separate structures for WriteException and CommandException) are expected to handle this.

      A few options are possible:

      • When encountering ok: 1 + WC error, throw a WriteException. When encountering ok: 0 + WC error, discard the WC error and throw a CommandException.
      • Amend CommandException to have an option WC error field. Still throw WriteError in the ok: 1 case.

      I'm not sure if either of these options are desirable though. Another more drastic solution would be to separate $out and $merge into their own helpers and advise users against using the stages directly in their own pipelines, similar to how we handle the $changeStream stage. This would allow us to define more specific errors for these cases, but it may be too late in the game to start doing that (for $out at least).

            Assignee:
            Unassigned Unassigned
            Reporter:
            patrick.freed@mongodb.com Patrick Freed
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: