Skip to content

Commit 04c9fba

Browse files
committed
DOCS-11604,DOCS-11425, DOCS-11637: system collection restrictions, getMore restrictions, update txn operations pages
1 parent aba745c commit 04c9fba

28 files changed

+416
-94
lines changed

source/core/transactions.txt

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ However, for situations that require atomicity for updates to multiple
2626
documents or consistency between reads to multiple documents, MongoDB
2727
provides the ability to perform multi-document transactions against
2828
replica sets. Multi-document transactions can be used across multiple
29-
operations, collections, and documents. Multi-document transactions
29+
operations, collections, databases, and documents. Multi-document transactions
3030
provide an "all-or-nothing" proposition. When a transaction commits,
3131
all data changes made in the transaction are saved. If any operation in
3232
the transaction fails, the transaction aborts and all data changes made
@@ -65,7 +65,7 @@ Storage Engines
6565
~~~~~~~~~~~~~~~
6666

6767
Multi-document transactions are available for the WiredTiger storage
68-
engine and in-memory storage engines.
68+
engine and in-memory storage engines.
6969

7070
If any voting member of a replica set uses the in-memory storage
7171
engine, you must set :rsconf:`writeConcernMajorityJournalDefault` to
@@ -76,20 +76,18 @@ engine, you must set :rsconf:`writeConcernMajorityJournalDefault` to
7676
Transactions and Operations
7777
---------------------------
7878

79-
For multi-document transactions:
80-
81-
- You can specify read/write (CRUD) operations on **existing**
82-
collections.
79+
For transactions:
8380

84-
- You cannot read/write to collections in the ``config``, ``admin``,
85-
or ``local`` databases.
81+
.. include:: /includes/extracts/transactions-operations-crud.rst
8682

8783
Operations that affect the database catalog, such as creating or
88-
dropping a collection or an index, are not allowed in multi-document
89-
transactions. For example, a multi-document transaction cannot include
90-
an insert operation that would result in the creation of a new
84+
dropping a collection or an index, are not allowed in multi-document
85+
transactions. For example, a multi-document transaction cannot include
86+
an insert operation that would result in the creation of a new
9187
collection. See :ref:`transactions-ops-restricted`.
9288

89+
For multi-document transactions:
90+
9391
.. include:: /includes/table-transactions-operations.rst
9492

9593
.. _transactions-ops-count:
@@ -219,7 +217,7 @@ function if a ``"TransientTransactionError"`` is encountered:
219217
break;
220218
} catch (error) {
221219
print("Transaction aborted. Caught exception during transaction.");
222-
220+
223221
// If transient error, retry the whole transaction
224222
if ( error.hasOwnProperty("errorLabels") && error.errorLabels.includes( "TransientTransactionError") ) {
225223
print("TransientTransactionError, retrying transaction ...");
@@ -299,7 +297,7 @@ and retrying the commit, the full code example is:
299297
throw error;
300298
}
301299
}
302-
}
300+
}
303301
}
304302

305303
// Retries commit if UnknownTransactionCommitResult encountered
@@ -375,10 +373,22 @@ Read Preference
375373

376374
.. include:: /includes/extracts/transactions-read-pref.rst
377375

376+
.. _transaction-options:
377+
378+
Transaction Options
379+
-------------------
380+
381+
.. code-block:: javascript
382+
383+
session.startTransaction( {
384+
readConcern: { level: <level>},
385+
writeConcern: { w: <value>, j: <boolean>, wtimeout: <number> }
386+
} );
387+
378388
.. _txn-read-concern:
379389

380390
Read Concern
381-
------------
391+
~~~~~~~~~~~~
382392

383393
Multi-document transactions support read concern
384394
:readconcern:`"snapshot"`, :readconcern:`"local"`, and
@@ -419,7 +429,7 @@ concern.
419429
.. _transactions-write-concern:
420430

421431
Write Concern
422-
-------------
432+
~~~~~~~~~~~~~
423433

424434
You set the write concern at the transaction level, not at the
425435
individual operation level. At the time of the commit, transactions use

source/includes/apiargs-dbcommand-update-field.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ description: |
3737
A document expressing the :doc:`write concern </reference/write-concern>`
3838
of the :dbcommand:`update` command. Omit to use the default write
3939
concern.
40+
41+
.. include:: /includes/extracts/transactions-operations-write-concern.rst
42+
4043
interface: dbcommand
4144
name: writeConcern
4245
operation: update

source/includes/apiargs-method-Bulk.execute-param.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ description: |
88
<repl-set-modify-default-write-concern>`.
99
1010
See :ref:`bulk-execute-ex-write-concern` for an example.
11+
12+
.. include:: /includes/extracts/transactions-operations-write-concern.rst
13+
1114
interface: method
1215
name: writeConcern
1316
operation: Bulk.execute

source/includes/apiargs-method-db.collection.update-param.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ description: |
5959
</reference/write-concern>`. Omit to use the default write concern.
6060
See :ref:`update-wc`.
6161
62-
.. versionadded:: 2.6
62+
.. include:: /includes/extracts/transactions-operations-write-concern.rst
63+
6364
interface: method
6465
name: writeConcern
6566
operation: db.collection.update

