IBM Cloud Databases for PostgreSQL offers two direct ways to perform a major version upgrade:
Unfortunately, both processes involve a period of time during which writes to the database must be suspended to prevent data from being lost following the upgrade.
When upgrading from IBM Cloud Databases for PostgreSQL versions 10+, a new process is available via PostgreSQL logical replication that allows continued writes to the database during and after the upgrade, requiring only a momentary interruption while application(s) are reconfigured to write to the upgraded database instance. This post walks through how to execute the process and discusses some of the caveats and limitations associated with it.
Note: We recommend testing the procedure described below in a non-production environment first to get familiar with it and identify any issues that may occur before attempting the upgrade against any production database instances.
First, you’ll need to prepare the original database instance to be upgraded:
wal_*
configuration and set a password for the repl
user):repl
) user permission to read all tables you want to migrate using GRANT SELECT {…} TO repl;
:GRANT SELECT ON ALL TABLES IN SCHEMA {schema} TO repl;
, filling in the {schema}
name as appropriate.GRANT
command is described in more detail in the PostgreSQL documentation.ibmcloud cdb deployment-connections
CLI.Next, to perform the upgrade:
pg_dump --schema-only/pg_restore
to migrate the DDL.pg_dump
is described in more detail in the PostgreSQL documentation (link resides outside of ibm.com).CREATE PUBLICATION {schema}_migration FOR TABLE {table}, {table}, {...};
, filling in the {table}
names and {schema}
as needed.SELECT create_subscription('{schema}_subscription', '{hostname}', '{port}', '{password}', 'repl', 'ibmclouddb', '{schema}_migration');
, filling in the fields as needed.SELECT slot_name, confirmed_flush_lsn, pg_current_wal_lsn(), (pg_current_wal_lsn() - confirmed_flush_lsn) AS lsn_distance FROM pg_replication_slots;
:lsn_distance
has reduced to zero), reconfigure your application(s) to begin writes to the target instance rather than the source.After verifying that the upgrade completed successfully, clean up as follows:
SELECT delete_subscription(‘{schema}_subscription’, ‘ibmclouddb’);
.Regularly scheduled maintenance performed by IBM Cloud Databases may impact the migration process and require it to be restarted. In that case, there should be no impact to running application(s) as the original database instance will continue to operate normally until the very end of the procedure.
The migration process has the same limitations as PostgreSQL logical replication, including the following:
See the PostgreSQL logical replication documentation (link resides outside of ibm.com) for more details.
Get started with IBM Cloud Databases for PostgreSQL.