[DOCS-10053] currentOp example for finding index ops needs 3.4 update Created: 29/Mar/17  Updated: 30/Oct/23  Resolved: 09/Aug/17

Status: Closed
Project: Documentation
Component/s: manual
Affects Version/s: 3.4.0
Fix Version/s: Server_Docs_20231030

Type: Bug Priority: Minor - P4
Reporter: Akira Kurogane Assignee: Allison Reinheimer Moore
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by DOCS-10089 Fix currentOp.op possiblities Closed
is duplicated by DOCS-8883 Instructions on Active Indexing Opera... Closed
Participants:
Days since reply: 6 years, 27 weeks ago

 Description   

I discovered that the example command to find Active Indexing Operations using currentOp didn't work for me recently when I was working with 3.4.

It's a pretty helpful for finding long-running index builds in support cases, so I encourage that we keep this example, but update it to be compatible with all currently supported versions.

The difference is that the "op" value in 3.4 has changed. On a standalone or primary node it used to be "query", but in 3.4 it's changed to being "command" (which makes more sense).

It seems that the oplog docs are maintaining the appearance of being inserts to the system.indexes collection, even in 3.4. So we still need the second line so index builds can be found whilst they are being run via replication sync on secondaries. However I found that the "op" value has again changed: from "insert" to "none".

So for both of the clauses inside the outer $or operation we need $in arrays to accept two types of "op" each. New solution shown below.

db.currentOp(
     {       $or: [
         { op: { $in: [ "command", "query" ] }, "query.createIndexes": { $exists: true } }, //"op" used to be "query" in =< 3.2, is now "command" in 3.4
         { op: { $in: [ "insert", "none" ] }, ns: /\.system\.indexes\b/ }  //This is a legacy form?. It is still used in oplog so that is how it manifests on the secondary
       ]
     } )



 Comments   
Comment by Githook User [ 09/Aug/17 ]

Author:

{'username': 'schmalliso', 'email': 'allison.moore@10gen.com', 'name': 'Allison Moore'}

Message: DOCS-10053: updates currentOp for 3.2 addition of 'command'
Branch: v3.2
https://github.com/mongodb/docs/commit/b423864b98c4d21b2e914c3dbeec6750f38d37e5

Comment by Githook User [ 09/Aug/17 ]

Author:

{'username': 'schmalliso', 'email': 'allison.moore@10gen.com', 'name': 'Allison Moore'}

Message: DOCS-10053: update currenOp.op for 3.2 addition of command
Branch: v3.4
https://github.com/mongodb/docs/commit/5f6231309d307b54195cbd9b8ea15fc6e333fda3

Comment by Githook User [ 09/Aug/17 ]

Author:

{'username': 'schmalliso', 'email': 'allison.moore@10gen.com', 'name': 'Allison Moore'}

Message: DOCS-10053: update currenOp.op for 3.2 addition of command
Branch: master
https://github.com/mongodb/docs/commit/a68d79402dabd712958d4e736ecf72786dea439d

Comment by Akira Kurogane [ 29/Mar/17 ]

For the curious this is what the currentOp output for an index build looks like in 3.4 on the primary:

{
	"inprog" : [
		{
			"desc" : "conn7",
			"threadId" : "140065978132224",
			"connectionId" : 7,
			"client" : "127.0.0.1:43972",
			"active" : true,
			"opid" : 57889,
			"secs_running" : 92,
			"microsecs_running" : NumberLong(92325339),
			"op" : "command",
			"ns" : "test.$cmd",
			"query" : {
				"createIndexes" : "foo",
				"indexes" : [  ... <the index spec(s)> ... ]
			},
			"msg" : "Index Build Index Build: 20164925/24165000 83%",
			"progress" : {
				"done" : 20164925,
				"total" : 24165000
			},
			"numYields" : 0,
			"locks" : { ... },
			"waitingForLock" : false,
			"lockStats" : { ... }
		}
	],
	"ok" : 1
}

And this is what it looks like on the secondaries. There will be one for each of the indexes in the index list above apparently. (I wonder if this means replication doesn't do bulk index builds on secondaries, but that's tangential to the doc fix request.)

{
	"inprog" : [
		{
			"desc" : "repl writer worker 0",
			"threadId" : "139837878322944",
			"active" : true,
			"opid" : 139460,
			"secs_running" : 1,
			"microsecs_running" : NumberLong(1500045),
			"op" : "none",
			"ns" : "test.system.indexes",
			"query" : <an index spec>,
			"msg" : "Index Build Index Build: 1784826/2493000 71%",
			"progress" : {
				"done" : 1784829,
				"total" : 2493000
			},
			"numYields" : 0,
			"locks" : { ... },
			"waitingForLock" : false,
			"lockStats" : { ... }
		}
	],
	"ok" : 1
}

Generated at Thu Feb 08 07:59:42 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.