rs.stepDown() Question

I have 3 node P-S-S.

In Primary, I did “rs.stepDown(20)”

Then, replica set become S-P-S for 20 sec.

Then, replica set will be P-S-S.

However, it was not.

  1. What is “rs.stepDown”'s first option meaning

  2. If what I know is right, why not come back?

please help me, and thank you

Hi @Kim_Hakseon!

In a replica set, the servers will communicate with each other and decide on a machine to become primary. Any of the machines in the cluster can become primary.

Whichever machine is primary will stay the primary unless something happens which means it can’t be primary any more, such as a reboot, or a call to stepDown. At that point another machine in the cluster (if possible) will be elected the new primary.

At this point, the same rules apply - the new machine will stay primary until something happens to stop it.

The first option to stepDown is the amount of seconds during which the primary you are stepping down is not allowed to be primary, but that doesn’t mean it will automatically become primary again after 20 seconds.

When you’ve called stepDown(20) you’ve forbidden the primary you’re connected to from becoming primary again for 20 seconds, but unless a new election happens after that time, the machine will stay as a secondary indefinitely.

Here’s the documentation for this call, in case you need more details.

Oh, I was mistaken.

Thank you. :smiley:

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.