@@ -80,7 +80,8 @@ upper-right to set the language of the following example.
80
80
/*
81
81
For a replica set, include the replica set name and a seedlist of the members in the URI string; e.g.
82
82
String uri = "mongodb://mongodb0.example.com:27017,mongodb1.example.com:27017/admin?replicaSet=myRepl";
83
- For a sharded cluster, connect to the mongos instances; e.g.
83
+ For a sharded cluster, connect to the mongos instances.
84
+ For example:
84
85
String uri = "mongodb://mongos0.example.com:27017,mongos1.example.com:27017:27017/admin";
85
86
*/
86
87
@@ -277,7 +278,6 @@ upper-right to set the language of the following example.
277
278
.. literalinclude:: /driver-examples/DocumentationTransactionsExampleSpec.scala
278
279
:language: scala
279
280
280
-
281
281
.. seealso::
282
282
283
283
For an example in :binary:`~bin.mongosh`, see
@@ -290,12 +290,12 @@ Transactions and Atomicity
290
290
291
291
.. include:: /includes/transactions/distributed-transaction-repl-shard-support.rst
292
292
293
- Distributed transactions are atomic. They provide an "all-or-nothing"
294
- proposition:
293
+ Distributed transactions are atomic:
294
+
295
+ - Transactions either apply all data changes or roll back the changes.
295
296
296
- - When a transaction commits, all data changes made in the transaction
297
- are saved and visible outside the transaction. That is, a transaction
298
- will not commit some of its changes while rolling back others.
297
+ - If a transaction commits, all data changes made in the transaction
298
+ are saved and are visible outside of the transaction.
299
299
300
300
.. include:: /includes/extracts/transactions-committed-visibility.rst
301
301
@@ -334,11 +334,11 @@ For a list of operations not supported in transactions, see
334
334
335
335
.. _transactions-create-collections-indexes:
336
336
337
- Create Collections and Indexes In a Transaction
337
+ Create Collections and Indexes in a Transaction
338
338
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
339
339
340
- You can perform the following operations inside of a :ref:`distributed
341
- transaction <transactions>` as long as the transaction is not a
340
+ You can perform the following operations in a :ref:`distributed
341
+ transaction <transactions>` if the transaction is not a
342
342
cross-shard write transaction:
343
343
344
344
- Create collections.
@@ -352,11 +352,11 @@ When creating a collection inside a transaction:
352
352
<transactions-operations-ddl-implicit>`, such as with:
353
353
354
354
- an :ref:`insert operation <transactions-operations-ddl-implicit>`
355
- against a non-existing collection, or
355
+ for a non-existent collection, or
356
356
357
357
- an :ref:`update/findAndModify operation
358
358
<transactions-operations-ddl-implicit>` with ``upsert: true``
359
- against a non-existing collection.
359
+ for a non-existent collection.
360
360
361
361
- You can :ref:`explicitly create a collection
362
362
<transactions-operations-ddl-explicit>` using the :dbcommand:`create`
@@ -366,7 +366,7 @@ When :ref:`creating an index inside a transaction
366
366
<transactions-operations-ddl-explicit>` [#create-existing-index]_, the
367
367
index to create must be on either:
368
368
369
- - a non-existing collection. The collection is created as part of the
369
+ - a non-existent collection. The collection is created as part of the
370
370
operation.
371
371
372
372
- a new empty collection created earlier in the same transaction.
@@ -387,7 +387,10 @@ Restrictions
387
387
388
388
- For explicit creation of a collection or an index inside a
389
389
transaction, the transaction read concern level must be
390
- :readconcern:`"local"`. Explicit creation is through:
390
+ :readconcern:`"local"`.
391
+
392
+ To explicitly create collections and indexes, use the following
393
+ commands and methods:
391
394
392
395
.. list-table::
393
396
:header-rows: 1
@@ -444,10 +447,9 @@ Restricted Operations
444
447
Transactions and Sessions
445
448
-------------------------
446
449
447
- - Transactions are associated with a session
450
+ - Transactions are associated with a session.
448
451
449
- - At any given time, you can have at most one open transaction for a
450
- session.
452
+ - You can have at most one open transaction at a time for a session.
451
453
452
454
- When using the drivers, each operation in the transaction must be
453
455
associated with the session. Refer to your driver specific
@@ -487,7 +489,7 @@ Transactions and Read Concern
487
489
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
488
490
489
491
Operations in a transaction use the transaction-level :doc:`read
490
- concern </reference/read-concern>`. That is, any read concern set at
492
+ concern </reference/read-concern>`. This means a read concern set at
491
493
the collection and database level is ignored inside the transaction.
492
494
493
495
You can set the transaction-level :doc:`read concern
@@ -498,8 +500,8 @@ You can set the transaction-level :doc:`read concern
498
500
499
501
- If transaction-level and the session-level read concern are unset,
500
502
the transaction-level read concern defaults to the client-level read
501
- concern. By default, client-level read concern is
502
- :readconcern:`"local"` for reads against the primary. See also:
503
+ concern. By default, the client-level read concern is
504
+ :readconcern:`"local"` for reads on the primary. See also:
503
505
504
506
- :ref:`transactions-read-preference`
505
507
- :doc:`/reference/mongodb-defaults`
@@ -559,16 +561,16 @@ Transactions and Write Concern
559
561
560
562
Transactions use the transaction-level :doc:`write concern
561
563
</reference/write-concern>` to commit the write operations. Write
562
- operations inside transactions must be issued without explicit write
564
+ operations inside transactions must be run without an explicit write
563
565
concern specification and use the default write concern. At commit
564
- time, the writes are then commited using the transaction-level write
566
+ time, the writes committed using the transaction-level write
565
567
concern.
566
568
567
569
.. tip::
568
570
569
- Do not explicitly set the write concern for the individual write
571
+ Don't explicitly set the write concern for the individual write
570
572
operations inside a transaction. Setting write concerns for the
571
- individual write operations inside a transaction results in an error.
573
+ individual write operations inside a transaction returns an error.
572
574
573
575
You can set the transaction-level :doc:`write concern
574
576
</reference/write-concern>` at the transaction start:
@@ -621,9 +623,8 @@ values, including:
621
623
`````````````````
622
624
623
625
- Write concern :writeconcern:`w: "majority" <"majority">` returns
624
- acknowledgement after the commit has been applied to a majority
625
- (M) of voting members, meaning the commit has been applied to the
626
- primary and (M-1) voting secondaries.
626
+ acknowledgement after the commit has been applied to a majority of
627
+ voting members.
627
628
628
629
- When you commit with :writeconcern:`w: "majority" <"majority">`
629
630
write concern, transaction-level :readconcern:`"majority"` read
@@ -652,12 +653,15 @@ values, including:
652
653
General Information
653
654
-------------------
654
655
656
+ The following sections describe additional considerations for
657
+ transactions.
658
+
655
659
Production Considerations
656
660
~~~~~~~~~~~~~~~~~~~~~~~~~
657
661
658
- For various production considerations with using transactions , see
662
+ For transactions in production environments , see
659
663
:ref:`production-considerations`. In addition, for sharded
660
- clusters, see also :ref:`production-considerations-sharded`.
664
+ clusters, see :ref:`production-considerations-sharded`.
661
665
662
666
Arbiters
663
667
~~~~~~~~
@@ -678,7 +682,7 @@ Shard Configuration Restriction
678
682
Diagnostics
679
683
~~~~~~~~~~~
680
684
681
- MongoDB provides various transactions metrics:
685
+ To obtain transaction status and metrics, use the following methods :
682
686
683
687
.. list-table::
684
688
:widths: 40 60
@@ -719,9 +723,9 @@ MongoDB provides various transactions metrics:
719
723
720
724
* - :binary:`~bin.mongod` and :binary:`~bin.mongos` log messages
721
725
722
- - Includes information on slow transactions, which are transactions
726
+ - Includes information on slow transactions ( which are transactions
723
727
that exceed the :setting:`operationProfiling.slowOpThresholdMs`
724
- threshold) under the :data:`TXN` log component.
728
+ threshold) in the :data:`TXN` log component.
725
729
726
730
.. _transactions-fcv:
727
731
@@ -775,8 +779,8 @@ Starting in MongoDB 5.2 (and 5.0.4):
775
779
:parameter:`metadataRefreshInTransactionMaxWaitBehindCritSecMS`
776
780
parameter.
777
781
778
- Additional Transactions Topics
779
- ------------------------------
782
+ Learn More
783
+ ----------
780
784
781
785
- :doc:`/core/transactions-in-applications`
782
786
- :doc:`/core/transactions-production-consideration`
0 commit comments