pgd group set-leader
====================

Synopsis
--------

The ``pgd group set-leader`` command is used to set the write leader of
a group in the EDB Postgres Distributed cluster.

This command performs a switchover operation.

Users and roles
^^^^^^^^^^^^^^^

Requires the ``bdr_superuser`` role. See :ref:`User roles <User roles>`  .

Syntax
------

.. code:: plaintext

   pgd group <GROUP_NAME> set-leader [OPTIONS] <LEADER>

Where ``<GROUP_NAME>`` is the name of the group for which you want to
set the write leader and ``<LEADER>`` is the name of the node that you
want to set as the write leader.

Options
-------

The following table lists the options available for the
``pgd group set-leader`` command:

.. csv-table::
  :header: Short,Long,Description
  :widths: 12,10,25
  :align: left
  :class: longtable

  "",`--strict`,Strict method (default).
  "",`--timeout`,Timeout period when method is strict. (Defaults to 30s (30 seconds))
  "",`--fast`,Fast method.

Strict method is the default method. The strict method waits for the new
leader to be in sync with the old leader before switching the leader.
The fast method is immediate as it does not wait for the new leader to
be in sync with the old leader before switching the leader, ignoring
``route_write_max_lag`` .

See also `Global Options <https://www.enterprisedb.com/docs/pgd/latest/reference/cli/command_ref/#global-options>`_  .

Examples
--------

Setting the write leader of a group
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. code:: shell

   pgd group dc1_subgroup set-leader kaboom
   __OUTPUT__
   Command executed successfully

Setting the write leader when node is already the leader
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. code:: shell

   pgd group dc1_subgroup set-leader kaboom
   __OUTPUT__
   Node kaboom is already the write leader
