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

MixedBulkWriteOperation should generate inserted document IDs at most once per batch

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 5.1.4, 4.11.4, 5.2.0
    • Affects Version/s: None
    • Component/s: Bulk API
    • None
    • Fully Compatible
    • Java Drivers
    • Needed
    • Hide

      Let's mention in what's new that we fixed the following bug: InsertOneResult.getInsertedId() and InsertManyResult.getInsertedIds() could return incorrect IDs in some situations (I don't think we need to specify them) when the operation was retried.

      See the "Fix Version/s" field in https://jira.mongodb.org/browse/JAVA-5572 for the versions where we added the fix.

      Show
      Let's mention in what's new that we fixed the following bug: InsertOneResult.getInsertedId() and InsertManyResult.getInsertedIds() could return incorrect IDs in some situations (I don't think we need to specify them) when the operation was retried. See the "Fix Version/s" field in https://jira.mongodb.org/browse/JAVA-5572 for the versions where we added the fix.

      Currently, MixedBulkWriteOperation generates IDs when inserting InsertOneModel.getDocument s anew for each attempt when retrying a batch. At the very least, this is problematic because the command we send differs from attempt to attempt, and this can be observed by either an application or a user.

      If the following situation is possible, then we also seem to be able to return wrong inserted IDs to an application:

      1. First attempt fails with ok: 1 and a retryable write concern error, i.e., the master inserts the documents locally.
      2. The driver generates the insertion IDs anew and successfully retries.
      3. The server inserted IDs that the driver generated for the first attempt, but the driver returns the IDs from the second attempt to an application.

            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: