Automatically switch to primary on fail-back

I have a question about the fail-over of the replica set.
Replica set consists of primary (db1)-secondary (db2)-arbiter(db3).

It makes sense that primary (db1) goes down and secondary (db2) switches to new primary. But when I start the old primary (db1), it joins the replica-set as the secondary, and then automatically switches to the primary. (of course, the new primary(db2) became secondary again)

Is this a normal behavior?

Hi @minjeong.bahk,

In a default configuration all electable members of the replica set have the same priority so a former primary rejoining a replica set will not trigger an extra election after it has caught up.

It sounds like you have configured a higher priority for db1, which would result in the behaviour you observed. Have a look at the priority values set in your rs.conf() to confirm.

Another possibility would be coincidental timing of db2 being unavailable which would also lead to db1 becoming primary again. If this is the case you should be able to search your MongoDB server logs for REPL log lines that will confirm the events from the perspective of each replica set member.



Thank you for your help!
It was confirmed that each priority was 1 and 0.5. When I changed the priority and tested it again, it remained secondary!!

1 Like

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