Upgrading to a new major version

Choose an upgrade path:

For the last two paths, validate the new deployment before switching your application's connection details. Promotion ends replication from the source.

Find versions available for new deployments in the catalog, with ibmcloud cdb deployables-show, or through the /deployables API.

In API examples, replace {id} with the deployment's URL-encoded Cloud Resource Name (CRN), and <IAM_TOKEN> with your Identity and Access Management (IAM) access token.

Requirements for upgrading

Application compatibility

Test your chosen upgrade path on a representative staging deployment before production. For an IPMVU rehearsal, restore a recent backup to the source PostgreSQL version, then upgrade it to your intended target. Check application queries, background jobs, drivers, extensions, and connection pools, and record performance for comparison afterward. Review the target version's release notes and role-privilege changes.

Extensions and replication objects

Complete the applicable preparation below before upgrading. Plan for any application dependencies on objects that you remove.

Extensions

pg_repack

Drop pg_repack before the upgrade. Recreate it afterward if needed; its extension and client components must match the PostgreSQL major version.

DROP EXTENSION pg_repack;

After the upgrade:

CREATE EXTENSION pg_repack;
old_snapshot

old_snapshot is unavailable in PostgreSQL 17 and later. IPMVU attempts to remove it when upgrading to these versions, without deleting dependent objects. Resolve reported dependencies before retrying. For other upgrade paths, contact support to arrange removal.

anon

If anon is installed, run these steps as the admin user in each affected database.

Before removing masking rules, block database access for users who must see masked data. Keep their access blocked until you restore and verify the masking rules and role settings after the upgrade.

  1. Remove all masking rules (if enabled).

    SELECT anon.remove_masks_for_all_columns();
    
  2. Disable masking roles (the upgrade might fail if any roles are marked as masked).

    SECURITY LABEL FOR anon ON ROLE <role_name> IS NULL;
    
  3. Drop the anon extension with the cascade option.

    DROP EXTENSION anon CASCADE;
    
  4. After the upgrade, re-enable anon, restore its masking rules and role settings, and verify masking before restoring affected users' access.

PostGIS

Upgrade PostGIS before PostgreSQL:

SELECT postgis_extensions_upgrade();

Verify the extension version:

SELECT postgis_full_version();

Logical replication slots

IPMVU is blocked while any logical replication slots remain, including inactive slots and those used by wal2json. Before removing them:

  1. Pause source writes until slots and consumers are restored after the upgrade, or plan to resynchronize downstream data.

  2. Let consumers process pending changes, then stop them.

  3. Drop each logical slot:

    SELECT pg_drop_replication_slot('<slot_name>');
    

Do not remove service-managed physical replication slots. A new logical slot cannot recover unconsumed changes from a deleted slot.

wal2json is a logical decoding output plug-in, not an extension created with CREATE EXTENSION.

In-place major version upgrade

Complete preparation, then use the UI, API, CLI, or Terraform procedure below.

You cannot cancel IPMVU after it starts or downgrade the deployment in place.

Availability during an upgrade

Compatibility checks run while the deployment is online. Database upgrade then requires a read-only period and temporary unavailability. Writes can resume before the task finishes, but further connection interruptions can occur during the remaining work.

Applications must handle connection failures and read-only errors, reconnect, and retry interrupted transactions only when safe. Connection pooling does not remove these requirements. Application access is not proof that the upgrade task completed.

Backups and recovery

Create and verify a recent on-demand backup before IPMVU; the service does not automatically take a pre-upgrade data backup. Recovery might require restoring that backup into a new deployment. Account for changes made since the backup.

The service queues a backup of the upgraded deployment to run separately after the upgrade task completes. Its duration does not extend the upgrade task. It might not start immediately. Check its status in Backups and restore.

Recovery of post-upgrade changes requires a successful backup of the upgraded deployment. Point-in-time recovery (PITR) also requires the corresponding transaction logs. PITR cannot replay transactions across the major version upgrade. Pre-upgrade backups and recovery points belong to the earlier version and remain subject to retention limits. See PITR.

If the queued backup fails, take an on-demand backup. Contact support if failures continue. A backup failure does not roll back the upgrade.

