-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathdb.checkMetadataConsistency.txt
134 lines (95 loc) · 3.58 KB
/
db.checkMetadataConsistency.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
=============================
db.checkMetadataConsistency()
=============================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. method:: db.checkMetadataConsistency(options)
Performs a series of consistency checks on sharding metadata for the cluster
or database. This method returns a cursor with either all or a batch of
the inconsistency results found.
.. |dbcommand| replace:: :dbcommand:`checkMetadataConsistency` command
.. include:: /includes/fact-mongosh-shell-method-alt.rst
Run this method after major maintenance operations, such as upgrades and
downgrades, or to check if the cluster metadata is inconsistent or
corrupted due to bugs in previous releases of MongoDB.
.. include:: /includes/inconsistency-type/index-note
By default, the method checks sharding metadata for the given database.
If run on the ``admin`` database, it instead checks sharding metadata
for the entire cluster.
For more information on the inconsistencies this method searches for,
see :ref:`inconsistency-types`.
:returns: This method returns a cursor with a ``documents`` array,
which contains a document for each inconsistency found in
the sharding metadata.
Compatibility
-------------
This method is available in deployments hosted in the following environments:
.. include:: /includes/fact-environments-atlas-only.rst
.. include:: /includes/fact-environments-atlas-support-no-free.rst
.. include:: /includes/fact-environments-onprem-only.rst
.. include:: /includes/method/checkMetadataConsistency-execute-mongos.rst
Syntax
-------
The :method:`db.checkMetadataConsistency` method has the following syntax:
.. code-block:: javascript
db.checkMetadataConsistency( { <options> } )
The ``options`` document can take the following fields and values:
.. include:: /includes/inconsistency-type/checkMetadataConsistency-options.rst
Example
-------
Perform a Consistency Check on the Database
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To perform consistency checks on a database, call the
``db.checkMetadataConsistency()`` method:
.. io-code-block::
.. input::
:language: javascript
use library
db.checkMetadataConsistency()
.. output::
:language: json
{
cursorHasMore: false,
documents: [
{
type: "MisplacedCollection",
description: "Unsharded collection found on shard different from database primary shard",
details: {
namespace: "library.authors",
shard: "shard02",
localUUID: new UUID("1ad56770-61e2-48e9-83c6-8ecefe73cfc4")
}
}
],
}
Perform Consistency Checks on the Cluster
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To perform consistency checks on a cluster, call the
``db.checkMetadataConsistency()`` method from the ``admin`` database:
.. io-code-block::
.. input::
:language: javascript
use admin
db.checkMetadataConsistency()
.. output::
:language: json
{
cursorHasMore: false,
documents: [
{
type: "MisplacedCollection",
description: "Unsharded collection found on shard different from database primary shard",
details: {
namespace: "library.authors",
shard: "shard02",
localUUID: new UUID("1ad56770-61e2-48e9-83c6-8ecefe73cfc4")
}
}
],
}