Skip to content

Commit e2f7454

Browse files
DOCSP-25487 update transaction docs (#5448) (#5507)
* General version and term cleanup * More deprecated version info cleanup, clarified collection creation is implicit if none exists * Fixed line break * Cleaned up Transactions and Operations topic * Lingering mention of collection reqs * Indentation fixes * Fixed indentation * Internal PR feedback * Externalized common content to includes * Internal review feedback * Typo fix
1 parent 5a21f3d commit e2f7454

File tree

5 files changed

+105
-201
lines changed

5 files changed

+105
-201
lines changed

source/core/transactions-operations.txt

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,6 @@ For transactions:
1818

1919
.. include:: /includes/extracts/transactions-operations-crud.rst
2020

21-
Operations that affect the database catalog, such as creating or
22-
dropping a collection or an index, are not allowed in multi-document
23-
transactions. For example, a multi-document transaction cannot include
24-
an insert operation that would result in the creation of a new
25-
collection. See :ref:`transactions-operations-ref-restricted`.
26-
2721
Operations Supported in Multi-Document Transactions
2822
---------------------------------------------------
2923

@@ -38,11 +32,11 @@ The following read/write operations are allowed in transactions:
3832

3933
.. note:: Updates to Shard Key Values
4034

41-
Starting in MongoDB 4.2, you can update a document's shard key value
42-
(unless the shard key field is the immutable ``_id`` field) by
43-
issuing single-document update/findAndModify
44-
operations either in a transaction or as a :doc:`retryable write
45-
</core/retryable-writes>`. For details, see :ref:`update-shard-key`.
35+
You can update a document's shard key value (unless the shard key
36+
field is the immutable ``_id`` field) by issuing single-document
37+
update / findAndModify operations either in a transaction or as a
38+
:doc:`retryable write </core/retryable-writes>`. For details, see
39+
:ref:`update-shard-key`.
4640

4741
.. _transactions-operations-count:
4842

@@ -63,10 +57,7 @@ Distinct Operation
6357
Administration Operations
6458
~~~~~~~~~~~~~~~~~~~~~~~~~
6559

66-
Starting in MongoDB 4.4 with :ref:`feature compatibility version (fcv)
67-
<view-fcv>` ``"4.4"``, you can create collections and indexes inside a
68-
:doc:`multi-document transaction </core/transactions>` if the
69-
transaction is :red:`not` a cross-shard write transaction.
60+
.. include:: /includes/transactions/create-collections-indexes-in-transaction.rst
7061

7162
.. _transactions-operations-ddl-explicit:
7263

source/core/transactions.txt

Lines changed: 24 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -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

2121
In MongoDB, an operation on a single document is atomic. Because you can
2222
use embedded documents and arrays to capture relationships between data
2323
in a single document structure instead of normalizing across multiple
2424
documents 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

2727
For situations that require atomicity of reads and writes to multiple
2828
documents (in a single or multiple collections), MongoDB supports
29-
multi-document transactions. With distributed transactions,
29+
distributed transactions. With distributed transactions,
3030
transactions can be used across multiple operations, collections,
3131
databases, documents, and shards.
3232

@@ -334,32 +334,10 @@ This example highlights the key components of the transactions API.
334334
Transactions and Atomicity
335335
--------------------------
336336

337-
.. note:: Distributed Transactions and Multi-Document Transactions
337+
.. include:: /includes/transactions/distributed-transaction-repl-shard-support.rst
338338

339-
Starting in MongoDB 4.2, the two terms are synonymous. Distributed
340-
transactions refer to multi-document transactions on sharded
341-
clusters and replica sets. Multi-document transactions (whether on
342-
sharded clusters or replica sets) are also known as distributed
343-
transactions starting in MongoDB 4.2.
344-
345-
For situations that require atomicity of reads and writes to multiple
346-
documents (in a single or multiple collections), MongoDB supports
347-
multi-document transactions:
348-
349-
- **In version 4.0**, MongoDB supports multi-document transactions on
350-
replica sets.
351-
352-
- **In version 4.2**, MongoDB introduces distributed transactions,
353-
which adds support for multi-document transactions on sharded
354-
clusters and incorporates the existing support for
355-
multi-document transactions on replica sets.
356-
357-
To use transactions on MongoDB 4.2 deployments (replica sets and
358-
sharded clusters), clients :red:`must` use MongoDB drivers updated for
359-
MongoDB 4.2.
360-
361-
Multi-document transactions are atomic (i.e. provide an
362-
"all-or-nothing" proposition):
339+
Distributed transactions are atomic. They provide an "all-or-nothing"
340+
proposition:
363341

