I am writing an ETL tool where I would need to create 2 collection and perform a bulk insert operation. After the insert I would like to create some indexes. I am using Mongo C# Driver 2.11.2 .
I followed this blog to understand the transactions in Mongo: https://www.mongodb.com/how-to/transactions-c-dotnet
It seems I cannot do bulk inserts on different collections with the same session. I keep getting the error :
Command commitTransaction failed: WriteConflict error: this operation conflicted with another operation. Please retry your operation or multi-document transaction…’
Then I separated out the bulk operations to individual methods and used the session to commit the transaction. The behavior is very inconsistent. Sometimes the collection is created with the records and sometimes exception about WriteConcern is thrown.
Can someone help me with this issue?