currentOp

Definition

  • currentOp
  • Returns a document that contains information on in-progressoperations for the mongod instance.

currentOp has the following form:

  1. { currentOp: 1 }

The mongo shell provides the db.currentOp()wrapper for the currentOp command.

Note

Because currentOp command anddb.currentOp() helper returns the results in a singledocument, the total size of the currentOp result setis subject to the maximum 16MB BSON size limit for documents.

Starting in version 3.6, MongoDB provides $currentOpaggregation stage. The $currentOp stage returns acursor over a stream of documents, each of which reports a singleoperation. Each operation document is subject to the 16MB BSONlimit, but unlike the currentOp command, there is nolimit on the overall size of the result set.

For this reason, the $currentOp aggregation stage ispreferred over the currentOp command and itsmongo shell helper db.currentOp().

Behavior

currentOp must run against the admin database, andit can accept several optional fields.

FieldDescription
"$ownOps"Boolean. If set to true, returns information on the current user’soperations only.On mongod instances, users are always authorized to runcurrentOp with "$ownOps": true to view their ownoperations. See access control.New in version 3.2.9.
"$all"Boolean. If set to true, returns information on all operations,including operations on idle connections and system operations."$all": true overrides any output field filters.
<filter>Specify filter conditions on the Output Fields.See Examples.

currentOp and thedatabase profiler report the samebasic diagnostic information for all CRUD operations, including thefollowing:

These operations are also included in the logging ofslow queries (see slowOpThresholdMs formore information about slow query logging).

Access Control

On systems running with authorization, the usermust have access that includes the inprog privilegeaction.

Changed in version 3.2.9: On mongod instances, users can use $ownOpsto view their own operations without theinprog privilege action.

  1. db.adminCommand( { currentOp: 1, "$ownOps": 1 } )

See also

Create a Role to Manage Current Operations

Examples

The following examples use the currentOp command withvarious query documents to filter the output.

Display All Current Operations

  1. db.adminCommand(
  2. {
  3. currentOp: true,
  4. "$all": true
  5. }
  6. )

Write Operations Waiting for a Lock

The following example returns information on all write operations thatare waiting for a lock:

  1. db.adminCommand(
  2. {
  3. currentOp: true,
  4. "waitingForLock" : true,
  5. $or: [
  6. { "op" : { "$in" : [ "insert", "update", "remove" ] } },
  7. { "query.findandmodify": { $exists: true } }
  8. ]
  9. }
  10. )

Active Operations with no Yields

The following example returns information on all active runningoperations that have never yielded:

  1. db.adminCommand(
  2. {
  3. currentOp: true,
  4. "active" : true,
  5. "numYields" : 0,
  6. "waitingForLock" : false
  7. }
  8. )

Active Operations on a Specific Database

The following example returns information on all active operations fordatabase db1 that have been running longer than 3 seconds:

  1. db.adminCommand(
  2. {
  3. currentOp: true,
  4. "active" : true,
  5. "secs_running" : { "$gt" : 3 },
  6. "ns" : /^db1\./
  7. }
  8. )

Active Indexing Operations

The following example returns information on index creation operations:

  1. db.adminCommand(
  2. {
  3. currentOp: true,
  4. $or: [
  5. { op: "command", "query.createIndexes": { $exists: true } },
  6. { op: "none", ns: /\.system\.indexes\b/ }
  7. ]
  8. }
  9. )

Output Example

  • Standalone
  • Replica Set (Primary)
  • Sharded Cluster (mongos)

The following is a prototype of the currentOpoutput when run on a standalone:

