Here is a stupid MongoDB Trick for someone who accidentally tells their primary to step down and not be eligible for election for some number of seconds - and that number is higher than they intended.
How do you cut that time short?
Normally when you run:
rs.stepDown(120)
your primary will step down (relinquish its Primary role) and it won't be eligible to be re-elected for two minutes. What if you realize that you didn't really mean to do this, or whatever you meant took about 5 seconds instead of 120?
You can't do another rs.stepDown with a different time value, because it will rightfully give you an error saying it cannot step down, not being a primary.
But what you can do is use the rs.freeze() command - this would normally be run on a secondary to prevent it from being eligible for the election for some number of seconds, but it has a special treatment for being passed 0 seconds:
rs.freeze(0)
{ "info" : "unfreezing", "ok" : 1 }
Well, isn't that convenient!
How do you cut that time short?
Normally when you run:
rs.stepDown(120)
your primary will step down (relinquish its Primary role) and it won't be eligible to be re-elected for two minutes. What if you realize that you didn't really mean to do this, or whatever you meant took about 5 seconds instead of 120?
You can't do another rs.stepDown with a different time value, because it will rightfully give you an error saying it cannot step down, not being a primary.
But what you can do is use the rs.freeze() command - this would normally be run on a secondary to prevent it from being eligible for the election for some number of seconds, but it has a special treatment for being passed 0 seconds:
rs.freeze(0)
{ "info" : "unfreezing", "ok" : 1 }
Well, isn't that convenient!