Upgrading PGD clusters with TPA
===============================

..  Note No Postgres major version upgrades::
   TPA doesn't currently support major version upgrades of Postgres. The techniques outlined here can perform minor version upgrades of the PGD software and minor version upgrades of Postgres. To perform a major version upgrade of Postgres, see  :ref:`In-place Postgres major version upgrades <In-place Postgres major version upgrades>`  .

.. ::
   If you used TPA to install your cluster, you can also use TPA to upgrade your cluster. You can read more, in detail, about the capabilities of TPA upgrades in  :ref:`Upgrading your cluster <Deploying EDB Postgres Distributed using Trusted Postgres Architect>`  in the TPA documentation.

..  Warning Always test first::
   If possible, always test upgrade processes in a QA environment first to ensure there are no unexpected factors to be taken into account. TPA's ability to reproducibly deploy a PGD configuration makes it much easier to build a test environment to work with. !!!

Minor and major PGD upgrades
----------------------------

Minor version upgrades of PGD are managed automatically

Major version upgrades of PGD will require changes to the TPA
``config.yml`` file which contains the deployment configuration.

If you are upgrading to PGD 5, from previous PGD major versions, you
will be able to use :ref:`tpaexec reconfigure <Deploying EDB Postgres Distributed using Trusted Postgres Architect>`  to help you make appropriate
modifications to your deployment configuration.

The ``reconfigure`` command will require settings for architecture (only
``PGD_Always_ON`` and PGD Proxy routing to run. Remember to back up your
deployment configuration before running, and use the ``--describe`` and
``--output`` options to preview the reconfiguration.

Pre-requisites
--------------

-  The cluster configuration directory that was created when TPA
   deployed your PGD cluster.

-  If performing a major version upgrade of PGD, ensure that
   ``tpaexec reconfigure`` has been run and :ref:`appropriate configuration changes <#minor-and-major-pgd-upgrades>`  have been
   made.

Upgrading
---------

Run

::

   tpaexec upgrade clustername

Where **clustername** is the name of the cluster and the path to the
cluster configuration directory. By default, TPA will upgrade each node
of the cluster to the latest minor versions of the software the nodes
were configured with.

..  Note TPA's automated rolling upgrade procedure::
   TPA will test first the cluster then the nodes. Each node will then be isolated from the cluster, upgraded and then returned to operation within the cluster.

-  Checks that all preconditions for upgrading the cluster are met.

-  For each instance in the cluster, checks that it has the correct
   repositories configured and that the required postgres packages are
   available in them. \* For each BDR node in the cluster, one at a
   time: \* Fences the node off to ensure that pgd-proxy doesn’t send
   any connections to it. \* Stops, updates, and restarts postgres. \*
   Unfences the node so it can receive connections again. \* Updates
   pgbouncer, pgd-proxy, and pgd-cli, as applicable for this node.

!!!