Changed in version 4.2.

  1. {
  2. "inprog": [
  3. {
  4. "type" : <string>,
  5. "host" : <string>,
  6. "desc" : <string>,
  7. "connectionId" : <number>,
  8. "client" : <string>,
  9. "appName" : <string>,
  10. "clientMetadata" : <document>,
  11. "active" : <boolean>,
  12. "currentOpTime" : <string>,
  13. "effectiveUsers" : [
  14. {
  15. "user" : <string>,
  16. "db" : <string>
  17. }
  18. ],
  19. "opid" : <number>,
  20. "lsid" : {
  21. "id" : <UUID>,
  22. "uid" : <BinData>
  23. },
  24. "secs_running" : <NumberLong()>,
  25. "microsecs_running" : <number>,
  26. "op" : <string>,
  27. "ns" : <string>,
  28. "command" : <document>,
  29. "planSummary": <string>,
  30. "cursor" : { // only for getMore operations
  31. "cursorId" : <NumberLong()>,
  32. "createdDate" : <ISODate()>,
  33. "lastAccessDate" : <ISODate()>,
  34. "nDocsReturned" : <NumberLong()>,
  35. "nBatchesReturned" : <NumberLong()>,
  36. "noCursorTimeout" : <boolean>,
  37. "tailable" : <boolean>,
  38. "awaitData" : <boolean>,
  39. "originatingCommand" : <document>,
  40. "planSummary" : <string>,
  41. "operationUsingCursorId" : <NumberLong()>
  42. },
  43. "msg": <string>,
  44. "progress" : {
  45. "done" : <number>,
  46. "total" : <number>
  47. },
  48. "killPending" : <boolean>,
  49. "numYields" : <number>,
  50. "locks" : {
  51. "ParallelBatchWriterMode" : <string>,
  52. "ReplicationStateTransition" : <string>,
  53. "Global" : <string>,
  54. "Database" : <string>,
  55. "Collection" : <string>,
  56. "Metadata" : <string>,
  57. "oplog" : <string>
  58. },
  59. "waitingForLock" : <boolean>,
  60. "lockStats" : {
  61. "ParallelBatchWriterMode" : {
  62. "acquireCount": {
  63. "r": <NumberLong>,
  64. "w": <NumberLong>,
  65. "R": <NumberLong>,
  66. "W": <NumberLong>
  67. },
  68. "acquireWaitCount": {
  69. "r": <NumberLong>,
  70. "w": <NumberLong>,
  71. "R": <NumberLong>,
  72. "W": <NumberLong>
  73. },
  74. "timeAcquiringMicros" : {
  75. "r" : NumberLong(0),
  76. "w" : NumberLong(0),
  77. "R" : NumberLong(0),
  78. "W" : NumberLong(0)
  79. },
  80. "deadlockCount" : {
  81. "r" : NumberLong(0),
  82. "w" : NumberLong(0),
  83. "R" : NumberLong(0),
  84. "W" : NumberLong(0)
  85. }
  86. },
  87. "ReplicationStateTransition" : {
  88. ...
  89. },
  90. "Global": {
  91. ...
  92. },
  93. "Database" : {
  94. ...
  95. },
  96. ...
  97. }
  98. },
  99. ...
  100. ],
  101. "fsyncLock": <boolean>,
  102. "info": <string>,
  103. "ok": <num>
  104. }

The following is a prototype of the currentOpoutput when run on a primary of a replica set:

