We are integrating Mongo DB as the database in our .NET based system. Since data consistency is required in our system, we need to support transactions. Mongo DB v4.0 supports transactions, but in order to integrate it with the .NET System.Transaction mechanism, it seems we need to implement a resource manager for Mongo with either a single phase (IPromotableSinglePhaseNotification) or a 2-phase (IEnlistNotification) commit.
- The Mongo C# driver exposes a StartTransaction(), Commit() & Rollback() API which looks like a single phase commit API, so it looks like our resource manager should implement the single phase interface. On the other hand we need to support distribute transactions, so this suits the 2-phase-commit mechanism, but what should be the implementation of the first phase (Prepare) in this case?
- In case there are multiple Mongo transaction participants (e.g. distributed transaction), what happens if one of the participants fails on the Mongo driver's Commit() API? What should I do with all the previous already committed participants?