Default commit behavior Mongo 4.X

What is the default commit behavior in MongoDB 4.X?

  1. On a Replica Set (with or without explicit transaction initiated by Client)
  2. On a Standalone (As I understand, Txn support is not enabled for Non Replica Set)


Not sure what is meant by default commit.

When transactions are not used any write is “auto commited”.

Transactions can only be used on replica set even if it has just one member because it requires an oplog as part of its mechanics. This is present only in a replica setup.


Thanks @Pavel_Duchovny. So how does the transaction works for replica set?
if an explicit transaction is not initiated by client (say java), does MongoDB create a transaction for a Write Op and commit it immediately after the Write concern is fulfilled?


Does it behave just like any other write operation on a non-replica set setup and is “auto-commited” as you mentioned before?

Kindly let us know.

Hi @Pavel_Duchovny and the much respected community at large, kind clarification will help.

MongoDB uses some extent of transactions mechanics for different features like retryable writes and casual consistency when you do not execute an explicit transaction.

But for a user you should consider that any write outside of the transaction is autocommited by default. So each atomic write is either fully stored or discarded.

Best regards,

Thanks @Pavel_Duchovny

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.