Changed in version 4.2.

  1. {
  2. "inprog": [
  3. {
  4. "type" : <string>,
  5. "host" : <string>,
  6. "desc" : <string>,
  7. "connectionId" : <number>,
  8. "client" : <string>,
  9. "appName" : <string>,
  10. "clientMetadata" : <document>,
  11. "lsid" : {
  12. "id" : <UUID>,
  13. "uid" : <BinData>
  14. },
  15. "transaction" : {
  16. "parameters" : {
  17. "txnNumber" : <NumberLong()>,
  18. "autocommit" : <boolean>,
  19. "readConcern" : {
  20. "level" : <string>
  21. }
  22. },
  23. "readTimestamp" : <Timestamp>,
  24. "startWallClockTime" : <string>,
  25. "timeOpenMicros" : <NumberLong()>,
  26. "timeActiveMicros" : <NumberLong()>,
  27. "timeInactiveMicros" : <NumberLong()>,
  28. "expiryTime" : <string>,
  29. },
  30. "active" : <boolean>,
  31. "currentOpTime" : <string>,
  32. "effectiveUsers" : [
  33. {
  34. "user" : <string>,
  35. "db" : <string>
  36. }
  37. ],
  38. "opid" : <number>,
  39. "secs_running" : <NumberLong()>,
  40. "microsecs_running" : <number>,
  41. "op" : <string>,
  42. "ns" : <string>,
  43. "command" : <document>,
  44. "originatingCommand" : <document>,
  45. "planSummary": <string>,
  46. "prepareReadConflicts" : <NumberLong()>,
  47. "writeConflicts" : <NumberLong()>,
  48. "cursor" : { // only for getMore operations
  49. "cursorId" : <NumberLong()>,
  50. "createdDate" : <ISODate()>,
  51. "lastAccessDate" : <ISODate()>,
  52. "nDocsReturned" : <NumberLong()>,
  53. "nBatchesReturned" : <NumberLong()>,
  54. "noCursorTimeout" : <boolean>,
  55. "tailable" : <boolean>,
  56. "awaitData" : <boolean>,
  57. "originatingCommand" : <document>,
  58. "planSummary" : <string>,
  59. "operationUsingCursorId" : <NumberLong()>
  60. },
  61. "msg": <string>,
  62. "progress" : {
  63. "done" : <number>,
  64. "total" : <number>
  65. },
  66. "killPending" : <boolean>,
  67. "numYields" : <number>,
  68. "locks" : {
  69. "ParallelBatchWriterMode" : <string>,
  70. "ReplicationStateTransition" : <string>,
  71. "Global" : <string>,
  72. "Database" : <string>,
  73. "Collection" : <string>,
  74. "Metadata" : <string>,
  75. "oplog" : <string>
  76. },
  77. "waitingForLock" : <boolean>,
  78. "lockStats" : {
  79. "ParallelBatchWriterMode" : {
  80. "acquireCount": {
  81. "r": <NumberLong>,
  82. "w": <NumberLong>,
  83. "R": <NumberLong>,
  84. "W": <NumberLong>
  85. },
  86. "acquireWaitCount": {
  87. "r": <NumberLong>,
  88. "w": <NumberLong>,
  89. "R": <NumberLong>,
  90. "W": <NumberLong>
  91. },
  92. "timeAcquiringMicros" : {
  93. "r" : NumberLong(0),
  94. "w" : NumberLong(0),
  95. "R" : NumberLong(0),
  96. "W" : NumberLong(0)
  97. },
  98. "deadlockCount" : {
  99. "r" : NumberLong(0),
  100. "w" : NumberLong(0),
  101. "R" : NumberLong(0),
  102. "W" : NumberLong(0)
  103. }
  104. },
  105. "ReplicationStateTransition" : {
  106. ...
  107. },
  108. "Global" : {
  109. ...
  110. },
  111. "Database" : {
  112. ...
  113. },
  114. ...
  115. }
  116. },
  117. ...
  118. ],
  119. "fsyncLock": <boolean>,
  120. "info": <string>,
  121. "ok": <num>,
  122. "operationTime": <timestamp>,
  123. "$clusterTime": <document>
  124. }

The following is an example of the currentOpoutput when run on a mongos of a shardedcluster (Fields may vary depending on the operation beingreported):

