Skip to content

Commit 38c1001

Browse files
authored
(DOCS-15601): Remove maxSize field from addShard command (#2072)
* Remove maxSize and add note * Additional updates * tech review feedback * small updates * copy review feedback
1 parent 834c570 commit 38c1001

File tree

7 files changed

+34
-73
lines changed

7 files changed

+34
-73
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Starting in version 6.2, MongoDB removes the ``maxSize`` field
2+
from the :dbcommand:`addShard` command. As a result:
3+
4+
- Running :dbcommand:`addShard` with the ``maxSize`` field returns
5+
an ``InvalidOptions`` error.
6+
7+
- New documents in the :data:`~config.shards` collection no longer
8+
include the ``maxSize`` field.
9+
10+
- Any pre-existing ``maxSize`` field entries are ignored.

source/reference/audit-message.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,6 @@ associated ``param`` details and the ``result`` values, if any.
801801
{
802802
shard: <shard name>,
803803
connectionString: <hostname>:<port>,
804-
maxSize: <maxSize>
805804
}
806805

807806
When a shard is a replica set, the ``connectionString`` includes the

source/reference/command/addShard.txt

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,18 @@ The command has the following syntax:
3030
db.adminCommand(
3131
{
3232
addShard: "<replica_set>/<hostname><:port>",
33-
maxSize: <size>,
3433
name: "<shard_name>"
3534
}
3635
)
3736

3837
Command Fields
3938
~~~~~~~~~~~~~~
4039

41-
The command contains the following fields:
40+
.. note::
41+
42+
.. include:: /includes/fact-remove-maxSize-addShard.rst
4243

44+
The command contains the following fields:
4345

4446
.. list-table::
4547
:header-rows: 1
@@ -62,38 +64,18 @@ The command contains the following fields:
6264
.. code-block:: bash
6365

6466
<replica_set>/<hostname><:port>,<hostname><:port>, ...
65-
66-
67-
68-
* - ``maxSize``
69-
70-
- integer
71-
72-
- Optional. The maximum size in megabytes of the shard. If you set ``maxSize``
73-
to ``0``, MongoDB does not limit the size of the shard.
74-
75-
76-
67+
7768
* - ``name``
7869

7970
- string
8071

8172
- Optional. A name for the shard. If this is not specified, MongoDB
8273
automatically provides a unique name.
8374

84-
8575
The :dbcommand:`addShard` command stores shard configuration
8676
information in the :term:`config database`. Always run
8777
:dbcommand:`addShard` when using the ``admin`` database.
8878

89-
Specify a ``maxSize`` when you have machines with different disk
90-
capacities, or if you want to limit the amount of data on some
91-
shards. The ``maxSize`` constraint prevents the :term:`balancer`
92-
from migrating chunks to the shard when the ``totalSize`` returned
93-
from running :dbcommand:`listDatabases` on the shard exceeds the
94-
value of ``maxSize``.
95-
96-
9779
Considerations
9880
--------------
9981

source/reference/command/listShards.txt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ The following document is an example of the output from a
6464
{
6565
"_id": "shard03",
6666
"host": "shard03/host7:27018,host8:27018,host9:27018",
67-
"maxSize": NumberLong("1024"),
6867
"state": 1
6968
}
7069
],
@@ -110,13 +109,6 @@ Output
110109
* - ``tags``
111110
- A list of :term:`zones <zone>` to which the shard belongs.
112111

113-
* - ``maxSize``
114-
- The :ref:`configured <sharded-cluster-config-max-shard-size>`
115-
maximum storage size of the shard in megabytes. This includes
116-
all data files on the shard including the ``local`` and
117-
``admin`` databases. If exceeded, this shard will not receive
118-
any more chunks.
119-
120112
* - ``state``
121113
- An internal field used during the
122114
:doc:`/reference/command/addShard` sequence to ensure that all

source/release-notes/6.2-compatibility.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,8 @@ Compatibility Changes in MongoDB 6.2 (Release Candidate)
1616

1717
This page describes changes introduced in MongoDB 6.2 that can affect
1818
compatibility with older versions of MongoDB.
19+
20+
Removed Options
21+
---------------
22+
23+
.. include:: /includes/fact-remove-maxSize-addShard.rst

source/release-notes/6.2.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ Collection Validation Improvements
6969

7070
.. include:: /includes/validate-improvements-introduction.rst
7171

72+
Changes to Sharding
73+
~~~~~~~~~~~~~~~~~~~
74+
75+
.. include:: /includes/fact-remove-maxSize-addShard.rst
76+
7277
Server Parameters
7378
-----------------
7479

source/tutorial/manage-sharded-cluster-balancer.txt

Lines changed: 9 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -463,46 +463,14 @@ collection may block for a long period of time during the migration.
463463
Change the Maximum Storage Size for a Given Shard
464464
-------------------------------------------------
465465

466-
By default shards have no constraints in storage size. However, you can set a
467-
maximum storage size for a given shard in the sharded cluster. When
468-
selecting potential destination shards, the balancer ignores shards
469-
where a migration would exceed the configured maximum storage size.
466+
Changing a shard's maximum storage size is deprecated. Starting in
467+
version 4.2, MongoDB uses the :ref:`storage-wiredtiger` to manage
468+
how data is stored. WiredTiger compresses data to minimize storage
469+
use. To learn more, see :ref:`storage-wiredtiger-compression`.
470470

471-
The :data:`~config.shards` collection in the :ref:`config
472-
database<config-database>` stores configuration data related to shards.
471+
For MongoDB versions 6.1 and earlier, you can still set a
472+
maximum storage size for a given shard in the sharded cluster by
473+
using the ``maxSize`` field. You can find configuration
474+
data related to shards in the :data:`config.shards` collection.
473475

474-
.. code-block:: javascript
475-
476-
{ "_id" : "shard0000", "host" : "shard1.example.com:27100" }
477-
{ "_id" : "shard0001", "host" : "shard2.example.com:27200" }
478-
479-
To limit the storage size for a given shard, use the
480-
:method:`db.collection.updateOne()` method with the :update:`$set` operator to
481-
create the ``maxSize`` field and assign it an ``integer`` value. The
482-
``maxSize`` field represents the maximum storage size for the shard in
483-
``megabytes``.
484-
485-
The following operation sets a maximum size on a shard of ``1024 megabytes``:
486-
487-
.. code-block:: javascript
488-
489-
config = db.getSiblingDB("config")
490-
config.shards.updateOne( { "_id" : "<shard>"}, { $set : { "maxSize" : 1024 } } )
491-
492-
This value includes the mapped size of *all* data files on the
493-
shard, including the ``local`` and ``admin`` databases.
494-
495-
By default, ``maxSize`` is not specified, allowing shards to consume the
496-
total amount of available space on their machines if necessary.
497-
498-
You can also set ``maxSize`` when adding a shard.
499-
500-
To set ``maxSize`` when adding a shard, set the :dbcommand:`addShard`
501-
command's ``maxSize`` parameter to the maximum size in ``megabytes``. The
502-
following command run in the :binary:`~bin.mongosh` shell adds a shard
503-
with a maximum size of 125 megabytes:
504-
505-
.. code-block:: javascript
506-
507-
config = db.getSiblingDB("config")
508-
config.runCommand( { addshard : "example.net:34008", maxSize : 125 } )
476+
.. include:: /includes/fact-remove-maxSize-addShard.rst

0 commit comments

Comments
 (0)