currentOp
定义
currentOp已弃用自版本6.2.
从版本 6.2 及以后使用
$currentOp聚合阶段。返回一个包含关于
mongod实例正在进行的操作信息的 文档。使用
$currentOp聚合阶段代替currentOp命令及其db.currentOp()辅助方法。
兼容性
此命令在以下环境中托管的部署中可用
MongoDB Atlas:云中MongoDB部署的全托管服务
注意
此命令在所有MongoDB Atlas集群中都受支持。有关所有命令的Atlas支持信息,请参阅不受支持的命令。
MongoDB Enterprise:基于订阅的自托管MongoDB版本
MongoDB Community:开源、免费使用且自托管的MongoDB版本
语法
命令具有以下语法
db.adminCommand( { currentOp: 1 } )
注意
从MongoDB 5.0开始,当使用mongosh.执行辅助方法db.currentOp()时,使用$currentOp聚合阶段
因此,在shell的5.0版本和mongosh中,db.currentOp()结果集不受先前遗留的mongo版本中16MB BSON文档返回大小限制。
行为
currentOp必须在admin数据库上运行,并且它可以接受几个可选字段。
字段 | 描述 |
|---|---|
"$ownOps" | |
"$all" | 布尔值。如果设置为
|
<filter> | |
comment | 可选。用户提供的附加到此命令的注释。一旦设置,此注释将出现在以下位置的此命令记录旁边
注释可以是任何有效的BSON类型(字符串、整数、对象、数组等)。 |
currentOp和数据库分析器报告了CRUD操作相同的基本诊断信息,包括以下
这些操作也包含在慢查询日志中。有关慢查询日志的更多信息,请参阅slowOpThresholdMs。
编辑
当使用可查询加密时,带有encryptionInformation选项的currentOp操作将编辑某些信息
输出省略了
"command"字段之后的所有字段。输出编辑
"command",仅包含第一个元素$comment和$db。
访问控制
在运行authorization的系统上,用户必须拥有包括inprog权限操作的访问权限。
用户可以在mongod实例上使用$ownOps来查看自己的操作,而无需inprog权限操作。
db.adminCommand( { currentOp: 1, "$ownOps": 1 } )
示例
以下示例使用currentOp命令与各种查询文档来过滤输出。
显示所有当前操作
db.adminCommand( { currentOp: true, "$all": true } )
等待锁定的写操作
以下示例返回所有等待锁定的写操作的信息
db.adminCommand( { currentOp: true, "waitingForLock" : true, $or: [ { "op" : { "$in" : [ "insert", "update", "remove" ] } }, { "command.findandmodify": { $exists: true } } ] } )
无让步的活跃操作
以下示例返回所有从未让步的正在运行的活跃操作的信息
db.adminCommand( { currentOp: true, "active" : true, "numYields" : 0, "waitingForLock" : false } )
特定数据库上的活动操作
以下示例返回数据库db1上所有运行时间超过3秒的活动操作的信息
db.adminCommand( { currentOp: true, "active" : true, "secs_running" : { "$gt" : 3 }, "ns" : /^db1\./ } )
活动索引操作
以下示例返回索引创建操作的信息
db.adminCommand( { currentOp: true, $or: [ { op: "command", "command.createIndexes": { $exists: true } }, { op: "none", "msg" : /^Index Build/ } ] } )
输出示例
以下是在独立模式下运行currentOp命令的输出原型
{ "inprog": [ { "type" : <string>, "host" : <string>, "desc" : <string>, "connectionId" : <number>, "client" : <string>, "appName" : <string>, "clientMetadata" : <document>, "active" : <boolean>, "currentOpTime" : <string>, "effectiveUsers" : [ { "user" : <string>, "db" : <string> } ], "opid" : <number>, "lsid" : { "id" : <UUID>, "uid" : <BinData> }, "secs_running" : <NumberLong()>, "microsecs_running" : <number>, "op" : <string>, "ns" : <string>, "command" : <document>, "queryFramework" : <string>, "planSummary": <string>, "cursor" : { // only for getMore operations "cursorId" : <NumberLong()>, "createdDate" : <ISODate()>, "lastAccessDate" : <ISODate()>, "nDocsReturned" : <NumberLong()>, "nBatchesReturned" : <NumberLong()>, "noCursorTimeout" : <boolean>, "tailable" : <boolean>, "awaitData" : <boolean>, "originatingCommand" : <document>, "planSummary" : <string>, "operationUsingCursorId" : <NumberLong()> }, "msg": <string>, "progress" : { "done" : <number>, "total" : <number> }, "killPending" : <boolean>, "numYields" : <number>, "dataThroughputLastSecond" : <number>, "dataThroughputAverage" : <number>, "locks" : { "ParallelBatchWriterMode" : <string>, "ReplicationStateTransition" : <string>, "Global" : <string>, "Database" : <string>, "Collection" : <string>, "Metadata" : <string>, "oplog" : <string> }, "waitingForLock" : <boolean>, "lockStats" : { "ParallelBatchWriterMode" : { "acquireCount": { "r": <NumberLong>, "w": <NumberLong>, "R": <NumberLong>, "W": <NumberLong> }, "acquireWaitCount": { "r": <NumberLong>, "w": <NumberLong>, "R": <NumberLong>, "W": <NumberLong> }, "timeAcquiringMicros" : { "r" : NumberLong(0), "w" : NumberLong(0), "R" : NumberLong(0), "W" : NumberLong(0) }, "deadlockCount" : { "r" : NumberLong(0), "w" : NumberLong(0), "R" : NumberLong(0), "W" : NumberLong(0) } }, "ReplicationStateTransition" : { ... }, "Global": { ... }, "Database" : { ... }, ... } }, ... ], "fsyncLock": <boolean>, "info": <string>, "ok": <num> }
以下是在副本集主节点上运行currentOp命令的输出原型
{ "inprog": [ { "type" : <string>, "host" : <string>, "desc" : <string>, "connectionId" : <number>, "client" : <string>, "appName" : <string>, "clientMetadata" : <document>, "lsid" : { "id" : <UUID>, "uid" : <BinData> }, "transaction" : { "parameters" : { "txnNumber" : <NumberLong()>, "autocommit" : <boolean>, "readConcern" : { "level" : <string> } }, "readTimestamp" : <Timestamp>, "startWallClockTime" : <string>, "timeOpenMicros" : <NumberLong()>, "timeActiveMicros" : <NumberLong()>, "timeInactiveMicros" : <NumberLong()>, "expiryTime" : <string>, }, "active" : <boolean>, "currentOpTime" : <string>, "effectiveUsers" : [ { "user" : <string>, "db" : <string> } ], "opid" : <number>, "secs_running" : <NumberLong()>, "microsecs_running" : <number>, "op" : <string>, "ns" : <string>, "command" : <document>, "originatingCommand" : <document>, "queryFramework" : <string>, "planSummary": <string>, "prepareReadConflicts" : <NumberLong()>, "writeConflicts" : <NumberLong()>, "cursor" : { // only for getMore operations "cursorId" : <NumberLong()>, "createdDate" : <ISODate()>, "lastAccessDate" : <ISODate()>, "nDocsReturned" : <NumberLong()>, "nBatchesReturned" : <NumberLong()>, "noCursorTimeout" : <boolean>, "tailable" : <boolean>, "awaitData" : <boolean>, "originatingCommand" : <document>, "planSummary" : <string>, "operationUsingCursorId" : <NumberLong()> }, "msg": <string>, "progress" : { "done" : <number>, "total" : <number> }, "killPending" : <boolean>, "numYields" : <number>, "dataThroughputLastSecond" : <number>, "dataThroughputAverage" : <number>, "locks" : { "ParallelBatchWriterMode" : <string>, "ReplicationStateTransition" : <string>, "Global" : <string>, "Database" : <string>, "Collection" : <string>, "Metadata" : <string>, "oplog" : <string> }, "waitingForLock" : <boolean>, "lockStats" : { "ParallelBatchWriterMode" : { "acquireCount": { "r": <NumberLong>, "w": <NumberLong>, "R": <NumberLong>, "W": <NumberLong> }, "acquireWaitCount": { "r": <NumberLong>, "w": <NumberLong>, "R": <NumberLong>, "W": <NumberLong> }, "timeAcquiringMicros" : { "r" : NumberLong(0), "w" : NumberLong(0), "R" : NumberLong(0), "W" : NumberLong(0) }, "deadlockCount" : { "r" : NumberLong(0), "w" : NumberLong(0), "R" : NumberLong(0), "W" : NumberLong(0) } }, "ReplicationStateTransition" : { ... }, "Global" : { ... }, "Database" : { ... }, ... } }, ... ], "fsyncLock": <boolean>, "info": <string>, "ok": <num>, "operationTime": <timestamp>, "$clusterTime": <document> }
以下是在分片集群的 currentOp 运行输出示例(字段可能因所报告的操作而异)。
{ "inprog": [ { "shard": <string>, "type" : <string>, "host" : <string>, "desc" : <string>, "connectionId" : <number>, "client_s" : <string>, "appName" : <string>, "clientMetadata" : <document>, "lsid" : { "id" : <UUID>, "uid" : <BinData> }, "transaction" : { "parameters" : { "txnNumber" : <NumberLong()>, "autocommit" : <boolean>, "readConcern" : { "level" : <string> } }, "readTimestamp" : <Timestamp>, "startWallClockTime" : <string>, "timeOpenMicros" : <NumberLong()>, "timeActiveMicros" : <NumberLong()>, "timeInactiveMicros" : <NumberLong()>, "expiryTime" : <string>, }, "active" : <boolean>, "currentOpTime" : <string>, "effectiveUsers" : [ { "user" : <string>, "db" : <string> } ], "runBy" : [ { "user" : <string>, "db" : <string> } ], "twoPhaseCommitCoordinator" : { "lsid" : { "id" : <UUID>, "uid" : <BinData> }, "txnNumber" : <NumberLong>, "numParticipants" : <NumberLong>, "state" : <string>, "commitStartTime" : <ISODate>, "hasRecoveredFromFailover" : <boolean>, "stepDurations" : <document>, "decision" : <document>, "deadline" : <ISODate> } "opid" : <string>, "secs_running" : <NumberLong()>, "microsecs_running" : <number>, "op" : <string>, "ns" : <string>, "command" : <document>, "configTime" : <Timestamp>, // Starting in 5.0 "topologyTime" : <Timestamp>, // Starting in 5.0 "queryFramework" : <string>, // Starting in 6.2 "planSummary": <string>, "prepareReadConflicts" : <NumberLong()>, "writeConflicts" : <NumberLong()>, "cursor" : { // only for getMore operations "cursorId" : <NumberLong()>, "createdDate" : <ISODate()>, "lastAccessDate" : <ISODate()>, "nDocsReturned" : <NumberLong()>, "nBatchesReturned" : <NumberLong()>, "noCursorTimeout" : <boolean>, "tailable" : <boolean>, "awaitData" : <boolean>, "originatingCommand" : <document>, "planSummary" : <string>, "operationUsingCursorId" : <NumberLong()> }, "msg": <string>, "progress" : { "done" : <number>, "total" : <number> }, "killPending" : <boolean>, "numYields" : <number>, "dataThroughputLastSecond" : <number>, "dataThroughputAverage" : <number>, "locks" : { "ParallelBatchWriterMode" : <string>, "ReplicationStateTransition" : <string>, "Global" : <string>, "Database" : <string>, "Collection" : <string>, "Metadata" : <string>, "DDLDatabase" : <string>, "DDLCollection" : <string>, "oplog" : <string> }, "waitingForLock" : <boolean>, "lockStats" : { "ParallelBatchWriterMode": { "acquireCount": { "r": <NumberLong>, "w": <NumberLong>, "R": <NumberLong>, "W": <NumberLong> }, "acquireWaitCount": { "r": <NumberLong>, "w": <NumberLong>, "R": <NumberLong>, "W": <NumberLong> }, "timeAcquiringMicros" : { "r" : NumberLong(0), "w" : NumberLong(0), "R" : NumberLong(0), "W" : NumberLong(0) }, "deadlockCount" : { "r" : NumberLong(0), "w" : NumberLong(0), "R" : NumberLong(0), "W" : NumberLong(0) } }, "ReplicationStateTransition" : { ... }, "Global" : { ... }, "Database" : { ... }, ... } }, ... ], "ok": <num>, "operationTime": <timestamp>, "$clusterTime": <document> }
特定输出示例
这些输出样本说明了特定操作的 currentOp 输出。实际输出中的字段根据服务器的角色而变化。
重新分片输出示例
{ type: "op", desc: "Resharding{Donor, Recipient, Coordinator}Service <reshardingUUID>", op: "command", ns: "<database>.<collection>", originatingCommand: { reshardCollection: "<database>.<collection>", key: <shardkey>, unique: <boolean>, collation: {locale: "simple"}, // Other options to the reshardCollection command are omitted // to decrease the likelihood the output is truncated. }, {donor, coordinator, recipient}State : "<service state>", approxDocumentsToCopy: NumberLong(<count>), approxBytesToCopy: NumberLong(<count>), bytesCopied: NumberLong(<count>), countWritesToStashCollections: NumberLong(<count>), countWritesDuringCriticalSection : NumberLong(<count>), countReadsDuringCriticalSection: NumberLong(<count>), deletesApplied: NumberLong(<count>), documentsCopied: NumberLong(<count>), insertsApplied: NumberLong(<count>), oplogEntriesFetched: NumberLong(<count>), oplogEntriesApplied: NumberLong(<count>), remainingOperationTimeEstimatedSecs: NumberLong(<count>), allShardsLowestRemainingOperationTimeEstimatedSecs: NumberLong(<estimate>), allShardsHighestRemainingOperationTimeEstimatedSecs: NumberLong(<estimate>), totalApplyTimeElapsedSecs: NumberLong(<count>), totalCopyTimeElapsedSecs: NumberLong(<count>), totalCriticalSectionTimeElapsedSecs : NumberLong(<count>), totalOperationTimeElapsedSecs: NumberLong(<count>), updatesApplied: NumberLong(<count>), }
全局索引示例
{ type: "op", desc: "GlobalIndex{Donor, Recipient, Coordinator}Service <globalIndexUUID}", op: "command", ns: "<database>.<collection>", originatingCommand: { createIndexes: "<database>.<collection>", key: <indexkeypattern>, unique: <boolean>, <Additional createIndexes options> }, {donor, coordinator, recipient}State : "<service state>", approxDocumentsToScan: NumberLong(<count>), approxBytesToScan: NumberLong(<count>), bytesWrittenFromScan: NumberLong(<count>), countWritesToStashCollections: NumberLong(<count>), countWritesDuringCriticalSection : NumberLong(<count>), countReadsDuringCriticalSection: NumberLong(<count>), keysWrittenFromScan: NumberLong(<count>), remainingOperationTimeEstimatedSecs: NumberLong(<count>), allShardsLowestRemainingOperationTimeEstimatedSecs: NumberLong(<estimate>), allShardsHighestRemainingOperationTimeEstimatedSecs: NumberLong(<estimate>), totalCopyTimeElapsedSecs: NumberLong(<count>), totalCriticalSectionTimeElapsedSecs : NumberLong(<count>), totalOperationTimeElapsedSecs: NumberLong(<count>), }
输出字段
currentOp.type操作类型。值可以是
opidleSessionidleCursor
如果
currentOp.type是op,currentOp.op提供关于特定操作的详细信息。
currentOp.desc客户端描述。该字符串包含
connectionId。
currentOp.client表示操作源位置的信息字符串。
对于多文档事务,
client存储有关在事务内部运行操作的最近客户端的信息。
currentOp.appName运行操作的客户端应用程序的标识符。使用
appName连接字符串选项来设置appName字段的自定义值。
currentOp.clientMetadata客户端的附加信息。
对于多文档事务,
client存储有关在事务内部运行操作的最近客户端的信息。
currentOp.currentQueue新版本8.0.
操作当前队列。
currentOp.currentQueue.name操作当前队列的名称。
注意
如果存在
currentQueue且name为ingress,则操作正在等待入口准入。
currentOp.runBy包含与操作关联的每个冒充
有效用户的用户文档的数组。runBy 文档包含用户名和认证数据库。通常,runBy 用户是__system用户;例如。"runBy" : [ { "user" : "__system", "db" : "local" } ] 仅在分片集群中可用
currentOp.transaction包含多文档事务信息的文档。
仅当操作属于多文档事务时才存在。
currentOp.transaction.parameters包含多文档事务信息的文档。
仅当操作属于多文档事务时才存在。
currentOp.transaction.parameters.readConcern事务的读取关注点。
多文档事务支持读取关注点
"snapshot"、"local"和"majority"。仅当操作属于多文档事务时才存在。
currentOp.transaction.timeOpenMicros事务持续时间,单位为微秒。
timeActiveMicros的值加上timeInactiveMicros的值应等于timeOpenMicros。仅当操作属于多文档事务时才存在。
currentOp.transaction.timeActiveMicros事务处于活跃状态的总时间;即事务有操作运行时。
timeActiveMicros的值加上timeInactiveMicros的值应等于timeOpenMicros。仅当操作属于多文档事务时才存在。
currentOp.transaction.timeInactiveMicros事务处于非活动状态的总时间;即事务没有正在运行的操作。
timeInactiveMicros的值加上timeActiveMicros应等于timeOpenMicros。仅当操作属于多文档事务时才存在。
currentOp.transaction.expiryTime事务将超时并中止的日期和时间(带时区)。
currentOp.transaction.expiryTime等于currentOp.transaction.startWallClockTime加上transactionLifetimeLimitSeconds。有关更多信息,请参阅事务的运行时限制。
仅当操作属于多文档事务时才存在。
currentOp.twoPhaseCommitCoordinator关于以下任一信息
跨多个分片写入操作的事务的提交协调指标。
提交协调由分片处理,
currentOp(在mongos或分片成员上运行)仅返回当前由该分片协调的事务的协调信息。仅筛选提交协调指标
db.currentOp( { desc: "transaction coordinator" }) 由事务协调器产生的一个特定提交协调操作(即
currentOp.type是op且currentOp.desc是"TransactionCoordinator")。
currentOp.twoPhaseCommitCoordinator.action事务协调器生成的特定提交协调操作。
"发送准备"。"发送提交"。"发送中止"。"写入参与者列表"。"写入决策"。"删除协调器文档"。
仅适用于特定的 协调操作。
currentOp.twoPhaseCommitCoordinator.numParticipants参与此提交的碎片数量。
仅适用于提交协调指标。
currentOp.twoPhaseCommitCoordinator.state提交协调过程的当前步骤/状态。
步骤/阶段描述不活跃不是提交的积极部分。写入参与者列表正在写入包含此多碎片事务中碎片列表的本地记录。等待投票等待参与者响应投票以提交或中止。写入决策根据投票写入协调器提交或中止决策的本地记录。等待决策确认等待参与者确认协调器的提交或中止决策。删除协调器文档删除提交决策的本地记录。仅适用于提交协调指标。
currentOp.twoPhaseCommitCoordinator.commitStartTime提交开始的日期和时间。
仅适用于提交协调指标。
currentOp.twoPhaseCommitCoordinator.hasRecoveredFromFailover一个布尔值,表示提交协调是否因为协调提交的分片故障转移而重新启动。
如果
hasRecoveredFromFailover为真,则currentOp.twoPhaseCommitCoordinator.stepDurations中指定的某些步骤的时间可能不准确。仅适用于提交协调指标。
currentOp.twoPhaseCommitCoordinator.stepDurations一个文档,包含提交协调
steps/state完成或进行中的持续时间的微秒数。"stepDurations" : { "writingParticipantListMicros" : NumberLong(17801), "totalCommitDurationMicros" : NumberLong(42488463), "waitingForVotesMicros" : NumberLong(30378502), "writingDecisionMicros" : NumberLong(15015), "waitingForDecisionAcksMicros" : NumberLong(12077145), "deletingCoordinatorDocMicros" : NumberLong(6009) }, 如果
currentOp.twoPhaseCommitCoordinator.hasRecoveredFromFailover为真,则stepDurations中指定的次数可能对所有步骤不准确。对于处于
非活动状态的协调器,文档为空。"stepDurations" : { } 仅适用于提交协调指标。
currentOp.twoPhaseCommitCoordinator.decision包含提交/中止决策的文档,例如
对于提交决策
"decision" : { "decision" : "commit", "commitTimestamp" : Timestamp(1572034669, 3) } 对于中止决策
"decision" : { "decision" : "abort", "abortStatus" : { "code" : 282, "codeName" : "TransactionCoordinatorReachedAbortDecision", "errmsg" : "Transaction exceeded deadline" } }
仅适用于提交协调指标。
currentOp.twoPhaseCommitCoordinator.deadline提交必须完成的日期和时间。
仅适用于提交协调指标。
currentOp.opid操作标识符。您可以将此值传递到
db.killOp()以在mongosh中终止操作。警告
请极其谨慎地终止正在运行的操作。仅使用
db.killOp()来终止由客户端启动的操作,不要终止内部数据库操作。
currentOp.active一个布尔值,指定操作是否已启动。如果操作已启动,则值为
true;如果操作处于空闲状态,例如空闲连接或当前空闲的内部线程,则值为false。即使操作已经让步给另一个操作,操作也可以处于活动状态。对于某些不活动的后台线程,例如不活动的signalProcessingThread,MongoDB会抑制各种空字段。
currentOp.secs_running操作以秒为单位的持续时间。MongoDB通过从操作的开始时间减去当前时间来计算此值。
仅在操作正在运行时才出现;即如果
active为true。
currentOp.microsecs_running操作以微秒为单位的持续时间。MongoDB通过从操作的开始时间减去当前时间来计算此值。
仅在操作正在运行时才出现;即如果
active为true。
currentOp.op一个字符串,用于标识特定的操作类型。只有在
currentOp.type是op时才存在。可能的值包括
"none""update""insert""query""command""getmore""remove""killcursors"
"query"操作包括读取操作。"command"操作包括大多数 命令,例如createIndexes和findAndModify。
currentOp.command包含与此操作相关联的完整命令对象的文档。
例如,以下输出包含在名为
items的集合中,在名为test的数据库上执行的find操作的命令对象。"command" : { "find" : "items", "filter" : { "sku" : 1403978 }, ... "$db" : "test" } 以下示例输出包含由具有游标 ID
19234103609的命令生成的,在名为items的集合中,在名为test的数据库上执行的getMore操作的命令对象。"command" : { "getMore" : NumberLong("19234103609"), "collection" : "items", "batchSize" : 10, ... "$db" : "test" }, 如果命令文档超过 1 千字节,则文档具有以下形式
"command" : { "$truncated": <string>, "comment": <string> } $truncated字段包含文档的字符串摘要,不包括(如果存在)文档的comment字段。如果摘要仍然超过 1 千字节,则进一步截断,字符串末尾用省略号 (...) 表示。如果向操作传递了注释,则存在
comment字段。注释可以附加到任何 数据库命令。
currentOp.cursor包含用于
getmore操作的光标信息的文档;即当op是getmore时。如果在
getmore操作访问其光标信息之前报告,则cursor字段不可用。currentOp.cursor.noCursorTimeout表示游标在空闲时不会超时的标志;即如果游标设置了
noTimeout选项。如果为真,则游标在空闲时不会超时。
如果为假,则游标在空闲时会超时。
currentOp.cursor.tailable表示游标是否是针对有界集合的可尾随游标的标志。可尾随游标在客户端耗尽初始游标的结果后仍然保持打开状态。
currentOp.lockslocks文档报告了操作当前持有的锁的类型和模式。可能的锁类型如下锁类型描述ParallelBatchWriterMode表示并行批写入模式的锁。
在早期版本中,PBWM 信息作为
Global锁信息的一部分报告。ReplicationStateTransition表示副本集成员状态转换所采取的锁。Global表示全局锁。Database表示数据库锁。Collection表示集合锁。Mutex表示互斥锁。Metadata表示元数据锁。DDLDatabase表示 DDL 数据库锁。
新版本7.1.
DDLCollection代表一个DDL集合锁。
新版本7.1.
oplog代表对oplog的锁。可能的模式如下
锁模式描述R代表共享(S)锁。W代表独占(X)锁。r代表意向共享(IS)锁。w代表意向独占(IX)锁。
currentOp.admissionPriority仅用于内部。该值表示操作在尝试获取存储引擎操作票据时的优先级。
可能的值有:"low"、"normal"和"immediate"。只有值为"low"的操作会被报告。
示例
currentOp输出{ type: 'op', host: 'ip-10-122-5-147:27017', desc: 'JournalFlusher', active: true, currentOpTime: '2022-10-11T12:45:52.053+00:00', opid: 201, op: 'none', ns: '', command: {}, numYields: 0, admissionPriority: 'low', locks: {}, waitingForLock: false, lockStats: {}, waitingForFlowControl: false, flowControlStats: {} } admissionPriority值也会在慢日志中报告。新版本6.3.
currentOp.waitingForLock返回一个布尔值。如果操作正在等待锁,则
waitingForLock为true,如果操作已经拥有所需的锁,则为false。
currentOp.msgmsg提供了一个描述操作状态和进度的消息。在索引或 mapReduce 操作的情况下,该字段报告了完成百分比。
currentOp.numYieldsnumYields是一个计数器,报告操作已让出多少次,以允许其他操作完成。通常,当操作需要访问MongoDB尚未完全读入内存的数据时,会进行让出。这允许其他操作在MongoDB读取让出操作所需数据的同时快速完成。
currentOp.dataThroughputLastSecond上一秒内由
validate操作处理的数据量(以MiB为单位)。仅当正在扫描文档的validate操作时可用。例如"msg" : "Validate: scanning documents Validate: scanning documents: 7258/24000 30%", "progress" : { "done" : 7258, "total" : 24000 }, "numYields" : 0, "dataThroughputLastSecond" : 15.576952934265137, "dataThroughputAverage" : 15.375944137573242,
currentOp.dataThroughputAveragevalidate操作处理的数据量的平均值(以MiB为单位)。仅当正在扫描文档的validate操作时可用。例如"msg" : "Validate: scanning documents Validate: scanning documents: 7258/24000 30%", "progress" : { "done" : 7258, "total" : 24000 }, "numYields" : 0, "dataThroughputLastSecond" : 15.576952934265137, "dataThroughputAverage" : 15.375944137573242,
currentOp.fsyncLock指定数据库是否当前锁定以进行
fsync write/snapshot。仅在锁定时出现;即如果
fsyncLock为true。
currentOp.info有关如何从 db.fsyncLock() 解锁数据库的信息。只有当
fsyncLock为true时才显示。
currentOp.lockStats对于每种锁定类型和模式(有关锁定类型和模式的描述,请参阅
currentOp.locks),返回以下信息currentOp.lockStats.acquireWaitCount操作需要等待
acquireCount锁获取次数的次数,因为锁以冲突模式持有。acquireWaitCount小于或等于acquireCount。
currentOp.lockStats.timeAcquiringMicros操作获取锁需要等待的累计时间,单位为微秒。
timeAcquiringMicros除以acquireWaitCount可得到特定锁模式的平均等待时间的大致估计。
currentOp.waitingForFlowControl一个布尔值,表示操作是否正在等待流控制。
currentOp.totalOperationTimeElapsedSecs当前重新分片操作的总耗时,单位为秒。当新的重新分片操作开始时,时间设置为0。
仅当正在进行重新分片操作时才存在。
新版本5.0.
从MongoDB 6.1版本开始,此指标也适用于重新分片过程中的协调器。
currentOp.remainingOperationTimeEstimatedSecsremainingOperationTimeEstimatedSecs:当前resharding操作剩余时间的估计值(以秒为单位)。当一个新的resharding操作开始时,返回值为-1。从
MongoDB 5.0开始,但在MongoDB 7.0之前,
remainingOperationTimeEstimatedSecs仅在resharding操作期间在接收分片上可用。MongoDB 7.0,
remainingOperationTimeEstimatedSecs在resharding操作期间也在协调器上可用。
resharding操作按顺序执行这些阶段
克隆阶段复制当前集合的数据。
追赶阶段将任何挂起的写操作应用到resharding集合中。
remainingOperationTimeEstimatedSecs设置为悲观时间估计追赶阶段时间估计设置为克隆阶段时间,这是一个相对较长的时期。
实际上,如果只有少量挂起的写操作,实际的追赶阶段时间相对较短。
新版本5.0.
currentOp.allShardsLowestRemainingOperationTimeEstimatedSecs在整个分片上计算,剩余时间的最低估计。
仅在执行分片操作时在协调器上出现。
新版本6.1.
currentOp.allShardsHighestRemainingOperationTimeEstimatedSecs在整个分片上计算,剩余时间的最高估计。
仅在执行分片操作时在协调器上出现。
新版本6.1.
currentOp.approxDocumentsToCopy在重新分片操作期间,从捐赠分片复制到接收分片的大约文档数量。此数字是在重新分片操作开始时设置的估计值,设置后不会改变。当新的重新分片操作开始时,数字设置为0。如果重新分片后的数据分布不完美均匀,则可能发生
$currentOp.documentsCopied和$currentOp.bytesCopied分别超过$currentOp.approxDocumentsToCopy和$currentOp.approxBytesToCopy。仅在resharding操作进行时,在接收分片上存在。
新版本5.0.
currentOp.documentsCopied在resharding操作期间从捐赠分片复制到接收分片的文档数量。当一个新的resharding操作开始时,该数字设置为0。
仅在resharding操作进行时,在接收分片上存在。
新版本5.0.
currentOp.approxBytesToCopy在resharding操作期间从捐赠分片复制到接收分片的字节数的近似值。这是一个在resharding操作开始时设置的估算值,并在设置后不会改变。当一个新的resharding操作开始时,该数字设置为0。如果resharding操作后的数据分布不是完全均匀的,则
$currentOp.documentsCopied和$currentOp.bytesCopied可能会分别超过$currentOp.approxDocumentsToCopy和$currentOp.approxBytesToCopy。仅在resharding操作进行时,在接收分片上存在。
新版本5.0.
currentOp.bytesCopied在resharding操作期间从捐赠分片复制到接收分片的字节数。当一个新的resharding操作开始时,该数字设置为0。
仅在resharding操作进行时,在接收分片上存在。
新版本5.0.
currentOp.countWritesToStashCollections写入到stash collections的数量。
仅在resharding操作进行时,在接收分片上存在。
新版本6.1.
currentOp.totalCopyTimeElapsedSecs当前重分片操作中,从捐赠分片到接收分片进行数据复制所花费的总时间(以秒为单位)。当新的重分片操作开始时,时间设置为0。
仅在resharding操作进行时,在接收分片上存在。
新版本5.0.
从MongoDB 6.1版本开始,此指标也适用于重新分片过程中的协调器。
currentOp.oplogEntriesFetched当前oplog中获取的条目数量,用于当前重分片操作。新重分片操作开始时,该数字设置为0。
仅在resharding操作进行时,在接收分片上存在。
新版本5.0.
currentOp.oplogEntriesApplied当前oplog中应用于当前重分片操作的条目数量。新重分片操作开始时,该数字设置为0。
仅在resharding操作进行时,在接收分片上存在。
新版本5.0.
currentOp.totalApplyTimeElapsedSecs当前resharding操作apply步骤的总耗时,单位为秒。在apply步骤中,接收到的分片将resharding操作的oplog条目应用到它们的数据上,以根据捐赠分片的新写入来修改数据。当新的resharding操作开始时,时间设置为0。
仅在resharding操作进行时,在接收分片上存在。
新版本5.0.
从MongoDB 6.1版本开始,此指标也适用于重新分片过程中的协调器。
currentOp.countWritesDuringCriticalSection当前resharding操作关键部分中执行的写入次数。关键部分阻止对正在resharding的集合的新写入。当新的resharding操作开始时,该数值设置为0。
仅在重新分片操作进行时,捐赠分片上存在。
新版本5.0.
currentOp.totalCriticalSectionTimeElapsedSecs当前resharding操作关键部分的总耗时,单位为秒。关键部分阻止对正在resharding的集合的新写入。当新的resharding操作开始时,时间设置为0。
仅在重新分片操作进行时,捐赠分片上存在。
新版本5.0.
从MongoDB 6.1版本开始,此指标也适用于重新分片过程中的协调器。
currentOp.donorState重分片操作中捐赠分片当前状态。当新的重分片操作开始时,状态设置为
未使用。仅在重新分片操作进行时,捐赠分片上存在。
状态描述未使用重分片操作即将开始或从主节点故障转移中恢复。准备捐赠捐赠分片正在准备向接收分片捐赠数据。捐赠初始数据捐赠分片正在向接收分片捐赠数据。捐赠操作日志条目捐赠分片正在向接收分片捐赠操作日志条目。准备阻止写入捐赠分片即将阻止对正在重分片的集合进行新的写入操作。错误重分片操作期间发生错误。阻止写入捐赠分片正在阻止新的写入操作,并已通知所有接收分片新的写入操作已被阻止。完成捐赠分片已删除旧的分片集合,重分片操作已完成。新版本5.0.
currentOp.recipientState重分片操作中接收分片当前状态。当新的重分片操作开始时,状态设置为
未使用。仅在重新分片操作进行时,捐赠分片上存在。
状态描述未使用重分片操作即将开始或从主节点故障转移中恢复。等待获取时间戳接收分片正在等待捐赠分片准备好捐赠数据。创建集合接收分片正在创建新的分片集合。克隆接收分片正在从捐赠分片接收数据。应用接收分片正在将oplog条目应用于其数据的副本,以根据来自捐赠分片的新传入写入进行修改。错误重分片操作期间发生错误。严格一致性接收分片将所有数据更改存储在一个临时集合中。完成重新分片操作已完成。新版本5.0.
currentOp.coordinatorState当前重新分片操作的重新分片协调器状态。重新分片协调器是运行在配置服务器主节点上的操作。当一个新的重新分片操作开始时,状态设置为
未使用。仅存在于协调配置服务器上。
状态描述未使用重分片操作即将开始或从主节点故障转移中恢复。初始化中重新分片协调器已将协调器文档插入到config.reshardingOperations中,并将reshardingFields添加到原始集合的config.collections条目中。准备捐赠重新分片协调器
为临时重新分片集合创建了
config.collections条目。已根据新的分片键插入到
config.chunks的条目。已根据与新分片键关联的任何区域插入到
config.tags的条目。
协调器通知参与分片开始重新分片操作。协调器等待所有捐赠分片选择一个
minFetchTimestamp并准备好捐赠。克隆重新分片协调器通知捐赠分片向接收分片捐赠数据。协调器等待所有接收者完成从捐赠者克隆数据。应用重新分片协调器通知接收分片根据捐赠者的新传入写入修改其数据副本。协调器等待所有接收者完成应用oplog条目。阻止写入重新分片协调器通知捐赠分片防止对新正在重新分片的集合进行新的写入操作。协调器然后等待所有接收者都有所有数据更改。正在中止在重新分片操作期间发生了不可恢复的错误,或者执行了abortReshardCollection命令(或运行了sh.abortReshardCollection()方法)。提交中重新分片协调器删除了临时重新分片集合的config.collections条目。然后协调器将recipientFields添加到源集合的条目中。新版本5.0.
currentOp.collUuid被采样集合的UUID。
此字段仅出现在与查询采样相关的文档中。详细信息,请参阅配置查询分析器。
新版本7.0.
currentOp.startTime查询采样开始的时间。
此字段仅出现在与查询采样相关的文档中。详细信息,请参阅配置查询分析器。
新版本7.0.
currentOp.samplesPerSecond每秒最多采样查询的数量。
在分片集群中,这个信息会在
mongos上显示,而不是在mongod上。在副本集中,这个信息会在mongod上显示。此字段仅出现在与查询采样相关的文档中。详细信息,请参阅配置查询分析器。
新版本7.0.
currentOp.sampledReadsCount样本读取查询的数量。
此字段仅出现在与查询采样相关的文档中。详细信息,请参阅配置查询分析器。
新版本7.0.
currentOp.sampledWritesCount样本写入查询的数量。
此字段仅出现在与查询采样相关的文档中。详细信息,请参阅配置查询分析器。
新版本7.0.
currentOp.sampledReadsBytes样本读取查询的大小,以字节为单位。
在副本集中,这个信息会在每个
mongod上显示。在分片集群中,只有带有
--shardsvr的mongod才会显示这个信息。此字段仅出现在与查询采样相关的文档中。详细信息,请参阅配置查询分析器。
新版本7.0.
currentOp.sampledWritesBytes样本写查询的大小,以字节为单位。
在副本集中,这个信息会在每个
mongod上显示。在分片集群中,只有带有
--shardsvr的mongod才会显示这个信息。此字段仅出现在与查询采样相关的文档中。详细信息,请参阅配置查询分析器。
新版本7.0.