Skip to content

Commit 061e247

Browse files
author
Sam Kleinman
committed
DOCS-162 first draft of current op docs
1 parent fa7529a commit 061e247

File tree

1 file changed

+219
-0
lines changed

1 file changed

+219
-0
lines changed

draft/reference/current-op.txt

Lines changed: 219 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
1+
===========================
2+
Current Operation Reporting
3+
===========================
4+
5+
.. default-domain:: mongodb
6+
7+
.. versionchanged:: 2.2
8+
9+
The :method:`db.currentOp()` helper in the :program:`mongo` shell
10+
reports on the current operations running on the :program:`mongod`
11+
instance. The command returns the ``inprog`` array which contains a
12+
document for each in progress operation. Consider the following
13+
example output:
14+
15+
.. code-block::
16+
17+
{
18+
"inprog": [
19+
{
20+
"opid" : 3434473,
21+
"active" : <boolean>,
22+
"secs_running" : 0,
23+
"op" : "<operation>",
24+
"ns" : "<database>.<collection>",
25+
"query" : {
26+
},
27+
"client" : "<host>:<outgoing>",
28+
"desc" : "conn57683",
29+
"threadId" : "0x7f04a637b700",
30+
"connectionId" : 57683,
31+
"locks" : {
32+
"^" : "w",
33+
"^local" : "W",
34+
"^<database>" : "W"
35+
},
36+
"waitingForLock" : false,
37+
"msg": "<string>"
38+
"numYields" : 0,
39+
"progress" : {
40+
"done" : <number>,
41+
"total" : <number>
42+
}
43+
"lockStats" : {
44+
"timeLockedMicros" : {
45+
"r" : NumberLong(),
46+
"w" : NumberLong()
47+
},
48+
"timeAcquiringMicros" : {
49+
"r" : NumberLong(),
50+
"w" : NumberLong()
51+
}
52+
}
53+
},
54+
]
55+
}
56+
57+
.. optional::
58+
59+
You may specify the ``true`` argument to :method:`db.currentOp()`
60+
to return full output. For example:
61+
62+
.. code-block:: javascript
63+
64+
db.currentOp(true)
65+
66+
Furthermore, active operations (i.e. where :data:`active` are
67+
``true``) will return additional fields.
68+
69+
Continue reading for full documentation of the entire output of
70+
:method:`db.currentOp()`.
71+
72+
Output Reference
73+
----------------
74+
75+
.. data:: opid
76+
77+
Holds an identifier for the operation. You can pass this value to
78+
:method:`db.killOp()` in the :program:`mongo` shell to terminate an
79+
operation.
80+
81+
.. data:: active
82+
83+
A boolean value, that reports if the option is currently running,
84+
with the ``true`` value, or queued and waiting for a lock to run,
85+
with the ``false`` value.
86+
87+
.. data:: secs_running
88+
89+
The duration of this operation in seconds.
90+
91+
.. data:: op
92+
93+
A string that identifies the type of operation. The possible values
94+
are:
95+
96+
- ``insert``
97+
- ``query``
98+
- ``update``
99+
- ``delete``
100+
- ``getmore``
101+
- ``command``
102+
103+
.. data:: ns
104+
105+
The :term:`namespace` that this operation targets. Namespaces are
106+
formed using the name of the :term:`database` and the name of the
107+
:term:`collection`.
108+
109+
.. data:: query
110+
111+
A document containing the current operation's query. This document
112+
is empty for operations that do not have queries: ``getmore``,
113+
``insert``, ``delete``, and ``command``.
114+
115+
.. data:: client
116+
117+
The IP address (or hostname) and the ephemeral port of the client
118+
connection where this operation originates. If your ``inprog``
119+
array has operations from many different clients, use this string
120+
to relate operations to clients.
121+
122+
.. data:: desc
123+
124+
A description of the client. This string includes the
125+
:data:`connectionId`.
126+
127+
.. data:: threadId
128+
129+
An identifier for the thread that services this operations and its
130+
connection.
131+
132+
.. data:: connectionId
133+
134+
An identifier for the connection where this operation originated.
135+
136+
.. data:: locks
137+
138+
The :data:`locks` document reports on the kinds of locks that this
139+
operation currently holds. The following lock types are possible:
140+
141+
.. data:: locks.^
142+
143+
:data:`locks.^` reports on the global lock state for the
144+
:program:`mongod` instance. The operation must hold this for
145+
some global phases of an operation.
146+
147+
.. data:: locks.^local
148+
149+
:data:`locks.^` reports on the lock for the ``local``
150+
database. MongoDB uses the ``local`` database for a number of
151+
operations, but the most frequent use of the ``local`` database
152+
is for the :term:`oplog` used in replication.
153+
154+
.. data:: locks.^<database>
155+
156+
:data:`locks.^<database>` reports on the lock state for the
157+
database that this operation targets.
158+
159+
.. data:: waitingForLock
160+
161+
Returns a boolean value. :data:`waitingForLock` is ``true`` if the
162+
operation is waiting for a lock and ``false`` if the operation has
163+
the locks that it needs to complete.
164+
165+
.. data:: msg
166+
167+
The :data:`msg` provides a message that describes the status and
168+
progress of the operation. In the case of indexing operations, this
169+
field reports the completion percentage.
170+
171+
.. data:: numYields
172+
173+
:data:`numYields` is a counter that reports the number of time that
174+
this operation has yielded to allow other operations to complete.
175+
176+
Typically, operations will yield when they need to access that that
177+
is not yet in memory while MongoDB pages in that data. This allows
178+
other operations that are already in memory, to complete quickly
179+
while MongoDB reads the data for the first operation into memory.
180+
181+
.. data:: lockStats
182+
183+
The :data:`lockStats` document reflects the amount of time that a
184+
this operation has spent both acquiring and holding
185+
locks. :data:`lockStats` reports data on a per-lock type, with the
186+
following possible lock types:
187+
188+
- ``r`` represents the database specific read lock and
189+
- ``w`` represents the database specific write lock.
190+
191+
.. data:: timeLockedMicros
192+
193+
The :data:`timeLockedMicros` document reports the amount of
194+
time this operation has spent holding specific locks.
195+
196+
.. data:: timeLockedMicros.r
197+
198+
Reports the amount of time that this operation has held the
199+
database specific read lock in microseconds.
200+
201+
.. data:: timeLockedMicros.w
202+
203+
Reports the amount of time that this operation has held the
204+
database specific write lock in microseconds.
205+
206+
.. data:: timeAquiringMicros
207+
208+
The :data:`timeLockedMicros` document reports the amount of time
209+
this operation has spent *waiting* to acquire a specific lock.
210+
211+
.. data:: timeAcquiringMicros.r
212+
213+
Reports the mount of time the operation has waited for the
214+
database specific read lock in microseconds.
215+
216+
.. data:: timeAcquiringMicros.w
217+
218+
Reports the mount of time the operation has waited for the
219+
database specific write lock in microseconds.

0 commit comments

Comments
 (0)