[SERVER-8878] db.currentOp() and db.killOp() on a mongos should display the host the op is running on. Created: 06/Mar/13  Updated: 06/Dec/22  Resolved: 17/Apr/18

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: 2.4.1
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Osmar Olivo Assignee: [DO NOT USE] Backlog - Sharding Team
Resolution: Duplicate Votes: 2
Labels: MongosOperationManagement
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-29546 Add hostname to standard $currentOp o... Closed
Related
is related to SERVER-8136 allow db.currentOp() from mongos to s... Closed
Assigned Teams:
Sharding
Participants:

 Description   

Currently when you run db.currentOp on a mongos, it tells me which shard it is running on, but not necessarily which node (replica set member) it is running on. This would be particularly useful when running aggregation framework and mapreduces on secondaries to:

A: Confirm it is following your read preferences and running in the correct place.

B: Be able to kill these jobs when they are executing on secondaries.

Currently, it only gives the current operations on the primaries of each shard and doesn't allow you to kill ops on secondaries without logging on directly to that secondary.



 Comments   
Comment by Bernard Gorman [ 17/Apr/18 ]

osmar.olivo, kaloian.manassiev: this has already been implemented as part of the $currentOp aggregation stage (see abridged sample output below).

I'm going to close this as a dupe of SERVER-29546 - please let me know if you think it needs to be reopened for any reason.

mongos> use admin
mongos> db.getMongo().setReadPref("secondary")
mongos> db.aggregate([{$currentOp: {idleConnections: true}}])
...
{
	"shard" : "shard01",
	"host" : "SEELE:27019",
	"desc" : "ReplBatcher",
	"active" : true,
	"currentOpTime" : "2018-04-17T18:51:33.523+0100",
	"opid" : "shard01:9287",
	"op" : "none",
	"ns" : "",
	"command" : {
 
	},
	"numYields" : 0,
	"locks" : {
 
	},
	"waitingForLock" : false,
	"lockStats" : {
 
	}
}
{
	"shard" : "shard02",
	"host" : "SEELE:27022",
	"desc" : "ReplBatcher",
	"active" : true,
	"currentOpTime" : "2018-04-17T18:51:33.523+0100",
	"opid" : "shard02:9214",
	"op" : "none",
	"ns" : "",
	"command" : {
 
	},
	"numYields" : 0,
	"locks" : {
 
	},
	"waitingForLock" : false,
	"lockStats" : {
 
	}
}
{
	"shard" : "shard03",
	"host" : "SEELE:27025",
	"desc" : "ReplBatcher",
	"active" : true,
	"currentOpTime" : "2018-04-17T18:51:33.524+0100",
	"opid" : "shard03:9192",
	"op" : "none",
	"ns" : "",
	"command" : {
 
	},
	"numYields" : 0,
	"locks" : {
 
	},
	"waitingForLock" : false,
	"lockStats" : {
 
	}
}
...
{
	"shard" : "shard01",
	"host" : "SEELE:27019",
	"op" : "getmore",
	"ns" : "admin.$cmd",
	"command" : {
		"getMore" : NumberLong("7629546417730682760"),
		"collection" : "$cmd.aggregate",
		"batchSize" : NumberLong(101),
		"$db" : "admin"
	},
	"originatingCommand" : {
		"aggregate" : 1,
		"pipeline" : [
			{
				"$currentOp" : {
					"idleConnections" : true
				}
			}
		],
		"fromMongos" : true,
		"needsMerge" : true,
		"cursor" : {
			"batchSize" : 0
		},
		"$readPreference" : {
			"mode" : "secondary"
		},
		"$db" : "admin"
	},
}
...

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