User interaction with the balancer could be improved.
Currently, to disable the balancer, users have to $set
{stopped: true}in the balancer document. This is error-prone (it'd be easy to misspell "stopped', etc.) and there's no feedback.
I propose a couple of commands for changing the balancer's state and getting the balancer's status.
For example:
db.runCommand(
{balancerstatus: 1})
Returns:
{ state: 1,
msg: "Balancing round"
ops: [
describe what's scheduled for this round / what's currently happening
]
}
db.runCommand(
{disablebalancer: 1})
This prints a message indicating current balancer state and blocks if balancer is in the middle of something.
db.runCommand(
{enablebalancer: 1})
Re-enables balancing.