Add function to check if bulkwrite is acknowledged

XMLWordPrintableJSON

    • Type: New Feature
    • Resolution: Done
    • Priority: Minor - P4
    • 2.2.0
    • Affects Version/s: 1.28.0
    • Component/s: Bulk API
    • None
    • Needed
    • 🔵 Done
    • C Drivers
    • Not Needed
    • None
    • None
    • None
    • None
    • None
    • None

      When modeling BulkWriteCommandResult (PHPC-2494), I was relying on mongoc_bulkwritereturn_t.res being non-null to infer whether the write was acknowledged since there is no other indication on mongoc_bulkwritereturn_t.

      However, mongoc_bulkwrite_execute has a condition that destroys mongoc_bulkwritereturn_t.res when (!is_acknowledged || !has_successful_results).

      I'm not sure if this is intentional, but I wanted to make a note of it in case it was not. I think most users would expect there to be a result object (even empty) for any acknowledged write, although I'm also not sure if that is explicitly discussed in the bulk write spec.

      In the meantime, I will revert to explicitly checking a write concern struct (either the explicit option or whatever is inherited by the client).

      How to Reproduce

      I observed this when constructing a test for bypassDocumentValidation that failed with a single insert. I used the following create command to define a basic validation rule requiring an "x" field:

      {
          "create": "coll",
          "validator": {
              "$jsonSchema": {
                  "bsonType": "object",
                  "required": ["x"]
              }
          }
      }
      

      I then constructed a mongoc_bulkwrite_t with bypassDocumentValidation: true and attempted to insert one invalid document without an "x" field.

      The resulting mongoc_bulkwritereturn_t struct has a null res field due to a (!is_acknowledged || !has_successful_results) condition near the bottom of mongoc_bulkwrite_execute.

      Note: I attempted to produce a single file derived from example-bulkwrite.c, but attempting to compile that locally through my libmongoc submodule was a bit too time consuming given how trivial I expect this will be for a libmongoc engineer to repro on their own.

            Assignee:
            Connor MacDonald
            Reporter:
            Jeremy Mikola
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: