@@ -15,18 +15,18 @@ Transactions
1515 :class: twocols
1616
1717.. meta::
18- :description: For situations that require atomicity of reads and writes to multiple documents (in a single or multiple collections), MongoDB supports multi-document transactions.
18+ :description: For situations that require atomicity of reads and writes to multiple documents (in a single or multiple collections), MongoDB supports multi-document transactions, also called distributed transactions .
1919 :keywords: MongoDB, transactions, distributed transactions, MongoDB multi-document transactions, MongoDB multi-statement transactions, java transaction examples, python transaction examples, node transaction examples, php transaction examples, scala transaction examples, csharp transaction examples, perl transaction examples, ruby transaction examples
2020
2121In MongoDB, an operation on a single document is atomic. Because you can
2222use embedded documents and arrays to capture relationships between data
2323in a single document structure instead of normalizing across multiple
2424documents and collections, this single-document atomicity obviates the
25- need for multi-document transactions for many practical use cases.
25+ need for distributed transactions for many practical use cases.
2626
2727For situations that require atomicity of reads and writes to multiple
2828documents (in a single or multiple collections), MongoDB supports
29- multi-document transactions. With distributed transactions,
29+ distributed transactions. With distributed transactions,
3030transactions can be used across multiple operations, collections,
3131databases, documents, and shards.
3232
@@ -333,32 +333,10 @@ This example highlights the key components of the transactions API.
333333Transactions and Atomicity
334334--------------------------
335335
336- .. note :: Distributed Transactions and Multi-Document Transactions
336+ .. include :: /includes/transactions/distributed-transaction-repl-shard-support.rst
337337
338- Starting in MongoDB 4.2, the two terms are synonymous. Distributed
339- transactions refer to multi-document transactions on sharded
340- clusters and replica sets. Multi-document transactions (whether on
341- sharded clusters or replica sets) are also known as distributed
342- transactions starting in MongoDB 4.2.
343-
344- For situations that require atomicity of reads and writes to multiple
345- documents (in a single or multiple collections), MongoDB supports
346- multi-document transactions:
347-
348- - **In version 4.0**, MongoDB supports multi-document transactions on
349- replica sets.
350-
351- - **In version 4.2**, MongoDB introduces distributed transactions,
352- which adds support for multi-document transactions on sharded
353- clusters and incorporates the existing support for
354- multi-document transactions on replica sets.
355-
356- To use transactions on MongoDB 4.2 deployments (replica sets and
357- sharded clusters), clients :red:`must` use MongoDB drivers updated for
358- MongoDB 4.2.
359-
360- Multi-document transactions are atomic (i.e. provide an
361- "all-or-nothing" proposition):
338+ Distributed transactions are atomic. They provide an "all-or-nothing"
339+ proposition:
362340
363341- When a transaction commits, all data changes made in the transaction
364342 are saved and visible outside the transaction. That is, a transaction
@@ -384,7 +362,7 @@ Transactions and Operations
384362---------------------------
385363
386364Distributed transactions can be used across multiple operations,
387- collections, databases, documents, and, starting in MongoDB 4.2, shards.
365+ collections, databases, documents, and shards.
388366
389367For transactions:
390368
@@ -404,12 +382,14 @@ For a list of operations not supported in transactions, see
404382Create Collections and Indexes In a Transaction
405383~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
406384
407- Starting in MongoDB 4.4 with :ref:`feature compatibility version (fcv)
408- <view-fcv>` ``"4.4"``, you can create collections and indexes inside a
409- :doc:`multi-document transaction </core/transactions>` unless the
410- transaction is a cross-shard write transaction. With ``"4.2"`` or less,
411- operations that affect the database catalog, such as creating or
412- dropping a collection or an index, are :red:`disallowed` in transactions.
385+ You can perform the following operations inside of a :ref:`distributed
386+ transaction <transactions>` as long as the transaction is not a
387+ cross-shard write transaction:
388+
389+ - Create collections.
390+
391+ - Create indexes on new empty collections created earlier in the same
392+ transaction.
413393
414394When creating a collection inside a transaction:
415395
@@ -512,8 +492,7 @@ Restricted Operations
512492Transactions and Sessions
513493-------------------------
514494
515- - Transactions are associated with a session; i.e. you start a
516- transaction for a session.
495+ - Transactions are associated with a session
517496
518497- At any given time, you can have at most one open transaction for a
519498 session.
@@ -591,20 +570,17 @@ Transactions support the following read concern levels:
591570``"majority"``
592571``````````````
593572
594- - Read concern :readconcern:`"majority"` returns data that has been
595- acknowledged by a majority of the replica set members (i.e. data
596- cannot be rolled back) **if** the transaction commits with
597- :ref:`write concern "majority" <transactions-write-concern>`.
598-
599- - If the transaction does not use :ref:`write concern "majority"
600- <transactions-write-concern>` for the commit, the
601- :readconcern:`"majority"` read concern provides **no** guarantees that
602- read operations read majority-committed data.
573+ - If the transaction commits with :ref:`write concern "majority"
574+ <transactions-write-concern>`, read concern :readconcern:`"majority"`
575+ returns data that has been acknowledged by a majority of the replica
576+ set members and can't be rolled back. Otherwise, read concern
577+ :readconcern:`"majority"` provides no guarantees that read operations
578+ read majority-committed data.
603579
604- - For transactions on sharded cluster, :readconcern:`"majority"` read
605- concern cannot guarantee that the data is from the same snapshot
606- view across the shards. If snapshot isolation is required, use
607- :ref:`transactions-read-concern-snapshot` read concern .
580+ - For transactions on sharded cluster, read concern
581+ :readconcern:`"majority"` can't guarantee that the data is from the
582+ same snapshot view across the shards. If snapshot isolation is
583+ required, use read concern :ref:`transactions-read-concern-snapshot`.
608584
609585.. _transactions-read-concern-snapshot:
610586
@@ -686,7 +662,7 @@ values, including:
686662
687663- Write concern :writeconcern:`w: "majority" <"majority">` returns
688664 acknowledgement after the commit has been applied to a majority
689- (M) of voting members; i.e. the commit has been applied to the
665+ (M) of voting members, meaning the commit has been applied to the
690666 primary and (M-1) voting secondaries.
691667
692668- When you commit with :writeconcern:`w: "majority" <"majority">`
@@ -809,7 +785,7 @@ MongoDB provides various transactions metrics:
809785
810786 * - :binary:`~bin.mongod` and :binary:`~bin.mongos` log messages
811787
812- - Includes information on slow transactions (i.e. transactions
788+ - Includes information on slow transactions, which are transactions
813789 that exceed the :setting:`operationProfiling.slowOpThresholdMs`
814790 threshold) under the :data:`TXN` log component.
815791
0 commit comments