The stopMonitoringGuard
is meant to remove the ReplicaSetMonitor for a new shard if the addShard() fails for any reason.
However, if the shard attempting to be added has the same setName as an existing shard's setName, the stopMonitoringGuard will use the existing shard's ReplicaSetMonitor and, on error, will remove that existing shard's ReplicaSetMonitor.
Potential fixes:
1) Check if a ReplicaSetMonitor for the new shard's setName exists, and fail immediately if so.
2) Make the stopMonitoringGuard only remove the ReplicaSetMonitor on failure if it actually created it (this seems less preferable - why would we ever want to use an existing ReplicaSetMonitor during addShard?).