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

mongoc_bulkwrite_execute may use MONGOC_ERROR_COMMAND_INVALID_ARG error code after server communication

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 1.28.0
    • Component/s: Bulk API
    • None
    • C Drivers

      In the legacy bulk write API, the domain/code combination of MONGOC_ERROR_COMMAND and MONGOC_ERROR_COMMAND_INVALID_ARG were used for early client-side errors before any communication with the server. PHPC relied on this to select an appropriate exception type.

      In the new bulk write API (CDRIVER-4363), there are a few scenarios where this domain/code might be used after server communication, and thus alongside a partial write result (with or without write and/or write concern errors).

      • _bulkwritereturn_apply_result and _bulkwritereturn_apply_reply both use the domain/code. This occurs within the functions, as well as related lookup_string, lookup_as_int64, and lookup_int32 functions.
      • The domain/code is also used later in mongoc_bulkwrite_execute, within the while loop to "Send one or more bulkWrite commands" for the error condition: Could not even fit one document within an OP_MSG.

      The errors when parsing a server response could ideally use a different domain and/or code. As for the maxMessageSizeBytes error, I'm not sure if it'd be possible to handle that sooner (like when maxBsonObjectSize is exceeded with an unacknowledged write concern).

      I'm opening this ticket so we have a record of this, but I won't push for an API change here. In the meantime, I can have PHPC use different logic for selecting an exception and also consider whether a partial write result is available in addition to just examining the top-level error's domain and code.

            Assignee:
            jmikola@mongodb.com Jeremy Mikola
            Reporter:
            jmikola@mongodb.com Jeremy Mikola
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: