Skip to content

Commit 93c9962

Browse files
committed
DOCS-11585: mongos and metadata operations
1 parent ead1556 commit 93c9962

23 files changed

+248
-12
lines changed

source/core/sharded-cluster-query-router.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,3 +293,9 @@ to access individual shards.
293293

294294
See :doc:`/tutorial/enable-authentication` for a tutorial on enabling
295295
adding users to an RBAC-enabled MongoDB deployment.
296+
297+
Metadata Operations
298+
-------------------
299+
300+
.. include:: /includes/extracts/mongos-operations-wc.rst
301+

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ description: |
189189
for the operation. Omit to use the default write
190190
concern.
191191
192+
.. include:: /includes/extracts/mongos-operations-wc-create.rst
193+
192194
optional: true
193195
arg_name: field
194196
type: document

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ description: |
4040
for the operation. Omit to use the default write
4141
concern.
4242
43+
.. include:: /includes/extracts/mongos-operations-wc-rename-collection.rst
44+
4345
optional: true
4446
arg_name: field
4547
type: document

source/includes/apiargs-method-db.createCollection-options-param.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,4 +280,19 @@ description: |
280280
281281
replacement:
282282
example: ":ref:`createCollection-collation-example`"
283+
---
284+
position: 15
285+
name: writeConcern
286+
description: |
287+
A document that expresses the :doc:`write concern </reference/write-concern>`
288+
for the operation. Omit to use the default write
289+
concern.
290+
291+
.. include:: /includes/extracts/mongos-operations-wc-create.rst
292+
293+
optional: true
294+
type: document
295+
interface: method
296+
operation: db.createCollection
297+
arg_name: field
283298
...
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
ref: mongos-operations-wc-move-primary
2+
content: |
3+
4+
:binary:`~bin.mongos` uses :writeconcern:`"majority"` for
5+
:dbcommand:`movePrimary`.
6+
7+
---
8+
ref: mongos-operations-wc-drop
9+
content: |
10+
11+
When issued on a sharded cluster, :binary:`~bin.mongos` converts the
12+
:doc:`write concern </reference/write-concern>` of the
13+
:dbcommand:`drop` command and its helper
14+
:method:`db.collection.drop()` to :writeconcern:`"majority"`.
15+
---
16+
ref: mongos-operations-wc-rename-collection
17+
content: |
18+
19+
When issued on a sharded cluster, :binary:`~bin.mongos` converts the
20+
:doc:`write concern </reference/write-concern>` of the
21+
:dbcommand:`renameCollection` command and its helper
22+
:method:`db.collection.renameCollection()` to
23+
:writeconcern:`"majority"`.
24+
25+
.. note::
26+
27+
You cannot rename a sharded collection. You can however rename an
28+
unsharded collection in a sharded cluster.
29+
30+
---
31+
ref: mongos-operations-wc-create
32+
content: |
33+
34+
When issued on a sharded cluster, :binary:`~bin.mongos` converts the
35+
:doc:`write concern </reference/write-concern>` of the
36+
:dbcommand:`create` command and its helper
37+
:method:`db.createCollection()` to :writeconcern:`"majority"`.
38+
---
39+
ref: mongos-operations-wc-drop-database
40+
content: |
41+
42+
When issued on a sharded cluster, MongoDB converts the :doc:`write
43+
concern </reference/write-concern>` of the :dbcommand:`dropDatabase`
44+
command to :writeconcern:`"majority"`.
45+
46+
---
47+
ref: mongos-operations-wc-shard-collection
48+
content: |
49+
50+
:binary:`~bin.mongos` uses :writeconcern:`"majority"` for the
51+
:doc:`write concern </reference/write-concern>` of the
52+
:dbcommand:`shardCollection` command and its helper
53+
:method:`sh.shardCollection()`.
54+
55+
---
56+
ref: mongos-operations-wc-enable-sharding
57+
content: |
58+
59+
:binary:`~bin.mongos` uses
60+
:writeconcern:`"majority"` for the
61+
:dbcommand:`enableSharding` command and its helper
62+
:method:`sh.enableSharding()`.
63+
---
64+
ref: mongos-operations-wc-add-shard
65+
content: |
66+
67+
:binary:`~bin.mongos` uses
68+
:writeconcern:`"majority"` for the
69+
:dbcommand:`addShard` command and its helper
70+
:method:`sh.addShard()`.
71+
72+
---
73+
ref: mongos-operations-wc-remove-shard
74+
content: |
75+
76+
:binary:`~bin.mongos` converts the
77+
:doc:`write concern </reference/write-concern>` of the
78+
:dbcommand:`removeShard` command to :writeconcern:`"majority"`.
79+
80+
---
81+
ref: mongos-operations-wc-fcv
82+
content: |
83+
When issued on a sharded cluster, :binary:`~bin.mongos` converts the
84+
:doc:`write concern </reference/write-concern>` of the
85+
:dbcommand:`setFeatureCompatibilityVersion` command to :writeconcern:`"majority"`.
86+
---
87+
ref: mongos-operations-wc
88+
content: |
89+
90+
:binary:`~bin.mongos` uses :writeconcern:`"majority"` for the
91+
following operations that affect the sharded cluster metadata:
92+
93+
.. list-table::
94+
:header-rows: 1
95+
96+
* - Command
97+
- Method
98+
- Note
99+
100+
* - :dbcommand:`addShard`
101+
- :method:`sh.addShard()`
102+
-
103+
104+
* - :dbcommand:`create`
105+
- :method:`db.createCollection()`
106+
-
107+
108+
* - :dbcommand:`drop`
109+
- :method:`db.collection.drop()`
110+
-
111+
112+
* - :dbcommand:`dropDatabase`
113+
114+
- :method:`db.dropDatabase()`
115+
116+
- Changed in MongoDB 3.6
117+
118+
* - :dbcommand:`enableSharding`
119+
- :method:`sh.enableSharding()`
120+
-
121+
122+
* - :dbcommand:`movePrimary`
123+
-
124+
-
125+
126+
* - :dbcommand:`renameCollection`
127+
- :method:`db.collection.renameCollection()`
128+
-
129+
130+
* - :dbcommand:`shardCollection`
131+
- :method:`sh.shardCollection()`
132+
-
133+
134+
* - :dbcommand:`removeShard`
135+
-
136+
-
137+
138+
* - :dbcommand:`setFeatureCompatibilityVersion`
139+
-
140+
-
141+
...
142+