Before you begin

Apply these requirements to both staging and production:

  • Complete the application, extension, and replication preparation and backup preparation.

  • Confirm that all data members are healthy and replication is caught up. Let maintenance and other deployment changes finish.

  • Keep at least 10% of allocated disk space free on each data member. Resolve sustained CPU, memory, or disk I/O pressure. Scale up your deployment as needed before starting IPMVU.

  • Promote attached read-only replicas that you need to retain; delete only those no longer needed. IPMVU cannot run on a read-only replica deployment or with external replication consumers connected. Built-in high-availability members are upgraded with the source. See Read-only replicas and IPMVU.

  • Have the owning application or transaction manager resolve prepared transactions. Do not commit or roll them back solely to clear a precheck.

  • Choose a target from your deployment's capabilities. Availability for new deployments does not guarantee an IPMVU transition:

    ibmcloud cdb deployment-capability-show <NAME|CRN> versions
    

Service prechecks cover deployment health, resources, replication, database compatibility, and transaction-log archiving before writes are interrupted. Passing prechecks does not guarantee application compatibility or prevent every later failure.

Planning the upgrade window

Use your staging rehearsal to estimate a maintenance window. Database size, object counts, workload, replication health, and additional data copying affect duration. Allow for the whole upgrade task and delays.

Expiration sets the latest time a queued upgrade can start; it does not stop a running upgrade. For example, a queued request expires at 22:30 UTC. A task started at 22:25 UTC can continue past that time.

Upgrading in the UI

  1. On the prepared deployment's Overview page, click Upgrade major version.
  2. Select an available target and a start expiration, then submit the upgrade.
  3. Monitor the task until it succeeds, then complete After the upgrade.

Upgrading through the API

Use an available target version from your deployment's capabilities. The following example upgrades to PostgreSQL 15 when that transition is supported:

curl -X PATCH https://api.{region}.databases.cloud.ibm.com/v5/ibm/deployments/{id}/version \
  -H 'Authorization: Bearer <IAM_TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '{"version": "15"}'

Use the returned task ID with Get task information to monitor completion. An accepted request is not a completed upgrade. For parameters, including start expiration, see the API reference.

Upgrading through the CLI

Use version 0.20.0 or later of the Cloud Databases CLI plug-in:

ibmcloud cdb deployment-version-upgrade <NAME|CRN> <TARGET_VERSION>

Set start expiration with --expire-in or --expire-at, between 5 minutes and 24 hours from the request. Run ibmcloud cdb deployment-version-upgrade --help for parameters.

Monitor the task with deployment-tasks-list:

ibmcloud cdb deployment-tasks-list <NAME|CRN>

Upgrading through Terraform

Use IBM Cloud® Terraform provider version 1.79.2 or later. Set version to an available target, review the plan, and apply it.

Ensure that the resource's update timeout is long enough for the operation to complete. The provider also derives the start expiration time from the configured timeout value, up to a maximum of 24 hours. For more information, see database resource reference.

After the upgrade

After the upgrade task completes successfully:

  1. Confirm the expected PostgreSQL version.
  2. Restore extensions and masking as described in preparation. Recreate required logical replication slots and read-only replicas, reconnect consumers, and complete any required data resynchronization before resuming dependent applications.
  3. Review optimizer statistics after the upgrade. PostgreSQL 14 through 17 do not transfer optimizer statistics during a major version upgrade, whereas PostgreSQL 18 transfers most optimizer statistics. Follow the PostgreSQL 17 or PostgreSQL 18 post-upgrade instructions for your target.
  4. Compare application behavior and performance with your staging results.
  5. Verify the post-upgrade backup.

Troubleshooting

For a precheck failure, use the reported error and monitoring metrics to identify the unmet prerequisite, resolve it, and retry. Do not delete database objects or transaction logs just to bypass a check.

If you cannot resolve a precheck error, the upgrade fails, or the deployment remains unavailable, contact support before making further deployment changes. Include the task ID, target version, and relevant task, database, or application errors.

Upgrading from a read-only replica

Create a read-only replica from the source deployment and wait for the replica to synchronize. Then, promote and upgrade the replica by using the /remotes/promotion endpoint, specifying a supported target version:

