yugabytedb

Forcing a leader change in YugabyteDB cluster


[Question posted by a user on YugabyteDB Community Slack]

Is there a way to force a leader change in YugabyteDB? I see there is a yb-admin command 'master_leader_stepdown' but the documentation mentions a possible downtime.


Solution

  • Its a raft group, so leader election should kick in quickly. From the moment a leader steps down, until a new one is elected, any change in the metadata of the cluster will not go through. This is typically ~3 seconds. For yb-master, there is yb-admin master_leader_stepdown command https://docs.yugabyte.com/preview/admin/yb-admin/#master-leader-stepdown.

    yb-admin \
        -master_addresses <master-addresses> \
        master_leader_stepdown [ <new_leader_id> ]
    

    You can also choose the next leader by providing the id rather than waiting for an automatic election.