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

Introduce bulk write options to disable BSON validation

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 1.6.0
    • Fix Version/s: 1.7.0
    • Component/s: libmongoc
    • Labels:
      None
    • Sprint:
      C Driver 2017 3 - March 7

      Description

      When CDRIVER-1341 added logic to validate insert, replacement, and update documents (4b37e65), it subtly changed some conventions with bulk write execution. I was alerted to this through the PHP driver's manager-executeBulkWrite_error-005.phpt test. Validation errors are not reported until the bulk write is executed (here), which changes a previous assumption that execution would always ensure the server stream was initialized. The existing checks in mongoc_bulk_operation_execute() for valid client/database/collection objects could theoretically have returned within initializing a stream, but it wasn't a concern for us.

      As it relates to the PHP driver, this means that we'd only be able to throw a BulkWriteException at execution time (from Manager::executeBulkWrite()) instead of an InvalidArgumentException from the offending method (e.g. BulkWrite::insert()). We actually discovered this because BulkWriteException attempts to refer to the server handling execution, and the selected server was null.

      This may only be an issue for mongoc_bulk_operation_insert(), which may be at a disadvantage because it is void and cannot return a boolean indicating success or failure (unlike the update and replace "with_opts" functions). For this reason, I think we either need a new insert function that can return a boolean or some public API that can expose the mongoc_bulk_operation_t's error so that we can check it after each attempted insert. The update and replace functions have "with_opts" variants, which return a boolean indicating success or failure, as well as a bson_error_t * output argument to store any error encountered. A similar API for insert would be appreciated.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              backlog-c-driver Backlog - C Driver Team
              Reporter:
              jmikola Jeremy Mikola
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: