Skip to content

Commit 51fc6c2

Browse files
authored
DOCSP-35385 v7.0 (#6352)
1 parent 9e1ab4a commit 51fc6c2

File tree

3 files changed

+65
-2
lines changed

3 files changed

+65
-2
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Starting in MongoDB 6.0.3, you can run an aggregation using the
2+
:pipeline:`$shardedDataDistribution` stage to confirm no orphaned
3+
documents remain:
4+
5+
.. code-block:: javascript
6+
7+
db.aggregate([
8+
{ $shardedDataDistribution: { } },
9+
{ $match: { "ns": "<database>.<collection>" } }
10+
])
11+
12+
``$shardedDataDistribution`` has output similar to the following:
13+
14+
.. include:: /includes/shardedDataDistribution-output-example.rst
15+
16+
Ensure that ``"numOrphanedDocs"`` is ``0`` for each shard in the
17+
cluster.
18+

source/reference/command/cleanupOrphaned.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ cleanupOrphaned
1010
:depth: 1
1111
:class: singlecol
1212

13+
.. important::
14+
15+
Starting in MongoDB 6.0.3, you should run an aggregation using the
16+
:pipeline:`$shardedDataDistribution` stage to confirm no orphaned
17+
documents remain. For details,
18+
see :ref:`shardedDataDistribution-no-orphaned-docs`.
19+
1320
Definition
1421
----------
1522

source/reference/operator/aggregation/shardedDataDistribution.txt

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,50 @@ following fields:
5151
Examples
5252
--------
5353

54+
Return All Sharded Data Distibution Metrics
55+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
56+
57+
To return all sharded data distribution metrics, run the following:
58+
5459
.. code-block:: javascript
5560

56-
db.aggregate( [
61+
db.aggregate([
5762
{ $shardedDataDistribution: { } }
58-
] )
63+
])
5964

6065
Example output:
6166

6267
.. include:: /includes/shardedDataDistribution-output-example.rst
68+
69+
Return Metrics for a Specific Shard
70+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
71+
72+
To return sharded data distribution metrics for a specific shard,
73+
run the following:
74+
75+
.. code-block:: javascript
76+
77+
db.aggregate([
78+
{ $shardedDataDistribution: { } },
79+
{ $match: { "shards.shardName": "<name of the shard>" } }
80+
])
81+
82+
Return Metrics for a Namespace
83+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
84+
85+
To return sharded data distribution data for a namespace, run the
86+
following:
87+
88+
.. code-block:: javascript
89+
90+
db.aggregate([
91+
{ $shardedDataDistribution: { } },
92+
{ $match: { "ns": "<database>.<collection>" } }
93+
])
94+
95+
.. _shardedDataDistribution-no-orphaned-docs:
96+
97+
Confirm No Orphaned Documents Remain
98+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
99+
100+
.. include:: /includes/shardedDataDistribution-orphaned-docs.rst

0 commit comments

Comments
 (0)