source/includes/extracts-transactions.yaml

Lines changed: 61 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,16 @@ ref: transactions-usage
1010
content: |
1111
.. important::
1212
13-
Multi-document transaction incurs a greater performance cost over
14-
single document writes, and the availability of multi-document
15-
transaction should not be a replacement for effective schema design.
16-
For many scenarios, the denormalized data model will continue to be
17-
optimal for your data and use cases.
13+
In most cases, multi-document transaction incurs a greater
14+
performance cost over single document writes, and the
15+
availability of multi-document transaction should not be a
16+
replacement for effective schema design. For many scenarios, the
17+
:ref:`denormalized data model (embedded documents and arrays)
18+
<data-modeling-embedding>` will continue to be optimal for your
19+
data and use cases. That is, for many scenarios, modeling your data
20+
appropriately will minimize the need for multi-document
21+
transactions.
22+
1823
---
1924
ref: transactions-intro
2025
content: |
@@ -78,5 +83,56 @@ content: |
7883
abort operation encounters an error, MongoDB drivers retry the
7984
operation a single time regardless of whether :urioption:`retryWrites` is
8085
set to ``true``.
86+
---
87+
ref: transactions-operations-crud
88+
content: |
89+
- You can specify read/write (CRUD) operations on **existing**
90+
collections. The collections can be in different databases.
91+
92+
- You cannot read/write to collections in the ``config``, ``admin``,
93+
or ``local`` databases.
94+
95+
- You cannot write to ``system.*`` collections.
96+
97+
- You cannot return the supported operation's query plan (i.e. ``explain``).
98+
99+
.. include:: /includes/extracts/transactions-operations-getMore.rst
100+
101+
---
102+
ref: transactions-operations-getMore
103+
content: |
104+
105+
- For cursors created outside of transactions, you cannot call
106+
:dbcommand:`getMore` inside a transaction.
107+
108+
- For cursors created in a transaction, you cannot call
109+
:dbcommand:`getMore` outside the transaction.
110+
111+
---
112+
ref: transactions-supported-operation
113+
content: |
114+
115+
|operation| supports :doc:`multi-document transactions
116+
</core/transactions>`.
117+
118+
---
119+
ref: transactions-operations-write-concern
120+
content: |
121+
122+
Do not explicitly set the write concern for the operation if run in
123+
a transaction. To use write concern with transactions, see
124+
:ref:`transaction-options`.
125+
126+
---
127+
ref: transactions-read-concern-tip
128+
content: |
129+
In MongoDB 4.0, all multi-documents transactions have ``snapshot`` isolation. In
130+
future versions of MongoDB, the server will optimize around your specified read
131+
concern (isolation level).
81132
133+
For :readconcern:`"local"` and :readconcern:`"majority"` read concern, MongoDB
134+
may provide stronger isolation guarantees than specified. If stronger guarantees
135+
are needed, be explicit as future versions of the server may include
136+
optimizations that remove stronger isolation guarantees than explicitly
137+
specified.
82138
...

source/includes/table-sql-to-mongo-terms.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,16 @@
3636
- aggregation pipeline
3737

3838
See the :doc:`/reference/sql-aggregation-comparison`.
39+
40+
* - transactions
41+
42+
- :doc:`/core/transactions`
43+
44+
.. tip::
45+
46+
For many scenarios, the :ref:`denormalized data model
47+
(embedded documents and arrays) <data-modeling-embedding>`
48+
will continue to be optimal for your data and use cases
49+
instead of multi-document transactions. That is, for many
50+
scenarios, modeling your data appropriately will minimize the
51+
need for multi-document transactions.

source/includes/table-transactions-operations.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@
4141
| :method:`db.collection.findOneAndUpdate()`
4242
4343
- :dbcommand:`findAndModify`
44-
-
44+
- For ``upsert``, only when run against an existing collection.
45+
4546

4647
* - | :method:`db.collection.insertMany()`
4748
| :method:`db.collection.insertOne()`
@@ -51,9 +52,13 @@
5152

5253
- Only when run against an existing collection.
5354

55+
* - :method:`db.collection.save()`
56+
-
57+
- If an insert, only when run against an existing collection.
5458

5559
* - | :method:`db.collection.updateOne()`
5660
| :method:`db.collection.updateMany()`
61+
| :method:`db.collection.replaceOne()`
5762
| :method:`db.collection.update()`
5863
5964
- :dbcommand:`update`