Changed in version 4.2.

  1. {
  2. "inprog": [
  3. {
  4. "shard": <string>,
  5. "type" : <string>,
  6. "host" : <string>,
  7. "desc" : <string>,
  8. "connectionId" : <number>,
  9. "client_s" : <string>,
  10. "appName" : <string>,
  11. "clientMetadata" : <document>,
  12. "lsid" : {
  13. "id" : <UUID>,
  14. "uid" : <BinData>
  15. },
  16. "transaction" : {
  17. "parameters" : {
  18. "txnNumber" : <NumberLong()>,
  19. "autocommit" : <boolean>,
  20. "readConcern" : {
  21. "level" : <string>
  22. }
  23. },
  24. "readTimestamp" : <Timestamp>,
  25. "startWallClockTime" : <string>,
  26. "timeOpenMicros" : <NumberLong()>,
  27. "timeActiveMicros" : <NumberLong()>,
  28. "timeInactiveMicros" : <NumberLong()>,
  29. "expiryTime" : <string>,
  30. },
  31. "active" : <boolean>,
  32. "currentOpTime" : <string>,
  33. "effectiveUsers" : [
  34. {
  35. "user" : <string>,
  36. "db" : <string>
  37. }
  38. ],
  39. "runBy" : [
  40. {
  41. "user" : <string>,
  42. "db" : <string>
  43. }
  44. ],
  45. "twoPhaseCommitCoordinator" : { // Starting in 4.2.1
  46. "lsid" : {
  47. "id" : <UUID>,
  48. "uid" : <BinData>
  49. },
  50. "txnNumber" : <NumberLong>,
  51. "numParticipants" : <NumberLong>,
  52. "state" : <string>,
  53. "commitStartTime" : <ISODate>,
  54. "hasRecoveredFromFailover" : <boolean>,
  55. "stepDurations" : <document>,
  56. "decision" : <document>,
  57. "deadline" : <ISODate>
  58. }
  59. "opid" : <string>,
  60. "secs_running" : <NumberLong()>,
  61. "microsecs_running" : <number>,
  62. "op" : <string>,
  63. "ns" : <string>,
  64. "command" : <document>,
  65. "planSummary": <string>,
  66. "prepareReadConflicts" : <NumberLong()>,
  67. "writeConflicts" : <NumberLong()>,
  68. "cursor" : { // only for getMore operations
  69. "cursorId" : <NumberLong()>,
  70. "createdDate" : <ISODate()>,
  71. "lastAccessDate" : <ISODate()>,
  72. "nDocsReturned" : <NumberLong()>,
  73. "nBatchesReturned" : <NumberLong()>,
  74. "noCursorTimeout" : <boolean>,
  75. "tailable" : <boolean>,
  76. "awaitData" : <boolean>,
  77. "originatingCommand" : <document>,
  78. "planSummary" : <string>,
  79. "operationUsingCursorId" : <NumberLong()>
  80. },
  81. "msg": <string>,
  82. "progress" : {
  83. "done" : <number>,
  84. "total" : <number>
  85. },
  86. "killPending" : <boolean>,
  87. "numYields" : <number>,
  88. "locks" : {
  89. "ParallelBatchWriterMode" : <string>,
  90. "ReplicationStateTransition" : <string>,
  91. "Global" : <string>,
  92. "Database" : <string>,
  93. "Collection" : <string>,
  94. "Metadata" : <string>,
  95. "oplog" : <string>
  96. },
  97. "waitingForLock" : <boolean>,
  98. "lockStats" : {
  99. "ParallelBatchWriterMode": {
  100. "acquireCount": {
  101. "r": <NumberLong>,
  102. "w": <NumberLong>,
  103. "R": <NumberLong>,
  104. "W": <NumberLong>
  105. },
  106. "acquireWaitCount": {
  107. "r": <NumberLong>,
  108. "w": <NumberLong>,
  109. "R": <NumberLong>,
  110. "W": <NumberLong>
  111. },
  112. "timeAcquiringMicros" : {
  113. "r" : NumberLong(0),
  114. "w" : NumberLong(0),
  115. "R" : NumberLong(0),
  116. "W" : NumberLong(0)
  117. },
  118. "deadlockCount" : {
  119. "r" : NumberLong(0),
  120. "w" : NumberLong(0),
  121. "R" : NumberLong(0),
  122. "W" : NumberLong(0)
  123. }
  124. },
  125. "ReplicationStateTransition" : {
  126. ...
  127. },
  128. "Global" : {
  129. ...
  130. },
  131. "Database" : {
  132. ...
  133. },
  134. ...
  135. }
  136. },
  137. ...
  138. ],
  139. "ok": <num>,
  140. "operationTime": <timestamp>,
  141. "$clusterTime": <document>
  142. }

Output Fields

  • currentOp.type

New in version 4.2.

The type of operation. Values are either:

  • currentOp.host
  • The name of the host against which the operation is run.
  • currentOp.desc
  • A description of the client. This string includes theconnectionId.
  • currentOp.connectionId
  • An identifier for the connection where the operation originated.
  • currentOp.client
  • A string with information about where the operation originated.

For multi-document transactions, client storesinformation about the most recent client to run an operation insidethe transaction.

  • currentOp.appName
  • A string with information about the type of client which made therequest.
  • currentOp.clientMetadata
  • Additional information on the client.

For multi-document transactions, client storesinformation about the most recent client to run an operation insidethe transaction.

  • currentOp.currentOpTime
  • The start time of the operation.

New in version 3.6.

  • currentOp.effectiveUsers
  • An array that contains a document for each user associated with theoperation. Each user document contains the user name and theauthentication db.

See also

currentOp.runBy

New in version 4.2.

  • currentOp.runBy
  • An array that contains a document for each user who is impersonatingthe effectiveUser(s) for theoperation. The runBy document contains the user nameand the authentication db. In general, the runBy user isthe __system user; e.g.
  1. "runBy" : [
  2. {
  3. "user" : "__system",
  4. "db" : "local"
  5. }
  6. ]

Only available on sharded clusters

New in version 4.2.

  • currentOp.lsid
  • The session identifier.

Only present if the operation is associated with asession.

New in version 3.6.

Only present if the operation is part of a multi-document transaction.

New in version 4.0.

  • currentOp.transaction.parameters
  • A document that contains information on multi-documenttransaction.

Only present if the operation is part of a multi-documenttransaction.

