Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-4775

Internal MongoWriteConcernWithResponseException is exposed to user code

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.9.0
    • Affects Version/s: 4.4.0
    • Component/s: Bulk API, Error Handling
    • Labels:
      None
    • Fully Compatible
    • Not Needed

      This exception is just an implementation detail, and was never supposed to be thrown from public API methods. However, as far as I can tell, I exposed this exception as a result of JAVA-4034. Specifically, it is exposed because of the changes in MixedBulkWriteOperation.

      jeff.yemin@mongodb.com noticed the problem when he was reviewing JAVA-4701, so the test added there can be used to debug the problem. I spent some time debugging in both the current driver version 4.8.0-SNAPSHOT, and in 4.3.4, where there is no problem. I did discover differences, but don't have a complete picture of how to solve fix the problem, i.e., I would need to spend more time. Here are the differences and issues I noticed:

      1. When running the test in 4.3.4, the test fails when executing this line, because the writeConcernError document configured in the fail point does not have the errmsg key, which is expected by WriteConcernHelper.createWriteConcernError. The important part here is that 4.3.4 does not expose MongoWriteConcernWithResponseException, and instead creates WriteConcernError from it and adds it as a result to BulkWriteBatch.
      2. 4.8.0-SNAPSHOT (and 4.4.0) appears to not always do this as the logic was moved to this place, which is executed on each retry except for the last attempt. This last part is unintentional and is different from the code in 4.3.4, where the logic in question gets to be executed on the last attempt.
      3. Another difference I noticed, which is irrelevant to this particular bug, but may represent a different one, is this code in 4.8.0-SNAPSHOT. It does not have a counterpart in 4.3.4, addRetryableWriteErrorLabel is called in 4.3.4 only here, which we also do in 4.8.0-SNAPSHOT here. This difference may be caused by the code in 4.8.0-SNAPSHOT being agnostic of the maximum number of retries (it does only 2 per each "next batch", but this limit is not hardcoded anywhere in the logic, as opposed to how it was in 4.3.4), but I fail to see how. At this moment I don't understand this code (not that I understand the rest of the code).
      4. Another interesting difference is that exceptions from executeCommand are ignored in 4.3.4 on a retry of a batch, while not being ignored in 4.8.0-SNAPSHOT.

            Assignee:
            valentin.kovalenko@mongodb.com Valentin Kavalenka
            Reporter:
            valentin.kovalenko@mongodb.com Valentin Kavalenka
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: