MAAS 3.6, which supports PostgreSQL 16, requires Ubuntu 24.04 LTS. Upgrade your system to this release before proceeding with the PostgreSQL upgrade.
You should upgrade the node Ubuntu distribution to 24.04 LTS before attempting to upgrade MAAS, so plan your maintenance window appropriately. Note that you might be required to upgrade PostgreSQL to version 16 before continuing with the MAAS upgrade.
Always back up your PostgreSQL data before performing a major upgrade.