Why are transactions not supported for Standalone?

I found an older post here: Getting error MongoDB Transactions with C# and the .NET Framework and yet I wonder why this is a thing? Transactions are meant to ensure multiple operations on different collections (and more) are atomic and can be reverted if any fails.

We do need them though for a few scenarios where embedding doesn’t work for us. But I can’t test it because our local Docker hosted instance is standalone (why bother with a cluster for local). The driver doesn’t allow it though because “System.NotSupportedException: Standalone servers do not support transactions.”

Why that? And how am I now supposed to test this? If clusters behave different than local deployments this is horrific for development. My code fails locally while it might work on production. No guarantee and non-deterministic.

If the driver doesn’t support it, why not just ignore it? Can’t you just kind of simulate that behavior so the logic works the same but the server decides how to handle things?

Btw: Your AI helper in the docs even tells me that Standalone supports transactions. So is it a fault of the driver or is your AI spreading misinformation?

Thanks for the help!

Hey @Manuel_Eisenschink,

The underlying question you’re asking is answered here: Why replica set is mandatory for transactions in MongoDB? - #2 by Pavel_Duchovny.

You can test this locally by using a single-member replica set, which is effectively the same thing as a standalone (a single mongod process) but behaves like a replica set (with an oplog and support for features such as transactions and changestreams).

1 Like