chapter eight

8 Executing Multi-Document ACID Transactions

 

This chapter covers

  • Understanding the WiredTiger Storage Engine
  • Refreshing the ACID principles
  • Comparing the Core API and Callback API
  • Implementing transactions with the Node.js driver
  • Performing transactions using the Python driver
  • Managing transactions with the Ruby driver

Transactions are discrete units of operation within a database management system, comprising multiple related read and write actions. These operations are grouped together and must either all succeed as a whole or fail together, ensuring that no partial updates are left in the database. For example, consider a transaction for booking a travel package that includes a flight and a hotel. If the booking process successfully reserves a flight but encounters an issue with the hotel reservation, the entire transaction must be aborted. This means the flight reservation would also be undone, maintaining the status quo in the database.

While MongoDB is a non-relational database and traditionally does not follow the relational model's approach to transactions, it has long ensured data integrity through its single-document operations. However, with the introduction of multi-document ACID transactions, MongoDB has significantly broadened its applicability and enhanced its capability to handle complex transaction scenarios.

8.1 Wired Tiger Storage Engine

8.1.1 WiredTiger Snapshots and Checkpoints

8.1.2 WiredTiger Journaling

8.1.3 WiredTiger Compression

8.1.4 WiredTiger Memory Utilization

8.2 Single Document Transaction

8.2.1 WiredTiger document-level transactions

8.3 Defining ACID

8.4 Multi Documents Transactions

8.4.1 Differentiating Core API and Callback API

8.4.2 Using transactions with mongosh

8.4.3 Using transactions with callback API

8.5 MongoDB Transactions Considerations

8.6 Summary