Administering PGD Proxy#
Switching the write leader#
Switching the write leader is a manual operation that you can perform to
change the node that’s the write leader. It can be useful when you want
to perform maintenance on the current write leader node or when you want
to change the write leader for any other reason. When changing write
leader, there are two modes: strict and fast . In strict
mode, the lag is checked before switching the write leader. It waits
until the lag is less than route_writer_max_lag before starting the
switchover. This is the default. In fast mode, the write leader is
switched immediately. You can also set a timeout parameter to specify
the time when the method is strict. (Defaults to 30s)
!!!Note The set-leader operation is not a guaranteed operation. If, due to a timeout or for other reasons, the switch to the given target node fails, PGD may elect another node as write leader in its place. This other node can include the current write leader node. PGD always tries to elect a new write leader if the set-leader operation fails.
Using SQL#
You can perform a switchover operation that explicitly changes the node that’s the write leader to another node.
Use the bdr.routing_leadership_transfer() function.
For example, to switch the write leader to node node1 in group
group1 , use the following SQL command:
SELECT bdr.routing_leadership_transfer(group1, node1,strict,10s);
This command switches the write leader using strict mode and waits
for up to 10 seconds for the switchover to complete. Those are default
settings, so you can omit them, as follows:
SELECT bdr.routing_leadership_transfer(group1, node1);
Using PGD CLI#
You can use the group set-leader command to perform a switchover operation.
For example, to switch the write leader from node node1 to node
node2 in group group1 , use the following command:
pgd group group1 set-leader node1 --strict --timeout 10s
This command switches the write leader using strict mode and waits
for up to 10 seconds for the switchover to complete in strict mode.
Those are default settings, so you can omit them, as follows:
pgd group group1 set-leader node1