4 / 4
Dec 2024

The BulkWrite command throws a ClientBulkWriteException when there is a conflict issue. However, this exception does not include the TransientTransactionError label, which is only present in the InnerException.

As a result, the session.WithTransactionAsync method does not automatically retry the operation, as it should.

Steps to Reproduce:

  1. Execute a BulkWrite operation inside a session.WithTransactionAsync block.
  2. Introduce a transient conflict error (e.g., a write conflict).
  3. Observe that the operation fails without retrying, even though retries are expected in this scenario.

Expected Behavior:
The ClientBulkWriteException should include the TransientTransactionError label to ensure session.WithTransactionAsync retries the operation as intended.

Actual Behavior:
The TransientTransactionError label is present only in the InnerException, and the session.WithTransactionAsync method does not retry the operation.

Environment Details:

  • MongoDB Server version: [Your version here]
  • Driver version: [Your driver version here]
  • OS: [Your OS here]

Additional Notes:
This issue disrupts the expected behavior of transaction retries and can lead to manual intervention for handling retries.

Exception example:

"StackTrace" : [ "at MongoDB.Driver.Core.Operations.ClientBulkWriteOperation.EnsureCanProceedNextBatch(ConnectionId connectionId, BulkWriteRawResult bulkWriteResult)", "at MongoDB.Driver.Core.Operations.ClientBulkWriteOperation.ExecuteAsync(IWriteBinding binding, CancellationToken cancellationToken)", "at MongoDB.Driver.OperationExecutor.ExecuteWriteOperationAsync[TResult](IWriteBinding binding, IWriteOperation`1 operation, CancellationToken cancellationToken)", "at MongoDB.Driver.MongoClient.ExecuteWriteOperationAsync[TResult](IClientSessionHandle session, IWriteOperation`1 operation, CancellationToken cancellationToken)",
"[Prop] ErrorLabels" : [ ],
"ExceptionType" : "ClientBulkWriteException",

"InnerExceptions" : [
				{
					"StackTrace" : [
						"at MongoDB.Driver.Core.WireProtocol.CommandUsingCommandMessageWireProtocol`1.ProcessResponse(ConnectionId connectionId, CommandMessage responseMessage)",
						"at MongoDB.Driver.Core.WireProtocol.CommandUsingCommandMessageWireProtocol`1.SendMessageAndProcessResponseAsync(CommandRequestMessage message, Int32 responseTo, IConnection connection, CancellationToken cancellationToken)",
						"at MongoDB.Driver.Core.WireProtocol.CommandUsingCommandMessageWireProtocol`1.ExecuteAsync(IConnection connection, CancellationToken cancellationToken)",
						"at MongoDB.Driver.Core.Servers.Server.ServerChannel.ExecuteProtocolAsync[TResult](IWireProtocol`1 protocol, ICoreSession session, CancellationToken cancellationToken)",
						"at MongoDB.Driver.Core.Operations.RetryableWriteOperationExecutor.ExecuteAsync[TResult](IRetryableWriteOperation`1 operation, RetryableWriteContext context, CancellationToken cancellationToken)",
                    "ExceptionType" : "MongoCommandException",
                    "[Prop] ErrorLabels" : [ "TransientTransactionError" ]

Hi @Fernando_Mondo!

Thank you for reporting the problem. Could you please specify the Driver’s version being used to reproduce the problem? We faced some retriability-related issue with client BulkWrite and it was fixed in 3.1.0. Please make sure you are using the latest version of the Driver.

Thanks,
Oleksandr