@@ -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.mongo` shell, see :ref:`txn-mongo-shell-example`.
@@ -335,12 +335,12 @@ Transactions and Atomicity
335
335
336
336
.. include:: /includes/transactions/distributed-transaction-repl-shard-support.rst
337
337
338
- Distributed transactions are atomic. They provide an "all-or-nothing"
339
- proposition:
338
+ Distributed transactions are atomic:
339
+
340
+ - Transactions either apply all data changes or roll back the changes.
340
341
341
- - When a transaction commits, all data changes made in the transaction
342
- are saved and visible outside the transaction. That is, a transaction
343
- will not commit some of its changes while rolling back others.
342
+ - If a transaction commits, all data changes made in the transaction
343
+ are saved and are visible outside of the transaction.
344
344
345
345
.. include:: /includes/extracts/transactions-committed-visibility.rst
346
346
@@ -379,11 +379,11 @@ For a list of operations not supported in transactions, see
379
379
380
380
.. _transactions-create-collections-indexes:
381
381
382
- Create Collections and Indexes In a Transaction
382
+ Create Collections and Indexes in a Transaction
383
383
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
384
384
385
- You can perform the following operations inside of a :ref:`distributed
386
- transaction <transactions>` as long as the transaction is not a
385
+ You can perform the following operations in a :ref:`distributed
386
+ transaction <transactions>` if the transaction is not a
387
387
cross-shard write transaction:
388
388
389
389
- Create collections.
@@ -397,11 +397,11 @@ When creating a collection inside a transaction:
397
397
<transactions-operations-ddl-implicit>`, such as with:
398
398
399
399
- an :ref:`insert operation <transactions-operations-ddl-implicit>`
400
- against a non-existing collection, or
400
+ for a non-existent collection, or
401
401
402
402
- an :ref:`update/findAndModify operation
403
403
<transactions-operations-ddl-implicit>` with ``upsert: true``
404
- against a non-existing collection.
404
+ for a non-existent collection.
405
405
406
406
- You can :ref:`explicitly create a collection
407
407
<transactions-operations-ddl-explicit>` using the :dbcommand:`create`
@@ -411,7 +411,7 @@ When :ref:`creating an index inside a transaction
411
411
<transactions-operations-ddl-explicit>` [#create-existing-index]_, the
412
412
index to create must be on either:
413
413
414
- - a non-existing collection. The collection is created as part of the
414
+ - a non-existent collection. The collection is created as part of the
415
415
operation.
416
416
417
417
- a new empty collection created earlier in the same transaction.
@@ -430,7 +430,10 @@ Restrictions
430
430
431
431
- For explicit creation of a collection or an index inside a
432
432
transaction, the transaction read concern level must be
433
- :readconcern:`"local"`. Explicit creation is through:
433
+ :readconcern:`"local"`.
434
+
435
+ To explicitly create collections and indexes, use the following
436
+ commands and methods:
434
437
435
438
.. list-table::
436
439
:header-rows: 1
@@ -492,10 +495,9 @@ Restricted Operations
492
495
Transactions and Sessions
493
496
-------------------------
494
497
495
- - Transactions are associated with a session
498
+ - Transactions are associated with a session.
496
499
497
- - At any given time, you can have at most one open transaction for a
498
- session.
500
+ - You can have at most one open transaction at a time for a session.
499
501
500
502
- When using the drivers, each operation in the transaction must be
501
503
associated with the session. Refer to your driver specific
@@ -535,7 +537,7 @@ Transactions and Read Concern
535
537
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
536
538
537
539
Operations in a transaction use the transaction-level :doc:`read
538
- concern </reference/read-concern>`. That is, any read concern set at
540
+ concern </reference/read-concern>`. This means a read concern set at
539
541
the collection and database level is ignored inside the transaction.
540
542
541
543
You can set the transaction-level :doc:`read concern
@@ -546,8 +548,8 @@ You can set the transaction-level :doc:`read concern
546
548
547
549
- If transaction-level and the session-level read concern are unset,
548
550
the transaction-level read concern defaults to the client-level read
549
- concern. By default, client-level read concern is
550
- :readconcern:`"local"` for reads against the primary. See also:
551
+ concern. By default, the client-level read concern is
552
+ :readconcern:`"local"` for reads on the primary. See also:
551
553
552
554
- :ref:`transactions-read-preference`
553
555
- :doc:`/reference/mongodb-defaults`
@@ -607,16 +609,16 @@ Transactions and Write Concern
607
609
608
610
Transactions use the transaction-level :doc:`write concern
609
611
</reference/write-concern>` to commit the write operations. Write
610
- operations inside transactions must be issued without explicit write
612
+ operations inside transactions must be run without an explicit write
611
613
concern specification and use the default write concern. At commit
612
- time, the writes are then commited using the transaction-level write
614
+ time, the writes committed using the transaction-level write
613
615
concern.
614
616
615
617
.. tip::
616
618
617
- Do not explicitly set the write concern for the individual write
619
+ Don't explicitly set the write concern for the individual write
618
620
operations inside a transaction. Setting write concerns for the
619
- individual write operations inside a transaction results in an error.
621
+ individual write operations inside a transaction returns an error.
620
622
621
623
You can set the transaction-level :doc:`write concern
622
624
</reference/write-concern>` at the transaction start:
@@ -661,9 +663,8 @@ values, including:
661
663
`````````````````
662
664
663
665
- Write concern :writeconcern:`w: "majority" <"majority">` returns
664
- acknowledgement after the commit has been applied to a majority
665
- (M) of voting members, meaning the commit has been applied to the
666
- primary and (M-1) voting secondaries.
666
+ acknowledgement after the commit has been applied to a majority of
667
+ voting members.
667
668
668
669
- When you commit with :writeconcern:`w: "majority" <"majority">`
669
670
write concern, transaction-level :readconcern:`"majority"` read
@@ -690,12 +691,15 @@ values, including:
690
691
General Information
691
692
-------------------
692
693
694
+ The following sections describe additional considerations for
695
+ transactions.
696
+
693
697
Production Considerations
694
698
~~~~~~~~~~~~~~~~~~~~~~~~~
695
699
696
- For various production considerations with using transactions , see
700
+ For transactions in production environments , see
697
701
:ref:`production-considerations`. In addition, for sharded
698
- clusters, see also :ref:`production-considerations-sharded`.
702
+ clusters, see :ref:`production-considerations-sharded`.
699
703
700
704
Arbiters
701
705
~~~~~~~~
@@ -744,7 +748,7 @@ Shard Configuration Restriction
744
748
Diagnostics
745
749
~~~~~~~~~~~
746
750
747
- MongoDB provides various transactions metrics:
751
+ To obtain transaction status and metrics, use the following methods :
748
752
749
753
.. list-table::
750
754
:widths: 40 60
@@ -785,9 +789,9 @@ MongoDB provides various transactions metrics:
785
789
786
790
* - :binary:`~bin.mongod` and :binary:`~bin.mongos` log messages
787
791
788
- - Includes information on slow transactions, which are transactions
792
+ - Includes information on slow transactions ( which are transactions
789
793
that exceed the :setting:`operationProfiling.slowOpThresholdMs`
790
- threshold) under the :data:`TXN` log component.
794
+ threshold) in the :data:`TXN` log component.
791
795
792
796
.. _transactions-fcv:
793
797
0 commit comments