@@ -71,7 +71,8 @@ upper-right to set the language of the following example.
71
71
/*
72
72
For a replica set, include the replica set name and a seedlist of the members in the URI string; e.g.
73
73
String uri = "mongodb://mongodb0.example.com:27017,mongodb1.example.com:27017/admin?replicaSet=myRepl";
74
- For a sharded cluster, connect to the mongos instances; e.g.
74
+ For a sharded cluster, connect to the mongos instances.
75
+ For example:
75
76
String uri = "mongodb://mongos0.example.com:27017,mongos1.example.com:27017:27017/admin";
76
77
*/
77
78
@@ -268,7 +269,6 @@ upper-right to set the language of the following example.
268
269
.. literalinclude:: /driver-examples/DocumentationTransactionsExampleSpec.scala
269
270
:language: scala
270
271
271
-
272
272
.. seealso::
273
273
274
274
For an example in :binary:`~bin.mongosh`, see
@@ -281,12 +281,12 @@ Transactions and Atomicity
281
281
282
282
.. include:: /includes/transactions/distributed-transaction-repl-shard-support.rst
283
283
284
- Distributed transactions are atomic. They provide an "all-or-nothing"
285
- proposition:
284
+ Distributed transactions are atomic:
285
+
286
+ - Transactions either apply all data changes or roll back the changes.
286
287
287
- - When a transaction commits, all data changes made in the transaction
288
- are saved and visible outside the transaction. That is, a transaction
289
- will not commit some of its changes while rolling back others.
288
+ - If a transaction commits, all data changes made in the transaction
289
+ are saved and are visible outside of the transaction.
290
290
291
291
.. include:: /includes/extracts/transactions-committed-visibility.rst
292
292
@@ -325,11 +325,11 @@ For a list of operations not supported in transactions, see
325
325
326
326
.. _transactions-create-collections-indexes:
327
327
328
- Create Collections and Indexes In a Transaction
328
+ Create Collections and Indexes in a Transaction
329
329
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
330
330
331
- You can perform the following operations inside of a :ref:`distributed
332
- transaction <transactions>` as long as the transaction is not a
331
+ You can perform the following operations in a :ref:`distributed
332
+ transaction <transactions>` if the transaction is not a
333
333
cross-shard write transaction:
334
334
335
335
- Create collections.
@@ -343,11 +343,11 @@ When creating a collection inside a transaction:
343
343
<transactions-operations-ddl-implicit>`, such as with:
344
344
345
345
- an :ref:`insert operation <transactions-operations-ddl-implicit>`
346
- against a non-existing collection, or
346
+ for a non-existent collection, or
347
347
348
348
- an :ref:`update/findAndModify operation
349
349
<transactions-operations-ddl-implicit>` with ``upsert: true``
350
- against a non-existing collection.
350
+ for a non-existent collection.
351
351
352
352
- You can :ref:`explicitly create a collection
353
353
<transactions-operations-ddl-explicit>` using the :dbcommand:`create`
@@ -357,7 +357,7 @@ When :ref:`creating an index inside a transaction
357
357
<transactions-operations-ddl-explicit>` [#create-existing-index]_, the
358
358
index to create must be on either:
359
359
360
- - a non-existing collection. The collection is created as part of the
360
+ - a non-existent collection. The collection is created as part of the
361
361
operation.
362
362
363
363
- a new empty collection created earlier in the same transaction.
@@ -378,7 +378,10 @@ Restrictions
378
378
379
379
- For explicit creation of a collection or an index inside a
380
380
transaction, the transaction read concern level must be
381
- :readconcern:`"local"`. Explicit creation is through:
381
+ :readconcern:`"local"`.
382
+
383
+ To explicitly create collections and indexes, use the following
384
+ commands and methods:
382
385
383
386
.. list-table::
384
387
:header-rows: 1
@@ -435,10 +438,9 @@ Restricted Operations
435
438
Transactions and Sessions
436
439
-------------------------
437
440
438
- - Transactions are associated with a session
441
+ - Transactions are associated with a session.
439
442
440
- - At any given time, you can have at most one open transaction for a
441
- session.
443
+ - You can have at most one open transaction at a time for a session.
442
444
443
445
- When using the drivers, each operation in the transaction must be
444
446
associated with the session. Refer to your driver specific
@@ -478,7 +480,7 @@ Transactions and Read Concern
478
480
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
479
481
480
482
Operations in a transaction use the transaction-level :doc:`read
481
- concern </reference/read-concern>`. That is, any read concern set at
483
+ concern </reference/read-concern>`. This means a read concern set at
482
484
the collection and database level is ignored inside the transaction.
483
485
484
486
You can set the transaction-level :doc:`read concern
@@ -489,8 +491,8 @@ You can set the transaction-level :doc:`read concern
489
491
490
492
- If transaction-level and the session-level read concern are unset,
491
493
the transaction-level read concern defaults to the client-level read
492
- concern. By default, client-level read concern is
493
- :readconcern:`"local"` for reads against the primary. See also:
494
+ concern. By default, the client-level read concern is
495
+ :readconcern:`"local"` for reads on the primary. See also:
494
496
495
497
- :ref:`transactions-read-preference`
496
498
- :doc:`/reference/mongodb-defaults`
@@ -550,16 +552,16 @@ Transactions and Write Concern
550
552
551
553
Transactions use the transaction-level :doc:`write concern
552
554
</reference/write-concern>` to commit the write operations. Write
553
- operations inside transactions must be issued without explicit write
555
+ operations inside transactions must be run without an explicit write
554
556
concern specification and use the default write concern. At commit
555
- time, the writes are then commited using the transaction-level write
557
+ time, the writes committed using the transaction-level write
556
558
concern.
557
559
558
560
.. tip::
559
561
560
- Do not explicitly set the write concern for the individual write
562
+ Don't explicitly set the write concern for the individual write
561
563
operations inside a transaction. Setting write concerns for the
562
- individual write operations inside a transaction results in an error.
564
+ individual write operations inside a transaction returns an error.
563
565
564
566
You can set the transaction-level :doc:`write concern
565
567
</reference/write-concern>` at the transaction start:
@@ -612,9 +614,8 @@ values, including:
612
614
`````````````````
613
615
614
616
- Write concern :writeconcern:`w: "majority" <"majority">` returns
615
- acknowledgement after the commit has been applied to a majority
616
- (M) of voting members, meaning the commit has been applied to the
617
- primary and (M-1) voting secondaries.
617
+ acknowledgement after the commit has been applied to a majority of
618
+ voting members.
618
619
619
620
- When you commit with :writeconcern:`w: "majority" <"majority">`
620
621
write concern, transaction-level :readconcern:`"majority"` read
@@ -643,12 +644,15 @@ values, including:
643
644
General Information
644
645
-------------------
645
646
647
+ The following sections describe additional considerations for
648
+ transactions.
649
+
646
650
Production Considerations
647
651
~~~~~~~~~~~~~~~~~~~~~~~~~
648
652
649
- For various production considerations with using transactions , see
653
+ For transactions in production environments , see
650
654
:ref:`production-considerations`. In addition, for sharded
651
- clusters, see also :ref:`production-considerations-sharded`.
655
+ clusters, see :ref:`production-considerations-sharded`.
652
656
653
657
Arbiters
654
658
~~~~~~~~
@@ -669,7 +673,7 @@ Shard Configuration Restriction
669
673
Diagnostics
670
674
~~~~~~~~~~~
671
675
672
- MongoDB provides various transactions metrics:
676
+ To obtain transaction status and metrics, use the following methods :
673
677
674
678
.. list-table::
675
679
:widths: 40 60
@@ -710,9 +714,9 @@ MongoDB provides various transactions metrics:
710
714
711
715
* - :binary:`~bin.mongod` and :binary:`~bin.mongos` log messages
712
716
713
- - Includes information on slow transactions, which are transactions
717
+ - Includes information on slow transactions ( which are transactions
714
718
that exceed the :setting:`operationProfiling.slowOpThresholdMs`
715
- threshold) under the :data:`TXN` log component.
719
+ threshold) in the :data:`TXN` log component.
716
720
717
721
.. _transactions-fcv:
718
722
@@ -766,8 +770,8 @@ Starting in MongoDB 5.2 (and 5.0.4):
766
770
:parameter:`metadataRefreshInTransactionMaxWaitBehindCritSecMS`
767
771
parameter.
768
772
769
- Additional Transactions Topics
770
- ------------------------------
773
+ Learn More
774
+ ----------
771
775
772
776
- :doc:`/core/transactions-in-applications`
773
777
- :doc:`/core/transactions-production-consideration`
0 commit comments