source/includes/steps-convert-replica-set-enable-sharding.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ action:
2121
code: |
2222
sh.enableSharding( "test" )
2323
- pre: |
24+
.. include:: /includes/extracts/mongos-operations-wc-enable-sharding.rst
25+
2426
The operation returns the status of the operation:
2527
language: sh
2628
code: |
@@ -77,6 +79,9 @@ action:
7779
use test
7880
sh.shardCollection( "test.test_collection", { "number" : 1 } )
7981
- pre: |
82+
83+
.. include:: /includes/extracts/mongos-operations-wc-shard-collection.rst
84+
8085
The method returns the status of the operation:
8186
language: sh
8287
code: |

source/includes/steps-shard-a-collection-ranged.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ ref: shard-database
3434
pre: |
3535
Issue the :method:`sh.enableSharding()` method, specifying the name of the
3636
target database:
37+
3738
action:
3839
- pre: |
3940
language: javascript
@@ -46,6 +47,9 @@ action:
4647
code: |
4748
db.runCommand( { enableSharding : <database> } )
4849
post: |
50+
.. include:: /includes/extracts/mongos-operations-wc-enable-sharding.rst
51+
52+
4953
Enabling sharding on a database does *not* begin the sharding process.
5054
It only allows for collections within that database to be sharded.
5155
---
@@ -84,4 +88,7 @@ action:
8488
language: javascript
8589
code: |
8690
sh.shardCollection( "<database>.<collection>", { <shard key> : <direction> } )
91+
post: |
92+
.. include:: /includes/extracts/mongos-operations-wc-shard-collection.rst
93+
8794
...

source/reference/command/drop.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ drop
3636
- Optional. A document expressing the :doc:`write concern
3737
</reference/write-concern>` of the :dbcommand:`drop` command.
3838
Omit to use the default write concern.
39-
39+
40+
.. include:: /includes/extracts/mongos-operations-wc-drop.rst
4041

4142
The :binary:`~bin.mongo` shell provides the equivalent helper method
4243
:method:`db.collection.drop()`.
@@ -51,3 +52,6 @@ collection.
5152

5253
This command obtains a write lock on the affected database and
5354
will block other operations until it has completed.
55+
56+
57+

