@@ -83,7 +83,8 @@ This example highlights the key components of the transactions API.
83
83
/*
84
84
For a replica set, include the replica set name and a seedlist of the members in the URI string; e.g.
85
85
String uri = "mongodb://mongodb0.example.com:27017,mongodb1.example.com:27017/admin?replicaSet=myRepl";
86
- For a sharded cluster, connect to the mongos instances; e.g.
86
+ For a sharded cluster, connect to the mongos instances.
87
+ For example:
87
88
String uri = "mongodb://mongos0.example.com:27017,mongos1.example.com:27017:27017/admin";
88
89
*/
89
90
@@ -323,7 +324,6 @@ This example highlights the key components of the transactions API.
323
324
.. literalinclude:: /driver-examples/DocumentationTransactionsExampleSpec.scala
324
325
:language: scala
325
326
326
-
327
327
.. seealso::
328
328
329
329
For an example in :binary:`~bin.mongosh`, see
@@ -336,12 +336,12 @@ Transactions and Atomicity
336
336
337
337
.. include:: /includes/transactions/distributed-transaction-repl-shard-support.rst
338
338
339
- Distributed transactions are atomic. They provide an "all-or-nothing"
340
- proposition:
339
+ Distributed transactions are atomic:
340
+
341
+ - Transactions either apply all data changes or roll back the changes.
341
342
342
- - When a transaction commits, all data changes made in the transaction
343
- are saved and visible outside the transaction. That is, a transaction
344
- will not commit some of its changes while rolling back others.
343
+ - If a transaction commits, all data changes made in the transaction
344
+ are saved and are visible outside of the transaction.
345
345
346
346
.. include:: /includes/extracts/transactions-committed-visibility.rst
347
347
@@ -380,11 +380,11 @@ For a list of operations not supported in transactions, see
380
380
381
381
.. _transactions-create-collections-indexes:
382
382
383
- Create Collections and Indexes In a Transaction
383
+ Create Collections and Indexes in a Transaction
384
384
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
385
385
386
- You can perform the following operations inside of a :ref:`distributed
387
- transaction <transactions>` as long as the transaction is not a
386
+ You can perform the following operations in a :ref:`distributed
387
+ transaction <transactions>` if the transaction is not a
388
388
cross-shard write transaction:
389
389
390
390
- Create collections.
@@ -398,11 +398,11 @@ When creating a collection inside a transaction:
398
398
<transactions-operations-ddl-implicit>`, such as with:
399
399
400
400
- an :ref:`insert operation <transactions-operations-ddl-implicit>`
401
- against a non-existing collection, or
401
+ for a non-existent collection, or
402
402
403
403
- an :ref:`update/findAndModify operation
404
404
<transactions-operations-ddl-implicit>` with ``upsert: true``
405
- against a non-existing collection.
405
+ for a non-existent collection.
406
406
407
407
- You can :ref:`explicitly create a collection
408
408
<transactions-operations-ddl-explicit>` using the :dbcommand:`create`
@@ -412,7 +412,7 @@ When :ref:`creating an index inside a transaction
412
412
<transactions-operations-ddl-explicit>` [#create-existing-index]_, the
413
413
index to create must be on either:
414
414
415
- - a non-existing collection. The collection is created as part of the
415
+ - a non-existent collection. The collection is created as part of the
416
416
operation.
417
417
418
418
- a new empty collection created earlier in the same transaction.
@@ -431,7 +431,10 @@ Restrictions
431
431
432
432
- For explicit creation of a collection or an index inside a
433
433
transaction, the transaction read concern level must be
434
- :readconcern:`"local"`. Explicit creation is through:
434
+ :readconcern:`"local"`.
435
+
436
+ To explicitly create collections and indexes, use the following
437
+ commands and methods:
435
438
436
439
.. list-table::
437
440
:header-rows: 1
@@ -488,10 +491,9 @@ Restricted Operations
488
491
Transactions and Sessions
489
492
-------------------------
490
493
491
- - Transactions are associated with a session
494
+ - Transactions are associated with a session.
492
495
493
- - At any given time, you can have at most one open transaction for a
494
- session.
496
+ - You can have at most one open transaction at a time for a session.
495
497
496
498
- When using the drivers, each operation in the transaction must be
497
499
associated with the session. Refer to your driver specific
@@ -531,7 +533,7 @@ Transactions and Read Concern
531
533
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
532
534
533
535
Operations in a transaction use the transaction-level :doc:`read
534
- concern </reference/read-concern>`. That is, any read concern set at
536
+ concern </reference/read-concern>`. This means a read concern set at
535
537
the collection and database level is ignored inside the transaction.
536
538
537
539
You can set the transaction-level :doc:`read concern
@@ -542,8 +544,8 @@ You can set the transaction-level :doc:`read concern
542
544
543
545
- If transaction-level and the session-level read concern are unset,
544
546
the transaction-level read concern defaults to the client-level read
545
- concern. By default, client-level read concern is
546
- :readconcern:`"local"` for reads against the primary. See also:
547
+ concern. By default, the client-level read concern is
548
+ :readconcern:`"local"` for reads on the primary. See also:
547
549
548
550
- :ref:`transactions-read-preference`
549
551
- :doc:`/reference/mongodb-defaults`
@@ -603,16 +605,16 @@ Transactions and Write Concern
603
605
604
606
Transactions use the transaction-level :doc:`write concern
605
607
</reference/write-concern>` to commit the write operations. Write
606
- operations inside transactions must be issued without explicit write
608
+ operations inside transactions must be run without an explicit write
607
609
concern specification and use the default write concern. At commit
608
- time, the writes are then commited using the transaction-level write
610
+ time, the writes committed using the transaction-level write
609
611
concern.
610
612
611
613
.. tip::
612
614
613
- Do not explicitly set the write concern for the individual write
615
+ Don't explicitly set the write concern for the individual write
614
616
operations inside a transaction. Setting write concerns for the
615
- individual write operations inside a transaction results in an error.
617
+ individual write operations inside a transaction returns an error.
616
618
617
619
You can set the transaction-level :doc:`write concern
618
620
</reference/write-concern>` at the transaction start:
@@ -665,9 +667,8 @@ values, including:
665
667
`````````````````
666
668
667
669
- Write concern :writeconcern:`w: "majority" <"majority">` returns
668
- acknowledgement after the commit has been applied to a majority
669
- (M) of voting members, meaning the commit has been applied to the
670
- primary and (M-1) voting secondaries.
670
+ acknowledgement after the commit has been applied to a majority of
671
+ voting members.
671
672
672
673
- When you commit with :writeconcern:`w: "majority" <"majority">`
673
674
write concern, transaction-level :readconcern:`"majority"` read
@@ -696,12 +697,15 @@ values, including:
696
697
General Information
697
698
-------------------
698
699
700
+ The following sections describe additional considerations for
701
+ transactions.
702
+
699
703
Production Considerations
700
704
~~~~~~~~~~~~~~~~~~~~~~~~~
701
705
702
- For various production considerations with using transactions , see
706
+ For transactions in production environments , see
703
707
:ref:`production-considerations`. In addition, for sharded
704
- clusters, see also :ref:`production-considerations-sharded`.
708
+ clusters, see :ref:`production-considerations-sharded`.
705
709
706
710
Arbiters
707
711
~~~~~~~~
@@ -722,7 +726,7 @@ Shard Configuration Restriction
722
726
Diagnostics
723
727
~~~~~~~~~~~
724
728
725
- MongoDB provides various transactions metrics:
729
+ To obtain transaction status and metrics, use the following methods :
726
730
727
731
.. list-table::
728
732
:widths: 40 60
@@ -763,9 +767,9 @@ MongoDB provides various transactions metrics:
763
767
764
768
* - :binary:`~bin.mongod` and :binary:`~bin.mongos` log messages
765
769
766
- - Includes information on slow transactions, which are transactions
770
+ - Includes information on slow transactions ( which are transactions
767
771
that exceed the :setting:`operationProfiling.slowOpThresholdMs`
768
- threshold) under the :data:`TXN` log component.
772
+ threshold) in the :data:`TXN` log component.
769
773
770
774
.. _transactions-fcv:
771
775
0 commit comments