Skip to content

Commit 6301172

Browse files
DOCSP-46868-improve-docs-observability-stuck-index-builds (#10969)
* Clarify sentence instructing users to use instead of db.currentOp() * fix render * update the createIndex and db.currentOp page * reviewer update * reviewer updates * reviewer updates * rendering issue * aggregation stages fix * rendering code block * reviewer update * wording * reviewer updates * reviewer updates * .
1 parent ef1802b commit 6301172

File tree

5 files changed

+49
-36
lines changed

5 files changed

+49
-36
lines changed

source/core/indexes/create-index.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ about an active operation that builds a descending index on the ``name`` field:
9797
:language: javascript
9898

9999
db.getSiblingDB("admin").aggregate( [
100-
{ $currentOp : {} },
100+
{ $currentOp : { idleConnections: true } },
101101
{ $match : {"command.createIndexes": { $exists: true } } }
102102
] )
103103

@@ -158,6 +158,10 @@ about an active operation that builds a descending index on the ``name`` field:
158158
}, ...
159159
]
160160

161+
MongoDB marks index builds in various stages, including waiting on commit quorum, as an
162+
idle connection by setting the ``active`` field to ``false``. The ``idleConnections: true``
163+
setting includes these idle connections in the ``$currentOp`` output.
164+
161165
To view information on existing indexes using a driver, refer to your
162166
:driver:`driver's documentation </>`.
163167

source/core/sharding-reshard-a-collection.txt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -98,21 +98,21 @@ requirements:
9898
Once the resharding operation completes, you can remove the old shard
9999
key from the queries.
100100

101-
- No index builds are in progress. Use ``db.currentOp()`` to
102-
check for any running index builds:
101+
- No index builds are in progress. To check for running index builds,
102+
use ``$currentOp``:
103103

104104
.. code-block:: javascript
105-
:copyable: false
106-
107-
db.adminCommand(
108-
{
109-
currentOp: true,
110-
$or: [
111-
{ op: "command", "command.createIndexes": { $exists: true } },
112-
{ op: "none", "msg" : /^Index Build/ }
113-
]
105+
106+
db.getSiblingDB("admin").aggregate( [
107+
{ $currentOp : { idleConnections: true } },
108+
{ $match: {
109+
$or: [
110+
{ "op": "command", "command.createIndexes": { $exists: true } },
111+
{ "op": "none", "msg": /^Index Build/ }
112+
]
113+
}
114114
}
115-
)
115+
] )
116116

117117
In the result document, if the ``inprog`` field value is an empty
118118
array, there are no index builds in progress:
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
Use the :pipeline:`$currentOp` aggregation stage instead
2-
of the :dbcommand:`currentOp` command and its
1+
The :dbcommand:`currentOp` database command is deprecated
2+
since version 6.2. Use the :pipeline:`$currentOp` aggregation
3+
stage instead of the :dbcommand:`currentOp` command and its
34
:binary:`~bin.mongosh` helper method :method:`db.currentOp()`.

source/reference/command/currentOp.txt

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -217,15 +217,20 @@ The following example returns information on index creation operations:
217217

218218
.. code-block:: javascript
219219

220-
db.adminCommand(
221-
{
222-
currentOp: true,
223-
$or: [
224-
{ op: "command", "command.createIndexes": { $exists: true } },
225-
{ op: "none", "msg" : /^Index Build/ }
226-
]
227-
}
228-
)
220+
db.getSiblingDB("admin").aggregate( [
221+
{ $currentOp : { idleConnections: true } },
222+
{ $match: {
223+
$or: [
224+
{ "op": "command", "command.createIndexes": { $exists: true } },
225+
{ "op": "none", "msg": /^Index Build/ }
226+
]
227+
}
228+
}
229+
] )
230+
231+
MongoDB marks index builds waiting on commit quorum to complete the operation as an
232+
idle connection by setting the ``active`` field to ``false``. The ``idleConnections: true``
233+
setting includes these idle connections in the ``$currentOp`` output.
229234

230235
Output Example
231236
--------------

source/reference/method/db.currentOp.txt

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@ Definition
1919

2020
.. |operation| replace:: :method:`db.currentOp()`
2121

22+
.. important::
23+
24+
.. include:: /includes/fact-currentOp-aggregation-stage.rst
25+
2226
Returns a :term:`document` that contains information on in-progress
2327
operations for the database instance. The :method:`db.currentOp()`
2428
method wraps the database command :dbcommand:`currentOp`.
2529

26-
.. include:: /includes/fact-currentOp-aggregation-stage.rst
27-
2830
.. note::
2931

3032
.. include:: /includes/5.0-fact-currentop.rst
@@ -108,6 +110,7 @@ filter. The filter document can contain:
108110
* - ``"$all"``
109111
- Boolean. If set to ``true``, returns information on all operations,
110112
including operations on idle connections and system operations.
113+
For more information, see :ref:`<current-op-agg>`.
111114

112115
If the document includes ``"$all": true`` along with
113116
:ref:`db.currentOp-output-fields` conditions, only the
@@ -224,16 +227,16 @@ on any number of fields:
224227

225228
.. code-block:: javascript
226229

227-
db.adminCommand(
228-
{
229-
currentOp: true,
230-
$or: [
231-
{ op: "command", "command.createIndexes": { $exists: true } },
232-
{ op: "command", "command.$truncated": /^\{ createIndexes/ },
233-
{ op: "none", "msg" : /^Index Build/ }
234-
]
235-
}
236-
)
230+
db.getSiblingDB("admin").aggregate( [
231+
{ $currentOp : { idleConnections: true } },
232+
{ $match: {
233+
$or: [
234+
{ "op": "command", "command.createIndexes": { $exists: true } },
235+
{ "op": "none", "msg": /^Index Build/ }
236+
]
237+
}
238+
}
239+
] )
237240

238241
Output Example
239242
--------------

0 commit comments

Comments
 (0)