curl -X POST \
  https://api.{region}.databases.cloud.ibm.com/v5/ibm/deployments/{id}/remotes/promotion \
  -H 'Authorization: Bearer <IAM_TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '{
    "promotion": {
        "version": "14",
        "skip_initial_backup": false
    }
}'

Set skip_initial_backup to true only if you want to skip the initial backup that is created during promotion. Although this setting can reduce the time required to complete the promotion task, recovery from the promoted deployment requires a later successful scheduled or on-demand backup.

Dry running the promotion and upgrade

A dry run validates the promotion and upgrade process without performing the actual conversion. Review the results through log integration. A successful check does not guarantee that the actual upgrade will succeed.

Specify the target version, dry_run: true and skip_initial_backup: false:

curl -X POST \
  https://api.{region}.databases.cloud.ibm.com/v5/ibm/deployments/{id}/remotes/promotion \
  -H 'Authorization: Bearer <IAM_TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '{
    "promotion": {
        "version": "14",
        "skip_initial_backup": false,
        "dry_run": true
    }
}'

Back up and restore upgrade

Restore a backup to a deployment that uses a supported target version. By default, the restored deployment inherits the source deployment's disk and memory allocations from the time that the backup was created.

Upgrading in the UI

From Backups in the deployment dashboard, click Restore for the backup that you want to use. Select a supported target version and configure the options for the new deployment. Then, click Create.

Upgrading through the CLI

Create the deployment with the target version and backup ID in the -p JSON argument:

ibmcloud resource service-instance-create example-upgrade databases-for-postgresql standard us-south \
  -p '{
  "backup_id": "crn:v1:bluemix:public:databases-for-postgresql:us-south:a/54e8ffe85dcedf470db5b5ee6ac4a8d8:1b8f53db-fc2d-4e24-8470-f82b15c71717:backup:06392e97-df90-46d8-98e8-cb67e9e0a8e6",
  "version": "14"
}' \
  --service-endpoints "public"

Upgrading through the API

Use the Resource controller API to restore a backup to a deploymentet version. Specify the deployment name, location, resource group, plan, backup ID, and target version:

curl -X POST \
  https://resource-controller.cloud.ibm.com/v2/resource_instances \
  -H 'Authorization: Bearer <IAM_TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "my-instance",
    "target": "bluemix-us-south",
    "resource_group": "5g9f447903254bb58972a2f3f5a4c711",
    "resource_plan_id": "databases-for-postgresql-standard",
    "parameters": {
      "backup_id": "crn:v1:bluemix:public:databases-for-postgresql:us-south:a/54e8ffe85dcedf470db5b5ee6ac4a8d8:1b8f53db-fc2d-4e24-8470-f82b15c71717:backup:06392e97-df90-46d8-98e8-cb67e9e0a8e6",
      "version": "18"
    }
  }'

Forced upgrade

After the end-of-life date, all active Databases for PostgreSQL deployments that run the deprecated version are automatically upgraded to the next supported version.

Upgrade before the end-of-life date to avoid the following risks:

  • No SLAs are provided for this type of forced upgrade.
  • You might experience some data loss.
  • Your application might experience prolonged downtime.
  • Your application might stop working if it is incompatible with the new version.
  • You cannot control the timing of when this upgrade will happen for your deployment.
  • There is no rollback process for this forced upgrade.

For the end-of-life dates, see the version policy page.

Role privilege issues during version upgrades

PostgreSQL 16 and later require ADMIN OPTION on a role to grant or revoke its membership. Before you upgrade, review the role grants that are required for continued role management. For more information, see the PostgreSQL 16 release notes, role attributes and role grants.

An upgraded deployment might report:

ERROR: only roles with the ADMIN OPTION on role "some_role" may grant this role

For deployments upgraded from PostgreSQL 14 or 15 to PostgreSQL 16 or later, the admin user can run the following helper to grant the affected roles to admin with ADMIN OPTION. The helper can be run safely more than once:

SELECT grant_admin_option_to_roles('role1', 'role2', 'role3');

Changelog for major PostgreSQL versions