Official Mafiree Blogs

Keeping you informed about Databases

Significance of using Invisible Primary key (GIPK) with MySQL 8.0
By Sukan   |   February 21, 2023   |   Posted in : MySQL
How Generated Invisible Primary Keys (GIPK) Can Boost Your Database Efficiency

Achieving High Availability Using Log Shipping
By Sujith   |   February 21, 2018   |   Posted in : SQL Server
Here we will get the detailed explanation of how we can achieve HA using Log Shipping.

SQL Server On Linux
By Sujith   |   March 30, 2019   |   Posted in : SQL Server
SQL Server 2017 brings the best features of the Microsoft relational database engine to the enterprise Linux ecosystem, including SQL Server Agent, Azure Active Directory (Azure AD) authentication, best-in-class high availability/ disaster recovery, and unparalleled data security.

Types of SQL Server Replication
By Sujith   |   February 19, 2018   |   Posted in : SQL Server
Understanding on the types of replication in SQL Server and the type apt for your traffic pattern.

Data File Splitting in SQL Server
By Murali   |   March 15, 2021   |   Posted in : SQL Server
Huge data blocks resides under single MDF file might cause a performance of the query and impact the application services. This blog help you to understand how we can the split the single MDF file into multiple data files.

 Home  /  Mongodb  
Insight on MongoDB Transactions
By AKumar   |   July 10, 2019   |   Posted in : Mongodb

Before version 4.0, MongoDB uses $isolated operator to update multiple documents but it does not provide “all-or-nothing” atomicity for write operations.

MongoDB resolved this issue in version 4.0 and provides the support of Multi-Document transactions. 
Prior to starting a transaction, a session must be created. A transaction cannot be run outside a session.

At any given time you may have multiple running sessions in the system, but each session may run only a single transaction at a time. You can run transactions in parallel according to how many open sessions you have.

The following mongo shell methods are available for Transactions to Start & Commit or Abort :

How it works?

Below example clearly explains how transactions work in MongoDB. Here we will be implementing transactions by creating two different sessions.

Session 1 :

In this session 1, I am starting a transaction and inserting a document without commiting the transaction.

Session 2 :

Lets find the inserted document.

Before Commiting the transaction: No result set, as Session 1 did not commit the transaction.

Session 1:

Now again in the session 1, lets commit the transaction.

Session 2 :

Now, when we find the document, we could see the same data that we have inserted already in session1.

Note : By default, trananaction uses Read Commited isolation and we can't change the isolation level. 

Limitations of Transactions :
  1. A collection cannot be dropped or created inside a transaction.

  2. It is not possible to read and write into a system.* collection.

  3. An index cannot be created or dropped inside a transaction.

  4. We can’t use transactions on a standalone server, we need to configure it as a replica set.

  5. By default, a transaction that executes for longer than 60 seconds will automatically expire.

  6. A transaction cannot read or write in config, admin, and local databases.

  7. Size of a transaction is limited to 16MB.

Note: From upcoming MongoDB version(4.2), transaction will get supported in shared cluster as well.


Leave a Comment

Name *

Email *

Comment *

Search All Blogs

Need Support?

Solutions      Services      Resources      About Mafiree

More than 3000 servers monitored

Certified database Administrators

24X7X365 Support

Happy Clients

For Sales Related Queries, Please Call Our Sales Experts at


Meet Mafiree on social networks!


PCI Certificate

Copyright © 2019 - All Rights Reserved - Mafiree