source/reference/command/dropDatabase.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ Definition
3939
</reference/write-concern>` of the :dbcommand:`drop` command.
4040
Omit to use the default write concern.
4141

42+
.. include:: /includes/extracts/mongos-operations-wc-drop-database.rst
43+
4244
The :binary:`~bin.mongo` shell also provides the helper method
4345
:method:`db.dropDatabase()`.
4446

@@ -50,10 +52,11 @@ Behavior
5052
.. include:: /includes/fact-drop-database-users.rst
5153

5254
.. versionchanged:: 3.6
53-
55+
5456
:dbcommand:`dropDatabase` waits until all collections drops in the
5557
database have propagated to a majority of the replica set members.
5658

59+
5760
Example
5861
-------
5962

source/reference/command/enableSharding.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ enableSharding
2626
To run :dbcommand:`enableSharding`, connect to a :binary:`~bin.mongos`
2727
instance and run the command in the ``admin`` database.
2828

29+
.. include:: /includes/extracts/mongos-operations-wc-enable-sharding.rst
30+
2931
:returns:
3032
A document that contains status of the operation.
3133

source/reference/command/movePrimary.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ operation, and such actions yield undefined behavior.
5656
:dbcommand:`movePrimary` may take significant time to complete, and
5757
you should plan for this unavailability.
5858

59+
.. include:: /includes/extracts/mongos-operations-wc-move-primary.rst
60+
5961
:dbcommand:`movePrimary` will fail if the destination shard contains a
6062
conflicting collection name. This may occur if documents are written to an
6163
un-sharded collection while the collection is moved away, and later the original

source/reference/command/removeShard.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ Chunk Balancing
5353

5454
.. include:: /includes/fact-remove-shard-balance-order.rst
5555

56+
Write Concern
57+
~~~~~~~~~~~~~
58+
59+
.. include:: /includes/extracts/mongos-operations-wc-remove-shard.rst
60+
5661
Example
5762
-------
5863

@@ -64,8 +69,8 @@ operation resembles the following:
6469
db.adminCommand( { removeShard : "bristol01" } )
6570

6671
Replace ``bristol01`` with the name of the shard to remove. When you
67-
run :dbcommand:`removeShard`, the command returns immediately,
68-
with a message that resembles the following:
72+
run :dbcommand:`removeShard`, the command returns with a message that
73+
resembles the following:
6974

7075
.. code-block:: javascript
7176

source/reference/command/shardCollection.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ Definition
3434
key: <shardkey>,
3535
unique: <boolean>,
3636
numInitialChunks: <integer>,
37-
collation: { locale: "simple" }
37+
collation: { locale: "simple" },
38+
writeConcern: <document>
3839
}
3940

4041
:dbcommand:`shardCollection` has the following fields:
@@ -89,6 +90,11 @@ See also :ref:`Sharded Collection and Unique Indexes
8990

9091
.. include:: /includes/fact-shardCollection-collation.rst
9192

93+
Write Concern
94+
~~~~~~~~~~~~~
95+
96+
.. include:: /includes/extracts/mongos-operations-wc-shard-collection.rst
97+
9298
Example
9399
-------
94100

source/reference/method/db.collection.drop.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ Definition
4949
:method:`db.collection.drop()` operation. Omit to use the
5050
default write concern.
5151

52+
.. include:: /includes/extracts/mongos-operations-wc-drop.rst
53+
5254
.. versionadded:: 4.0
5355

5456
:returns:
@@ -61,6 +63,7 @@ Behavior
6163
This method obtains a write lock on the affected database and
6264
will block other operations until it has completed.
6365

66+
6467
Example
6568
-------
6669

source/reference/method/db.createCollection.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ Definition
5252
indexOptionDefaults: <document>,
5353
viewOn: <string>,
5454
pipeline: <pipeline>,
55-
collation: <document> } )
55+
collation: <document>,
56+
writeConcern: <document>} )
5657

5758
The :method:`db.createCollection()` method has the following parameters:
5859

source/reference/method/db.dropDatabase.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ db.dropDatabase()
1313
Definition
1414
----------
1515

16-
.. method:: db.dropDatabase()
16+
.. method:: db.dropDatabase(<option>)
1717

1818
Removes the current database, deleting the associated data files.
1919

@@ -27,6 +27,8 @@ command.
2727

2828
.. include:: /includes/fact-drop-database-users.rst
2929

30+
.. include:: /includes/extracts/mongos-operations-wc-drop.rst
31+
3032
Example
3133
-------
3234

source/reference/method/sh.addShard.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,11 @@ Definition
3737
.. |mongodb-package| replace:: :binary:`~bin.mongos`
3838
.. include:: /includes/note-deb-and-rpm-default-to-localhost.rst
3939

40-
The :method:`sh.addShard()` method is a helper for the
41-
:dbcommand:`addShard` command.
42-
The :dbcommand:`addShard` command has additional options which are
43-
not available with this helper.
40+
.. include:: /includes/extracts/mongos-operations-wc-add-shard.rst
41+
42+
The :method:`sh.addShard()` method is a helper for the
43+
:dbcommand:`addShard` command. The :dbcommand:`addShard` command has
44+
additional options which are not available with this helper.
4445

4546
Considerations
4647
--------------

0 commit comments

Comments
 (0)