[SERVER-2740] Provide a quick way of finding out which mongos has balancer lock Created: 11/Mar/11  Updated: 27/Oct/15  Resolved: 09/Feb/15

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

Type: Improvement Priority: Minor - P4
Reporter: Kyle Banker Assignee: Unassigned
Resolution: Done Votes: 1
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Documented
is documented by DOCS-4801 Update sh.status() docs and document ... Closed
Backwards Compatibility: Fully Compatible
Participants:

 Description   

One way to accomplish this:

Store the host and port of the mongos that has the balancer lock within the balancer lock document in the config.locks collection.



 Comments   
Comment by Asya Kamsky [ 09/Feb/15 ]

This is now visible in the output of sh.status() as well as directly from sh.getBalancerLockDetails() helper function (it returns null if balancer lock isn't being "held")

From sh.status:

> sh.status()
--- Sharding Status ---
  sharding version: {
	"_id" : 1,
	"version" : 3,
	"minCompatibleVersion" : 3,
	"currentVersion" : 4,
	"clusterId" : ObjectId("51631b733fb8b29deb771db8")
}
  shards:
	{  "_id" : "shard1_replica_set",  "host" : "shard1_replica_set/192.168.102.212:37028,192.168.102.213:37028" }
	{  "_id" : "shard2_replica_set",  "host" : "shard2_replica_set/192.168.102.214:37029,192.168.102.215:37029" }
	{  "_id" : "shard3_replica_set",  "host" : "shard3_replica_set/192.168.102.216:37030,192.168.102.217:37030" }
  balancer:
	Currently enabled:  no
	Currently running:  yes
		Balancer lock taken at Wed Mar 12 2014 05:18:45 GMT-0400 (EDT) by blade4.xxx.com:61028:1390937310:1804289383:Balancer:846930886
  databases:

Helper function:

sh.getBalancerLockDetails()
{
	"_id" : "balancer",
	"process" : "blade4.xxx.com:61028:1390937310:1804289383",
	"state" : 2,
	"ts" : ObjectId("53202675fca32f8b900c05e3"),
	"when" : ISODate("2014-03-12T05:18:45.371-0400"),
	"who" : "blade4.xxx.com:61028:1390937310:1804289383:Balancer:846930886",
	"why" : "doing balance round"
}

Went into 2.7.5 as part of SERVER-8752 work.

Comment by Greg Studer [ 02/May/14 ]

This is now a request for a shell helper that summarizes distributed lock state - it would definitely help users who are experiencing network problems leading to stale locks.

Comment by Greg Studer [ 11/Mar/11 ]

can also add helper in shell, but useful to add port to id in any case

Comment by auto [ 11/Mar/11 ]

Author:

{u'login': u'gregstuder', u'name': u'gregs', u'email': u'greg@10gen.com'}

Message: Fix for SERVER-2740 add port to dist lock id
https://github.com/mongodb/mongo/commit/df2913a7a01ec911bc95be243df4ce718ba1dad4

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