364342
- When a transaction commits, all data changes made in the transaction
365343
are saved and visible outside the transaction. That is, a transaction
@@ -385,7 +363,7 @@ Transactions and Operations
385363
---------------------------
386364

387365
Distributed transactions can be used across multiple operations,
388-
collections, databases, documents, and, starting in MongoDB 4.2, shards.
366+
collections, databases, documents, and shards.
389367

390368
For transactions:
391369

@@ -405,19 +383,15 @@ For a list of operations not supported in transactions, see
405383
Create Collections and Indexes In a Transaction
406384
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
407385

408-
Starting in MongoDB 4.4, you can perform the following operations inside
409-
of a :doc:`multi-document transaction </core/transactions>` as long as
410-
the transaction is not a cross-shard write transaction:
386+
You can perform the following operations inside of a :ref:`distributed
387+
transaction <transactions>` as long as the transaction is not a
388+
cross-shard write transaction:
411389

412390
- Create collections.
413391

414392
- Create indexes on new empty collections created earlier in the same
415393
transaction.
416394

417-
In MongoDB 4.2 and earlier, operations that affect the database catalog,
418-
such as creating or dropping a collection or an index, are
419-
:red:`disallowed` in transactions.
420-
421395
When creating a collection inside a transaction:
422396

423397
- You can :ref:`implicitly create a collection
@@ -514,8 +488,7 @@ Restricted Operations
514488
Transactions and Sessions
515489
-------------------------
516490

517-
- Transactions are associated with a session; i.e. you start a
518-
transaction for a session.
491+
- Transactions are associated with a session
519492

520493
- At any given time, you can have at most one open transaction for a
521494
session.
@@ -593,20 +566,17 @@ Transactions support the following read concern levels:
593566
``"majority"``
594567
``````````````
595568

596-
- Read concern :readconcern:`"majority"` returns data that has been
597-
acknowledged by a majority of the replica set members (i.e. data
598-
cannot be rolled back) **if** the transaction commits with
599-
:ref:`write concern "majority" <transactions-write-concern>`.
600-
601-
- If the transaction does not use :ref:`write concern "majority"
602-
<transactions-write-concern>` for the commit, the
603-
:readconcern:`"majority"` read concern provides **no** guarantees that
604-
read operations read majority-committed data.
569+
- If the transaction commits with :ref:`write concern "majority"
570+
<transactions-write-concern>`, read concern :readconcern:`"majority"`
571+
returns data that has been acknowledged by a majority of the replica
572+
set members and can't be rolled back. Otherwise, read concern
573+
:readconcern:`"majority"` provides no guarantees that read operations
574+
read majority-committed data.
605575

606-
- For transactions on sharded cluster, :readconcern:`"majority"` read
607-
concern cannot guarantee that the data is from the same snapshot
608-
view across the shards. If snapshot isolation is required, use
609-
:ref:`transactions-read-concern-snapshot` read concern.
576+
- For transactions on sharded cluster, read concern
577+
:readconcern:`"majority"` can't guarantee that the data is from the
578+
same snapshot view across the shards. If snapshot isolation is
579+
required, use read concern :ref:`transactions-read-concern-snapshot`.
610580

611581
.. _transactions-read-concern-snapshot:
612582

@@ -660,7 +630,7 @@ You can set the transaction-level :doc:`write concern
660630
<replica-set-arbiter-configuration>`. See
661631
:ref:`wc-default-behavior`.
662632

663-
- :writeconcern:`w: 1 <\<number\>>` in MongoDB 4.4 and earlier.
633+
- :writeconcern:`w: 1 <\<number\>>`
664634

665635
.. seealso::
666636

@@ -696,7 +666,7 @@ values, including:
696666

697667
- Write concern :writeconcern:`w: "majority" <"majority">` returns
698668
acknowledgement after the commit has been applied to a majority
699-
(M) of voting members; i.e. the commit has been applied to the
669+
(M) of voting members, meaning the commit has been applied to the
700670
primary and (M-1) voting secondaries.
701671

702672
- When you commit with :writeconcern:`w: "majority" <"majority">`
@@ -793,7 +763,7 @@ MongoDB provides various transactions metrics:
793763

794764
* - :binary:`~bin.mongod` and :binary:`~bin.mongos` log messages
795765

796-
- Includes information on slow transactions (i.e. transactions
766+
- Includes information on slow transactions, which are transactions
797767
that exceed the :setting:`operationProfiling.slowOpThresholdMs`
798768
threshold) under the :data:`TXN` log component.
799769

0 commit comments

Comments
 (0)