定义
currentOp自版本 6.2 起已弃用。
在 6.2 版本及更高版本中,使用
$currentOp聚合阶段。返回一个文档,其中包含有关
mongod实例正在进行的操作的信息。自版本 6.2 以来,
currentOp数据库命令已被弃用。使用$currentOp聚合阶段而不是currentOp命令及其mongosh辅助方法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 聚合阶段。
鉴于此,在 5.0 版本的 Shell 以及使用 mongosh 时,db.currentOp() 结果集不受针对先前 mongo 旧版本文档的 16 MB BSON 文档返回大小限制的约束。
行为
currentOp 必须针对 admin 数据库运行,并且可以接受多个可选字段。
字段 | 说明 |
|---|---|
| 布尔值。如果设为 在 |
| 布尔值。如果设置为
|
<filter> | 在输出字段上指定过滤条件。请参阅示例。 |
| 可选。用户提供的待附加到该命令的注释。设置后,该注释将与该命令的记录一起出现在以下位置:
注释可以是任何有效的 BSON 类型(字符串、整型、对象、数组等)。 |
currentOp 数据库分析器会为 CRUD 操作报告相同的基本诊断信息,包括以下内容:
getMore(OP_GET_MORE 和command)
这些操作也包含在慢查询的日志中。有关慢查询日志的更多信息,请参阅 slowOpThresholdMs。
日志校订
使用可查询加密时,带有 encryptionInformation 选项的 currentOp 操作会编辑某些信息:
输出将忽略
"command"之后的所有字段。输出编辑
"command"以仅包含第一个元素$comment以及$db。
访问控制
在使用 authorization 运行的系统上,用户必须具有包含 inprog 特权动作的访问权限。
没有 inprog 特权动作,用户也可以在 mongod 实例上使用 $ownOps,来查看自己的操作。
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 } )
针对特定数据库的活动操作
以下示例将返回有关运行时间超过 3 秒且针对数据库 db1 的所有活动操作的信息:
db.adminCommand( { currentOp: true, "active" : true, "secs_running" : { "$gt" : 3 }, "ns" : /^db1\./ } )
主动索引操作
以下示例返回索引创建操作的相关信息:
db.getSiblingDB("admin").aggregate( [ { $currentOp : { idleConnections: true } }, { $match: { $or: [ { "op": "command", "command.createIndexes": { $exists: true } }, { "op": "none", "msg": /^Index Build/ } ] } } ] )
MongoDB通过将 active字段设置为 false,将等待提交法定人数完成操作的索引构建索引为空闲连接。idleConnections: true 设置在 $currentOp 输出中包含这些空闲连接。
输出示例
以下是在独立实例上运行时 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" : <Long()>, "microsecs_running" : <number>, "op" : <string>, "ns" : <string>, "command" : <document>, "queryFramework" : <string>, "planSummary": <string>, "cursor" : { // only for getMore operations "cursorId" : <Long()>, "createdDate" : <ISODate()>, "lastAccessDate" : <ISODate()>, "nDocsReturned" : <Long()>, "nBatchesReturned" : <Long()>, "noCursorTimeout" : <boolean>, "tailable" : <boolean>, "awaitData" : <boolean>, "originatingCommand" : <document>, "planSummary" : <string>, "operationUsingCursorId" : <Long()> }, "msg": <string>, "progress" : { "done" : <number>, "total" : <number> }, "killPending" : <boolean>, "numYields" : <number>, "dataThroughputLastSecond" : <number>, "dataThroughputAverage" : <number>, "waitingForLatch" : { "timestamp" : <ISODate()>, "captureName" : <string> }, "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" : Long(0), "w" : Long(0), "R" : Long(0), "W" : Long(0) }, "deadlockCount" : { "r" : Long(0), "w" : Long(0), "R" : Long(0), "W" : Long(0) } }, "ReplicationStateTransition" : { ... }, "Global": { ... }, "Database" : { ... }, ... } }, ... ], "fsyncLock": <boolean>, "info": <string>, "ok": <num> }
以下是在副本集的主节点 (primary node in the replica set)节点上运行时currentOp输出的原型:
{ "inprog": [ { "type" : <string>, "host" : <string>, "desc" : <string>, "connectionId" : <number>, "client" : <string>, "appName" : <string>, "clientMetadata" : <document>, "lsid" : { "id" : <UUID>, "uid" : <BinData> }, "transaction" : { "parameters" : { "txnNumber" : <Long()>, "autocommit" : <boolean>, "readConcern" : { "level" : <string> } }, "readTimestamp" : <Timestamp>, "startWallClockTime" : <string>, "timeOpenMicros" : <Long()>, "timeActiveMicros" : <Long()>, "timeInactiveMicros" : <Long()>, "expiryTime" : <string>, }, "active" : <boolean>, "currentOpTime" : <string>, "effectiveUsers" : [ { "user" : <string>, "db" : <string> } ], "opid" : <number>, "secs_running" : <Long()>, "microsecs_running" : <number>, "op" : <string>, "ns" : <string>, "command" : <document>, "originatingCommand" : <document>, "queryFramework" : <string>, "planSummary": <string>, "prepareReadConflicts" : <Long()>, "writeConflicts" : <Long()>, "cursor" : { // only for getMore operations "cursorId" : <Long()>, "createdDate" : <ISODate()>, "lastAccessDate" : <ISODate()>, "nDocsReturned" : <Long()>, "nBatchesReturned" : <Long()>, "noCursorTimeout" : <boolean>, "tailable" : <boolean>, "awaitData" : <boolean>, "originatingCommand" : <document>, "planSummary" : <string>, "operationUsingCursorId" : <Long()> }, "msg": <string>, "progress" : { "done" : <number>, "total" : <number> }, "killPending" : <boolean>, "numYields" : <number>, "dataThroughputLastSecond" : <number>, "dataThroughputAverage" : <number>, "waitingForLatch" : { "timestamp" : <ISODate()>, "captureName" : <string> }, "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" : Long(0), "w" : Long(0), "R" : Long(0), "W" : Long(0) }, "deadlockCount" : { "r" : Long(0), "w" : Long(0), "R" : Long(0), "W" : Long(0) } }, "ReplicationStateTransition" : { ... }, "Global" : { ... }, "Database" : { ... }, ... } }, ... ], "fsyncLock": <boolean>, "info": <string>, "ok": <num>, "operationTime": <timestamp>, "$clusterTime": <document> }
以下是在分分片集群的 上运行时的currentOp mongos输出示例(字段可能因所报告的操作而异):
{ "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" : <Long()>, "autocommit" : <boolean>, "readConcern" : { "level" : <string> } }, "readTimestamp" : <Timestamp>, "startWallClockTime" : <string>, "timeOpenMicros" : <Long()>, "timeActiveMicros" : <Long()>, "timeInactiveMicros" : <Long()>, "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" : <Long()>, "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" : <Long()>, "writeConflicts" : <Long()>, "cursor" : { // only for getMore operations "cursorId" : <Long()>, "createdDate" : <ISODate()>, "lastAccessDate" : <ISODate()>, "nDocsReturned" : <Long()>, "nBatchesReturned" : <Long()>, "noCursorTimeout" : <boolean>, "tailable" : <boolean>, "awaitData" : <boolean>, "originatingCommand" : <document>, "planSummary" : <string>, "operationUsingCursorId" : <Long()> }, "msg": <string>, "progress" : { "done" : <number>, "total" : <number> }, "killPending" : <boolean>, "numYields" : <number>, "dataThroughputLastSecond" : <number>, "dataThroughputAverage" : <number>, "waitingForLatch" : { "timestamp" : <ISODate()>, "captureName" : <string> }, "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" : Long(0), "w" : Long(0), "R" : Long(0), "W" : Long(0) }, "deadlockCount" : { "r" : Long(0), "w" : Long(0), "R" : Long(0), "W" : Long(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: Long(<count>), approxBytesToScan: Long(<count>), bytesWrittenFromScan: Long(<count>), countWritesToStashCollections: Long(<count>), countWritesDuringCriticalSection : Long(<count>), countReadsDuringCriticalSection: Long(<count>), keysWrittenFromScan: Long(<count>), remainingOperationTimeEstimatedSecs: Long(<count>), allShardsLowestRemainingOperationTimeEstimatedSecs: Long(<estimate>), allShardsHighestRemainingOperationTimeEstimatedSecs: Long(<estimate>), totalCopyTimeElapsedSecs: Long(<count>), totalCriticalSectionTimeElapsedSecs : Long(<count>), totalOperationTimeElapsedSecs: Long(<count>), }
输出字段
currentOp.type操作类型。值为:
opidleSessionidleCursor
如果
currentOp.type为op,currentOp.op将提供有关特定操作的详细信息。
currentOp.desc对客户的描述。该字符串包括
connectionId。
currentOp.client包含操作来源信息的字符串。
对于多文档事务,
client会存储有关在事务内运行操作的最新客户端的信息。
currentOp.appName运行操作的客户端应用程序的标识符。使用
appName连接字符串选项设置appName字段的自定义值。
currentOp.clientMetadata有关客户端的其他信息。
对于多文档事务,
client会存储有关在事务内运行操作的最新客户端的信息。
currentOp.runBy数组,其中包含正在模拟
effectiveUser(s)进行操作的每个用户的文档。runBy 文档包含user名称和身份验证db。一般来说,runBy 用户是__system用户;例如"runBy" : [ { "user" : "__system", "db" : "local" } ] 仅在分片集群上可用
currentOp.transaction一份文档,包含多文档事务信息。
只有当操作是多文档事务的一部分时才会出现。
currentOp.transaction.parameters一份文档,包含多文档事务的信息。
只有当操作是多文档事务的一部分时才会出现。
currentOp.transaction.parameters.readConcern事务的读关注。
多文档事务支持读关注
"snapshot"、"local"和"majority"。只有当操作是多文档事务的一部分时才会出现。
currentOp.transaction.timeOpenMicros事务的持续时间(以微秒计)。
添加至
timeInactiveMicros的timeActiveMicros值应该等于timeOpenMicros。只有当操作是多文档事务的一部分时才会出现。
currentOp.transaction.timeActiveMicros事务处于活动状态的总时长;即事务运行各种操作的总时长。
添加至
timeInactiveMicros的timeActiveMicros值应该等于timeOpenMicros。只有当操作是多文档事务的一部分时才会出现。
currentOp.transaction.timeInactiveMicros事务处于非活动状态的总时长;即事务没有运行任何操作的总时长。
添加至
timeActiveMicros的timeInactiveMicros值应该等于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事务协调器生成的特定提交协调操作:
"sendingPrepare""sendingCommit""sendingAbort""writingParticipantList""writingDecision""deletingCoordinatorDoc"
仅适用于特定的协调操作。
currentOp.twoPhaseCommitCoordinator.numParticipants参与本次提交的分片数量。
仅适用于提交协调指标。
currentOp.twoPhaseCommitCoordinator.state提交协调过程的当前步骤/状态。
步骤/阶段说明inactive不是提交的主动部分。
writingParticipantList写入属于该多分片事务的分片列表的本地记录。
waitingForVotes等待参与者通过投票作出提交或终止响应。
writingDecision写入协调器根据投票作出提交或终止决定的本地记录。
waitingForDecisionAck等待参与者确认协调器提交或中止的决定。
deletingCoordinatorDoc删除提交决策的本地记录。
仅适用于提交协调指标。
currentOp.twoPhaseCommitCoordinator.commitStartTime提交操作的开始日期和时间。
仅适用于提交协调指标。
currentOp.twoPhaseCommitCoordinator.hasRecoveredFromFailover一个布尔值,指示提交协调是否由于协调提交的分片故障转移而重新启动。
如果
hasRecoveredFromFailover为 true,那么currentOp.twoPhaseCommitCoordinator.stepDurations中指定的时间可能不会准确适用于所有步骤。仅适用于提交协调指标。
currentOp.twoPhaseCommitCoordinator.stepDurations包含已完成或正在进行的提交协调
steps/state的持续时间(以微秒计)的文档:"stepDurations" : { "writingParticipantListMicros" : Long(17801), "totalCommitDurationMicros" : Long(42488463), "waitingForVotesMicros" : Long(30378502), "writingDecisionMicros" : Long(15015), "waitingForDecisionAcksMicros" : Long(12077145), "deletingCoordinatorDocMicros" : Long(6009) }, 如果
currentOp.twoPhaseCommitCoordinator.hasRecoveredFromFailover为 true,那么stepDurations中指定的时间可能不会准确适用于所有步骤。对于处于
inactive状态的协调器来说,文档为空:"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该操作的标识符。您可以将此值传递给
mongosh中的db.killOp(),以终止操作。警告
终止正在运行的操作时要格外小心。仅使用
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包含与此操作相关的完整命令对象的文档。
例如,以下输出包含在
test数据库中items集合上执行的find操作的命令对象:"command" : { "find" : "items", "filter" : { "sku" : 1403978 }, ... "$db" : "test" } 以下示例输出包含
getMore操作的命令对象,该命令对象由游标 ID 为19234103609的命令在名为test的数据库中名为items的集合上生成:"command" : { "getMore" : Long("19234103609"), "collection" : "items", "batchSize" : 10, ... "$db" : "test" }, 如果命令文档的大小超过 1 KB,则文档的格式如下:
"command" : { "$truncated": <string>, "comment": <string> } $truncated字段包含文档的字符串概要,不包括文档的comment字段(如果存在)。如果概要仍然超过 1 KB,则会进一步截断,在字符串末尾用省略号 (...) 表示。如果将注释传递给操作,则会出现
comment字段。任何数据库命令都可以附加注释。
currentOp.cursor包含
getmore操作的游标信息的文档;即其中op为getmore。如果在
getmore访问其游标信息之前报告getmore操作,则cursor字段不可用。currentOp.cursor.noCursorTimeout此标记指示游标空闲时未超时;即,如果游标设置了
noTimeout选项。如果为 true,则游标在空闲时不会超时。
如果为 false,则游标在空闲时超时。
currentOp.cursor.tailable此标记指示游标是否为固定大小集合的可追加游标。在客户端用尽初始游标中的结果后,可追加游标将保持打开状态。
currentOp.waitingForLatch仅当操作正在等待获取内部锁原语(又名锁存器)或等待满足内部条件时,
waitingForLatch文档才可用。例如,
"waitingForLatch" : { "timestamp" : ISODate("2020-03-19T23:25:58.412Z"), "captureName" : "FutureResolution", }, 输出字段说明timestamp
操作开始等待的日期和时间。
captureName
当前操作受阻的区段的内部名称。
版本 4.2.2 中的新增功能。
currentOp.lockslocks文档会报告该操作当前持有的锁的类型和模式。可能的锁类型如下:锁类型说明ParallelBatchWriterMode代表并行批量写入模式的锁。
在早期版本中,PBWM 信息作为
Global锁信息的一部分进行报告。ReplicationStateTransition表示副本集节点状态转换采用的锁。
Global代表全局锁定。
Database代表数据库锁。
Collection代表集合锁。
Mutex代表互斥锁。
Metadata代表元数据锁。
oplog表示 oplog 上的锁。
可能的模式如下:
锁模式说明R代表共享(S)锁。
W代表独占 (X) 锁。
r代表意向共享(IS)锁。
w代表意图独占 (IX) 锁。
currentOp.admissionPriority供内部使用。该值是操作在尝试获取票证以执行存储引擎操作时所具有的优先级。
可能的值为:“低”、“正常”和“立即”。仅报告值为“低”的操作。
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.dataThroughputLastSecondvalidate操作在上一秒处理的数据量(以 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:当前重新分片操作的预计剩余时间(以秒为单位)。当新的重新分片操作开始时,将返回-1。开始于:
MongoDB 5.0,但在 MongoDB 6.1 之前,
remainingOperationTimeEstimatedSecs仅在重新分片操作期间在接收分片上可用。MongoDB 6.1,在重新分片操作期间,协调器上也可以使用
remainingOperationTimeEstimatedSecs。
重新分片操作按顺序执行以下阶段:
克隆阶段复制当前的集合数据。
追赶阶段将所有待处理的写入操作应用于重新分片的集合。
remainingOperationTimeEstimatedSecs设置为悲观的时间估计值:将追赶阶段时间估计值设置为克隆阶段时间,这是一个相对较长的时间。
实际上,如果只有几个待处理的写入操作,则实际的追赶阶段时间相对较短。
版本 5.0 中的新增功能。
currentOp.allShardsLowestRemainingOperationTimeEstimatedSecs在所有分片上计算的剩余秒数的最低估值。
仅在执行重新分片操作时才出现在协调器上。
6.1 版本新增内容。
currentOp.allShardsHighestRemainingOperationTimeEstimatedSecs在所有分片上计算的剩余描述的最高估值。
仅在执行重新分片操作时才出现在协调器上。
6.1 版本新增内容。
currentOp.approxDocumentsToCopy在重新分片操作期间要从发送分片复制到接收分片的大致文档数量。此数字是在重新分片操作开始时设置的估计值,设置后不会更改。开始新的重新分片操作时,该数字将被设置为 0。如果重新分片后的数据分布不完全均匀,则
$currentOp.documentsCopied和$currentOp.bytesCopied最终可能分别超过$currentOp.approxDocumentsToCopy和$currentOp.approxBytesToCopy。仅在执行重新分片操作时出现在接收分片上。
版本 5.0 中的新增功能。
currentOp.documentsCopied在重新分片操作期间,从发送分片复制到接收分片的文档数量。开始新的重新分片操作时,该数字设置为 0。
仅在执行重新分片操作时出现在接收分片上。
版本 5.0 中的新增功能。
currentOp.approxBytesToCopy在重新分片操作期间从发送分片复制到接收分片的大致字节数。此数字是在重新分片操作开始时设置的估计值,设置后不会更改。开始新的重新分片操作时,该数字将被设置为 0。如果重新分片后的数据分布不完全均匀,则
$currentOp.documentsCopied和$currentOp.bytesCopied最终可能分别超过$currentOp.approxDocumentsToCopy和$currentOp.approxBytesToCopy。仅在执行重新分片操作时出现在接收分片上。
版本 5.0 中的新增功能。
currentOp.bytesCopied在重新分片操作期间从捐赠分片复制到接收分片的字节数。开始新的重新分片操作时,该数字被设置为 0。
仅在执行重新分片操作时出现在接收分片上。
版本 5.0 中的新增功能。
currentOp.countWritesToStashCollections写入接收储藏集合的次数。
仅在执行重新分片操作时出现在接收分片上。
6.1 版本新增内容。
currentOp.totalCopyTimeElapsedSecs当前重新分片操作从发送分片到接收分片的持续数据复制任务所花费的总时间(以秒计)。开始新的重新分片操作时,时间设置为 0。
仅在执行重新分片操作时出现在接收分片上。
版本 5.0 中的新增功能。
从 MongoDB 6.1 开始,该指标在重新分片期间也可在协调器上使用。
currentOp.oplogEntriesFetched从当前重新分片操作的 oplog 获取的条目数。开始新的重新分片操作时,该数字将被设置为 0。
仅在执行重新分片操作时出现在接收分片上。
版本 5.0 中的新增功能。
currentOp.oplogEntriesApplied应用于当前的重新分片操作的 oplog 的条目数。开始新的重新分片操作时,该数字将被设置为 0。
仅在执行重新分片操作时出现在接收分片上。
版本 5.0 中的新增功能。
currentOp.totalApplyTimeElapsedSecs当前重新分片操作的应用步骤所用的总时间(以秒为单位)。在应用步骤中,接收分片应用 oplog 条目,根据来自发送分片的新传入写入来修改其数据。开始新的重新分片操作时,时间设置为 0。
仅在执行重新分片操作时出现在接收分片上。
版本 5.0 中的新增功能。
从 MongoDB 6.1 开始,该指标在重新分片期间也可在协调器上使用。
currentOp.countWritesDuringCriticalSection当前重新分片操作在关键部分执行的写入次数。关键部分可防止对当前正在重新分片的集合进行新的传入写入。开始新的重新分片操作时,该数字将被设置为 0。
仅在执行重新分片操作时才出现在发送分片上。
版本 5.0 中的新增功能。
currentOp.totalCriticalSectionTimeElapsedSecs当前重新分片操作的关键部分所用的总时间(以秒为单位)。关键部分可防止对当前正在重新分片的集合进行新的传入写入。开始新的重新分片操作时,时间设置为 0。
仅在执行重新分片操作时才出现在发送分片上。
版本 5.0 中的新增功能。
从 MongoDB 6.1 开始,该指标在重新分片期间也可在协调器上使用。
currentOp.donorState重新分片操作中发送分片的当前状态。当新的重新分片操作开始时,该状态将被设置为
unused。仅在执行重新分片操作时才出现在发送分片上。
州说明unused重新分片操作即将开始或从主节点故障转移中恢复。
preparing-to-donate源分片正准备向接收分片提供数据。
donating-initial-data发送分片正在向接收分片发送数据。
donating-oplog-entries发送分片正在向接收分片发送 oplog 条目。
preparing-to-block-writes发送分片即将阻止对正在重新分片的集合进行新的传入写入操作。
error重新分片操作过程中发生错误。
blocking-writes发送分片正在阻止新的传入写入操作,并且发送分片已通知所有接收分片新的传入写入已禁止。
done发送分片已经删除旧的分片集合,重新分片操作已完成。
版本 5.0 中的新增功能。
currentOp.recipientState重新分片操作中接收分片的当前状态。当新的重新分片操作开始时,该状态将被设置为
unused。仅在执行重新分片操作时才出现在发送分片上。
州说明unused重新分片操作即将开始或从主节点故障转移中恢复。
awaiting-fetch-timestamp接收分片正在等待发送分片做好发送数据的准备。
creating-collection接收分片正在创建新的分片集合。
cloning接收分片正在接收来自发送分片的数据。
applying接收分片正在应用 oplog 条目,以根据来自发送分片的新传入写入来修改数据副本。
error重新分片操作过程中发生错误。
strict-consistency接收分片将所有数据更改存储在临时集合中。
done重新分片操作已完成。
版本 5.0 中的新增功能。
currentOp.coordinatorState当前重新分片操作的重新分片协调器的状态。重新分片协调器是在配置服务器主节点上运行的操作。当新的重新分片操作开始时,该状态将被设置为
unused。仅存在于协调配置服务器上。
州说明unused重新分片操作即将开始或从主节点故障转移中恢复。
initializing重新分片协调器已将协调器文档插入
config.reshardingOperations中,并将reshardingFields添加到原始集合的config.collections条目中。preparing-to-donate重新分片协调器
已为临时重新分片集合创建了一个
config.collections条目。已在
config.chunks中插入了基于新分片键的范围条目。已将条目插入到与新分片键关联的任何区域的
config.tags中。
协调器通知参与分片开始重新分片操作。然后,协调器将等待,直到所有发送分片都选择了一个
minFetchTimestamp并准备好发送。cloning重新分片协调节点通知发送分片将数据发送给接收分片。协调节点等待所有接收分片完成对发送分片数据的克隆。
applying重新分片协调器通知接收分片根据来自发送分片的新传入写入来修改其数据副本。协调器等待所有接收分片完成应用 oplog 条目。
blocking-writes重新分片协调节点通知发送分片,以防止对正在重新分片的集合进行新的传入写入操作。然后,协调节点等待所有接收分片进行所有数据更改。
aborting在重新分片操作或运行
abortReshardCollection命令(或sh.abortReshardCollection()方法)期间出现不可恢复的错误。committing重新分片协调器删除了临时重新分区集合的
config.collections条目。然后,协调器将recipientFields添加到源集合的条目中。版本 5.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 版本中的新增功能。