source/reference/command/aggregate.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,17 @@ For more information about the aggregation pipeline
5656
:doc:`/core/aggregation-pipeline`, :doc:`/reference/aggregation`, and
5757
:doc:`/core/aggregation-pipeline-limits`.
5858

59+
Sessions
60+
~~~~~~~~
61+
62+
.. versionadded:: 4.0
63+
64+
For cursors created inside a session, you cannot call
65+
:dbcommand:`getMore` outside the session.
66+
67+
Similarly, for cursors created outside of a session, you cannot call
68+
:dbcommand:`getMore` inside a session.
69+
5970
Transactions
6071
------------
6172

@@ -72,6 +83,8 @@ However, the following stages are not allowed within transactions:
7283

7384
You also cannot specify the ``explain`` option.
7485

86+
.. include:: /includes/extracts/transactions-operations-getMore.rst
87+
7588
.. include:: /includes/extracts/transactions-usage.rst
7689

7790
.. |operation| replace:: :dbcommand:`aggregate`

source/reference/command/delete.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,6 @@ Transactions
8282

8383
.. include:: /includes/extracts/transactions-usage.rst
8484

85-
.. |operation| replace:: :dbcommand:`delete`
86-
8785

8886
Examples
8987
--------

source/reference/command/find.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,24 @@ Definition
6262
Behavior
6363
--------
6464

65+
Sessions
66+
~~~~~~~~
67+
68+
.. versionadded:: 4.0
69+
70+
For cursors created inside a session, you cannot call
71+
:dbcommand:`getMore` outside the session.
72+
73+
Similarly, for cursors created outside of a session, you cannot call
74+
:dbcommand:`getMore` inside a session.
75+
6576
Transactions
6677
~~~~~~~~~~~~
6778

6879
.. include:: /includes/extracts/transactions-supported-operation.rst
6980

81+
.. include:: /includes/extracts/transactions-operations-getMore.rst
82+
7083
.. include:: /includes/extracts/transactions-usage.rst
7184

7285
.. |operation| replace:: :dbcommand:`find`

source/reference/command/findAndModify.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,15 +159,12 @@ Transactions
159159

160160
.. include:: /includes/extracts/transactions-supported-operation.rst
161161

162-
If ``upsert: true``, the collection must already exist.
162+
If the operation results in an upsert, the collection must already exist.
163163

164164
.. include:: /includes/extracts/transactions-operations-write-concern.rst
165165

166166
.. include:: /includes/extracts/transactions-usage.rst
167167

168-
169-
.. |operation| replace:: :dbcommand:`findAndModify`
170-
171168
Examples
172169
--------
173170

source/reference/command/geoSearch.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Transactions
4343

4444
.. include:: /includes/extracts/transactions-usage.rst
4545

46-
.. |operation| replace:: :dbcommand:`distinct`
46+
.. |operation| replace:: :dbcommand:`geoSearch`
4747

4848
Examples
4949
--------

source/reference/command/getMore.txt

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,35 @@ Definition
3636

3737
.. include:: /includes/apiargs/dbcommand-getMore-field.rst
3838

39-
.. versionadded:: 3.6
4039

41-
If :doc:`authentication </core/authentication>` is turned on, you can
42-
only issue a :dbcommand:`getMore` against cursors you created.
40+
Behavior
41+
--------
42+
43+
Access Control
44+
~~~~~~~~~~~~~~
45+
46+
.. versionadded:: 3.6
47+
48+
If :doc:`authentication </core/authentication>` is turned on, you can
49+
only issue a :dbcommand:`getMore` against cursors you created.
50+
51+
Sessions
52+
~~~~~~~~
53+
54+
.. versionadded:: 4.0
55+
56+
For cursors created inside a session, you cannot call
57+
:dbcommand:`getMore` outside the session.
58+
59+
Similarly, for cursors created outside of a session, you cannot call
60+
:dbcommand:`getMore` inside a session.
61+
62+
Transactions
63+
````````````
64+
65+
.. versionadded:: 4.0
66+
67+
For :doc:`multi-document transactions </core/transactions>`:
68+
69+
.. include:: /includes/extracts/transactions-operations-getMore.rst
4370

44-
.. seealso:: :ref:`3.2-driver-compatibility`

source/reference/command/update.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,19 @@ Document Validation
116116

117117
.. include:: /includes/extracts/bypassDocumentValidation-update.rst
118118

119+
Transactions
120+
~~~~~~~~~~~~
121+
122+
.. include:: /includes/extracts/transactions-supported-operation.rst
123+
124+
If the operation results in an upsert, the collection must already exist.
125+
126+
.. include:: /includes/extracts/transactions-operations-write-concern.rst
127+
128+
.. include:: /includes/extracts/transactions-usage.rst
129+
130+
.. |operation| replace:: :dbcommand:`update`
131+
119132
Examples
120133
--------
121134

0 commit comments

Comments
 (0)