New in version 4.0.

  1. - <code>currentOp.transaction.parameters.</code><code>txnNumber</code>[]($da8d189bb5cc60f2.md#currentOp.transaction.parameters.txnNumber)
  2. -

The transaction number.

Only present if the operation is part of a multi-document transaction.

New in version 4.0.

  1. - <code>currentOp.transaction.parameters.</code><code>autocommit</code>[]($da8d189bb5cc60f2.md#currentOp.transaction.parameters.autocommit)
  2. -

A boolean flag that indicates if autocommit is on for thetransaction.

Only present if the operation is part of a multi-document transaction.

New in version 4.0.2.

  1. - <code>currentOp.transaction.parameters.</code><code>readConcern</code>[]($da8d189bb5cc60f2.md#currentOp.transaction.parameters.readConcern)
  2. -

The read concern for thetransaction.

Multi-document transactions support read concern"snapshot", "local", and"majority".

Only present if the operation is part of a multi-document transaction.

New in version 4.0.2.

  1. - <code>currentOp.transaction.</code><code>readTimestamp</code>[]($da8d189bb5cc60f2.md#currentOp.transaction.readTimestamp)
  2. -

The timestamp of the snapshot being read by the operations inthe transaction.

Only present if the operation is part of a multi-document transaction.

New in version 4.0.2.

  1. - <code>currentOp.transaction.</code><code>startWallClockTime</code>[]($da8d189bb5cc60f2.md#currentOp.transaction.startWallClockTime)
  2. -

The date and time (with time zone) of the transaction start.

Only present if the operation is part of a multi-document transaction.

New in version 4.0.2.

  1. - <code>currentOp.transaction.</code><code>timeOpenMicros</code>[]($da8d189bb5cc60f2.md#currentOp.transaction.timeOpenMicros)
  2. -

The duration of the transaction in microseconds.

The timeActiveMicrosvalue added to thetimeInactiveMicrosshould equal thetimeOpenMicros.

Only present if the operation is part of a multi-document transaction.

New in version 4.0.2.

  1. - <code>currentOp.transaction.</code><code>timeActiveMicros</code>[]($da8d189bb5cc60f2.md#currentOp.transaction.timeActiveMicros)
  2. -

The total amount of time that the transaction has been active;i.e. when the transaction had operations running.

ThetimeActiveMicrosvalue added to thetimeInactiveMicrosshould equal thetimeOpenMicros.

Only present if the operation is part of a multi-document transaction.

New in version 4.0.2.

  1. - <code>currentOp.transaction.</code><code>timeInactiveMicros</code>[]($da8d189bb5cc60f2.md#currentOp.transaction.timeInactiveMicros)
  2. -

The total amount of time that the transaction has beeninactive; i.e. when the transaction had no operations running.

ThetimeInactiveMicrosvalue added to thetimeActiveMicrosshould equal thetimeOpenMicros.

Only present if the operation is part of a multi-document transaction.

  1. - <code>currentOp.transaction.</code><code>expiryTime</code>[]($da8d189bb5cc60f2.md#currentOp.transaction.expiryTime)
  2. -

The date and time (with time zone) when the transaction willtime out and abort.

The currentOp.transaction.expiryTime equals thecurrentOp.transaction.startWallClockTime + thetransactionLifetimeLimitSeconds.

For more information, seee Runtime Limit fortransactions.

Only present if the operation is part of a multi-document transaction.

New in version 4.0.2.

Commit coordination is handled by a shard, andcurrentOp (run either on a mongos or ashard member) returns a shard’s coordination information only forthose transactions currently being coordinated by that shard.

To filter for just the commit coordination metrics:

  1. db.currentOp( { desc: "transaction coordinator" })
  • A specific commit coordination operation (i.e.currentOp.type is op and currentOp.desc is"TransactionCoordinator") spawned by the transactioncoordinator.

New in version 4.2.1.

  • currentOp.twoPhaseCommitCoordinator.lsid
  • The session identifier for the multi-shard transaction.

The combination of thelsid andtxnNumber identifiesthe transaction.

Available for both the commit coordination metrics and for specificcoordination operation.

New in version 4.2.1.

  • currentOp.twoPhaseCommitCoordinator.txnNumber
  • The transaction number for the multi-shard transaction.

The combination of thetxnNumber andlsid identifies thetransaction.

Available for both the commit coordination metrics and for specificcoordination operation.

New in version 4.2.1.

  • currentOp.twoPhaseCommitCoordinator.action
  • The specific commit coordination operation spawned by thetransaction coordinator:

    • "sendingPrepare"
    • "sendingCommit"
    • "sendingAbort"
    • "writingParticipantList"
    • "writingDecision"
    • "deletingCoordinatorDoc"Only available for specific coordination operation.
  • currentOp.twoPhaseCommitCoordinator.startTime

  • The start date and time of theaction.

Only available for specific coordination operation.

New in version 4.2.1.

  • currentOp.twoPhaseCommitCoordinator.numParticipants
  • Number of shards participating in this commit.

Only available for the commit coordination metrics.

New in version 4.2.1.

  • currentOp.twoPhaseCommitCoordinator.state
  • The current step/state of the commit coordination process.

Step/stageDescriptioninactiveNot actively part of a commit.writingParticipantListWriting a local record of the list of shards that are partof this multi-shard transaction.waitingForVotesWaiting for the participants to respond with vote to commit or abort.writingDecisionWriting a local record of the coordinator’s decision to commit orabort based on votes.waitingForDecisionAckWaiting for participants to acknowledge the coordinator’sdecision to commit or abort.deletingCoordinatorDocDeleting the local record of commit decision.

Only available for the commit coordination metrics.

See alsocurrentOp.twoPhaseCommitCoordinator.stepDurations.

New in version 4.2.1.

  • currentOp.twoPhaseCommitCoordinator.commitStartTime
  • The date and time when the commit started.

Only available for the commit coordination metrics.

New in version 4.2.1.

  • currentOp.twoPhaseCommitCoordinator.hasRecoveredFromFailover
  • A boolean that indicates whether the commit coordination wasrestarted due to failover on the shard that is coordinating thecommit.

IfhasRecoveredFromFailoveris true, then the times specified incurrentOp.twoPhaseCommitCoordinator.stepDurations may notbe accurate for all steps.

Only available for the commit coordination metrics.

New in version 4.2.1.

  • currentOp.twoPhaseCommitCoordinator.stepDurations
  • A document that contains the duration, in microseconds, of thecommit coordination steps/state completed or inprogress:
  1. "stepDurations" : {
  2. "writingParticipantListMicros" : NumberLong(17801),
  3. "totalCommitDurationMicros" : NumberLong(42488463),
  4. "waitingForVotesMicros" : NumberLong(30378502),
  5. "writingDecisionMicros" : NumberLong(15015),
  6. "waitingForDecisionAcksMicros" : NumberLong(12077145),
  7. "deletingCoordinatorDocMicros" : NumberLong(6009)
  8. },

IfcurrentOp.twoPhaseCommitCoordinator.hasRecoveredFromFailoveris true, then the times specified instepDurations may notbe accurate for all steps.

For a coordinator in an inactive state, the document is empty:

  1. "stepDurations" : {
  2. }

Only available for the commit coordination metrics.

See currentOp.twoPhaseCommitCoordinator.state.

New in version 4.2.1.

  • currentOp.twoPhaseCommitCoordinator.decision
  • A document that contains the commit/abort decision, for example:

    • For a commmit decision:
  1. "decision" : {
  2. "decision" : "commit",
  3. "commitTimestamp" : Timestamp(1572034669, 3)
  4. }
  1. -

For an abort decision:

  1. "decision" : {
  2. "decision" : "abort",
  3. "abortStatus" : {
  4. "code" : 282,
  5. "codeName" : "TransactionCoordinatorReachedAbortDecision",
  6. "errmsg" : "Transaction exceeded deadline"
  7. }
  8. }

Only available for the commit coordination metrics.

New in version 4.2.1.

  • currentOp.twoPhaseCommitCoordinator.deadline
  • The date and time by which the commit must finish.

Only available for the commit coordination metrics.

New in version 4.2.1.

  • currentOp.opid
  • The identifier for the operation. You can pass this value todb.killOp() in the mongo shell to terminate theoperation.

Warning

Terminate running operations with extreme caution. Only usedb.killOp() to terminate operations initiated by clientsand do not terminate internal database operations.

  • currentOp.active
  • A boolean value specifying whether the operation has started. Valueis true if the operation has started or false if theoperation is idle, such as an idle connection or an internal threadthat is currently idle. An operation can be active even if theoperation has yielded to another operation.

Changed in version 3.0: For some inactive background threads, such as an inactivesignalProcessingThread, MongoDB suppresses various emptyfields.

  • currentOp.secs_running
  • The duration of the operation in seconds. MongoDB calculates thisvalue by subtracting the current time from the start time of theoperation.

Only appears if the operation is running; i.e. ifactive is true.

  • currentOp.microsecs_running
  • The duration of the operation in microseconds. MongoDB calculates thisvalue by subtracting the current time from the start time of theoperation.

Only appears if the operation is running; i.e. ifactive is true.

  • currentOp.op
  • A string that identifies the specific operation type. Only presentif currentOp.type is op.

The possible values are:

  • "none"
  • "update"
  • "insert"
  • "query"
  • "command"
  • "getmore"
  • "remove"
  • "killcursors""query" operations include read operations.

"command" operations include mostcommands such as thecreateIndexes and findandmodify.

Changed in version 3.0: Write operations that use the insert,update, and delete commandsrespectively display "insert", "update", and "remove"for op. Previous versions include these writecommands under "query" operations.

Changed in version 3.2: Most commands includingcreateIndexes and findandmodify display"command" for op. Previous versions ofMongoDB included these commands under "query" operations.

  • currentOp.ns
  • The namespace the operation targets. A namespace consists ofthe database name and the collection nameconcatenated with a dot (.); that is,"<database>.<collection>".
  • currentOp.command

Changed in version 3.6.

A document containing the full command object associated with thisoperation.

For example, the following output contains the command object for afind operation on a collection named items in adatabase named test:

  1. "command" : {
  2. "find" : "items",
  3. "filter" : {
  4. "sku" : 1403978
  5. },
  6. ...
  7. "$db" : "test"
  8. }

The following example output contains the command object for agetMore operation generated bya command with cursor id 19234103609 on a collection nameditems in a database named test:

  1. "command" : {
  2. "getMore" : NumberLong("19234103609"),
  3. "collection" : "items",
  4. "batchSize" : 10,
  5. ...
  6. "$db" : "test"
  7. },

If the command document exceeds 1 kilobyte, thedocument has the following form:

  1. "command" : {
  2. "$truncated": <string>,
  3. "comment": <string>
  4. }

The $truncated field contains a string summary of the document excludingthe document’s comment field if present. If the summary still exceeds1 kilobyte then it is further truncated, denoted by an ellipsis(…) at the end of the string.

The comment field is present if a comment was passed to the operation.

  • currentOp.planSummary
  • Specifies whether the cursor uses a collection scan(COLLSCAN) or an index scan (IXSCAN { … }).

The IXSCAN also includes the specification document of the indexused.

  • currentOp.prepareReadConflicts
  • The number of times the current operation had to wait for aprepared transaction with a write to commit or abort.

While waiting, the current operation continues to hold any necessarylocks and storage engine resources.

New in version 4.2.

  • currentOp.writeConflicts
  • The number of times the current operation conflicted withanother write operation on the same document.

New in version 4.2.

  • currentOp.cursor

New in version 4.2.

A document that contains the cursor information for getmoreoperations; i.e. where op is getmore.

If reporting on a getmore operation before the getmore hasaccessed its cursor information, the cursor fieldis not available.

  • currentOp.cursor.cursorId

New in version 4.2.

The id of the cursor.

  • currentOp.cursor.createdDate

New in version 4.2.

The date and time when the cursor was created.

  • currentOp.cursor.lastAccessDate

New in version 4.2.

The date and time when the cursor was last used.

  • currentOp.cursor.nDocsReturned

New in version 4.2.

The cumulative number of documents returned by the cursor.

  • currentOp.cursor.nBatchesReturned

New in version 4.2.

The curmulative number of batches returned by the cursor.

  • currentOp.cursor.noCursorTimeout

New in version 4.2.

The flag that indicates that the cursor will not timeout when idle;i.e. if the cursor has the noTimeout option set.

  1. - If true, the cursor does not time out when idle.
  2. - If false, the cursor will time out when idle.

See also

cursor.addOption()

  • currentOp.cursor.tailable

New in version 4.2.

The flag that indicates if the cursor is a tailable cursor for a capped collection. Tailable cursorsremain open after the client exhausts the results in the initialcursor.

See also

  1. - [<code>find</code>]($b880d3668448c2e5.md#dbcmd.find)
  2. - [<code>cursor.tailable()</code>]($d047cc6a3717a527.md#cursor.tailable)
  3. - [<code>cursor.addOption()</code>]($fb45b4e29bd8bcf4.md#cursor.addOption)
  • currentOp.cursor.awaitData

New in version 4.2.

The flag that indicates whether the tailable cursor should temporarily block agetMore command on the cursor while waiting for newdata rather than returning no data.

For non-tailable cursors, the value is always false.

See also

  1. - [<code>find</code>]($b880d3668448c2e5.md#dbcmd.find)
  2. - [<code>cursor.tailable()</code>]($d047cc6a3717a527.md#cursor.tailable)
  3. - [<code>cursor.addOption()</code>]($fb45b4e29bd8bcf4.md#cursor.addOption)
  • currentOp.cursor.originatingCommand

New in version 4.2.

The originatingCommand field contains the full command object(e.g. find or aggregate) which originally created thecursor.

Note

Starting in version 4.2, MongoDB now returnsoriginatingCommand field as a nested field in the newcursor field. In previous versions, theoriginatingCommand was a top-level field for the associated"getmore" document.

  • currentOp.cursor.planSummary

New in version 4.2.

Specifies whether the cursor uses a collection scan(COLLSCAN) or an index scan (IXSCAN { … }).

The IXSCAN also includes the specification document of the indexused.

  • currentOp.cursor.operationUsingCursorId

New in version 4.2.

The opid of the operation using the cursor.

Only present if the cursor is not idle.

  • currentOp.client
  • The IP address (or hostname) and the ephemeral port of the clientconnection where the operation originates. If your inprogarray has operations from many different clients, use this stringto relate operations to clients.
  • currentOp.appName

New in version 3.4.

The identifier of the client application which ran the operation. Usethe appName connection string option to set a custom valuefor the appName field.

  • currentOp.locks

Changed in version 3.0.

The locks document reports the type and mode oflocks the operation currently holds. The possible lock types are asfollows:

Lock TypeDescriptionParallelBatchWriterModeRepresents a lock for parallel batch writer mode.

In earlier versions, PBWM information was reported as part ofthe Global lock information.

New in version 4.2.

ReplicationStateTransitionRepresents lock taken for replica set member state transitions.

New in version 4.2.

GlobalRepresents global lock.DatabaseRepresents database lock.CollectionRepresents collection lock.MutexRepresents mutex.MetadataRepresents metadata lock.oplogRepresents lock on the oplog.

The possible modes are as follows:

Lock ModeDescriptionRRepresents Shared (S) lock.WRepresents Exclusive (X) lock.rRepresents Intent Shared (IS) lock.wRepresents Intent Exclusive (IX) lock.

  • currentOp.waitingForLock
  • Returns a boolean value. waitingForLock is true if theoperation is waiting for a lock and false if the operation hasthe required lock.
  • currentOp.msg
  • The msg provides a message that describes the status andprogress of the operation. In the case of indexing or mapReduceoperations, the field reports the completion percentage.
  • currentOp.progress
  • Reports on the progress of mapReduce or indexing operations. Theprogress fields corresponds to the completion percentage inthe msg field. The progress specifies the followinginformation:

    • currentOp.progress.done
    • Reports the number completed.

    • currentOp.progress.total

    • Reports the total number.
  • currentOp.killPending
  • Returns true if the operation is currently flagged fortermination. When the operation encounters its next safe termination point, theoperation will terminate.
  • currentOp.numYields
  • numYields is a counter that reports the number of times theoperation has yielded to allow other operations to complete.

Typically, operations yield when they need access to data thatMongoDB has not yet fully read into memory. This allowsother operations that have data in memory to complete quicklywhile MongoDB reads in data for the yielding operation.

Only appears if locked; i.e. if fsyncLock istrue.

  • currentOp.lockStats
  • For each lock type and mode (see currentOp.locks fordescriptions of lock types and modes), returns the followinginformation:

    • currentOp.lockStats.acquireCount
    • Number of times the operation acquired the lock in the specifiedmode.

    • currentOp.lockStats.acquireWaitCount

    • Number of times the operation had to wait for theacquireCount lock acquisitionsbecause the locks were held in a conflicting mode.acquireWaitCount is less than orequal to acquireCount.

    • currentOp.lockStats.timeAcquiringMicros

    • Cumulative time in microseconds that the operation had to wait toacquire the locks.

timeAcquiringMicros divided byacquireWaitCount gives anapproximate average wait time for the particular lock mode.

  • currentOp.lockStats.deadlockCount
  • Number of times the operation encountered deadlocks while waitingfor lock acquisitions.
  • currentOp.waitingForFlowControl
  • A boolean that indicates if the operation is in the process of waiting forflow control.

New in version 4.2.

  • currentOp.flowControlStats
  • The flow control statistics for this operation.

New in version 4.2.

  • currentOp.flowControlStats.acquireCount
  • The number of times this operation acquired a ticket.

New in version 4.2.

  • currentOp.flowControlStats.acquireWaitCount
  • The number of times this operation waited to aqcuire a ticket.

New in version 4.2.

  • currentOp.flowControlStats.timeAcquiringMicros
  • The total time this operation has waited to acquire a ticket.

New in version 4.2.