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:
- First attempt fails with ok: 1 and a retryable write concern error, i.e., the master inserts the documents locally.
- The driver generates the insertion IDs anew and successfully retries.
- 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.
- links to