This topic describes how to perform a major version upgrade for an ApsaraDB RDS for PostgreSQL instance with zero downtime.
Prerequisites
The instance runs ApsaraDB RDS for PostgreSQL 16 or an earlier version.
The storage type of the instance is disk.
NoteIf the instance uses high-performance local disks, you can only perform a major version upgrade in blue-green deployment mode.
The billing method of the instance is pay-as-you-go or subscription.
NoteIf the instance is a serverless instance, you can only perform a major version upgrade in blue-green deployment mode.
The instance is not a read-only instance or a dedicated cluster instance.
The
wal_levelparameter of the instance is set tological. If it is not, modify the instance parameters.Babelfish is not enabled for the instance. The minor engine version number does not end with
babelfish.
Background information
In zero-downtime mode, the system uses pg_upgrade to upgrade the source instance to the destination version and implements incremental updates using native logical replication. You can perform an active switchover during the upgrade and verify the destination instance before the switchover. The instance can perform normal read and write operations from the start of the upgrade until the active switchover. During the switchover, the instance is in read-only mode for only a few seconds.
In the ApsaraDB RDS console, you can also upgrade the major version of a database in blue-green deployment mode or local upgrade mode. For a comparison of different modes, see Introduction to major version upgrade solutions.
Upgrade fees
Free of charge.
Precautions
Business impact: The impact on your services is minimal. The downtime for the source instance is measured in seconds. The duration of the downtime depends on the number of sequences and large transaction writes on the instance.
Replication slots:
If the source instance has a publishing end of a replication slot, the replication slot is lost after the upgrade.
If the source instance has a subscribing end of a replication slot, the upgrade may cause data synchronization issues due to replication slot preemption. For a solution, see How do I prevent data synchronization issues caused by replication slot preemption during an upgrade?
Parameter changes:
If the source instance uses parameters that are not supported by the destination version, these parameters are automatically deleted in the destination version.
If the value of a parameter in the source instance is outside the valid range for the corresponding parameter in the destination version, the parameter is set to the default value of the parameter template for the destination version.
During the upgrade, the system temporarily changes the value of
statement_timeoutto 0 and restores it to the initial value after the upgrade is complete.
DTS tasks: If the instance to be upgraded is a source or destination instance for Data Transmission Service (DTS), you need to recreate the DTS task after the upgrade.
Plugin compatibility issues: When you perform a major version upgrade, the system automatically updates the instance to the latest minor engine version. This may cause plugin compatibility issues.
Instance backup: A full backup is performed on the instance before and after the upgrade. This allows for subsequent clone-based recovery.
Impact on the instance at different upgrade stages
Upgrade stage | Impact |
Start the major version upgrade | DDL operations are prohibited. |
Create replication slots and publications |
|
Start the subscriber and establish a logical replication relationship |
|
Start the switchover |
|
Complete the switchover (upgrade complete) |
|
After the upgrade task starts, go to the Upgrade History tab. In the Upgrade Log column of the target upgrade task, click View Information to view the detailed upgrade process.
Step 1: Perform a pre-upgrade check
Log on to the ApsaraDB RDS console and go to the Instances page. In the top navigation bar, select the region in which the RDS instance resides. Then, find the RDS instance and click the ID of the instance.
In the navigation pane on the left, click Major Version Upgrade.
NoteIf Major Version Upgrade does not appear in the navigation pane on the left, check the version and configuration of your ApsaraDB RDS for PostgreSQL instance. For more information, see Prerequisites.
On the Upgrade Check tab, click Create upgrade check report.
Select the destination version. Set Upgrade Mode to Zero Downtime. Then, click OK.
The instance status changes to Maintaining Instance. After the pre-upgrade check is complete, the instance status changes to Running.
If the result of the upgrade check report is Success or Warning, you can proceed with the major version upgrade. If the result is Failed, click View Information. Fix the abnormal items based on the report. Then, perform the pre-upgrade check again. For more information about common errors and their causes, see Interpret an ApsaraDB RDS for PostgreSQL major version upgrade check report.
ImportantTo ensure a successful upgrade, if the check result is Warning, we recommend that you fix the abnormal items based on the report and perform the pre-upgrade check again until the result is Success.
After the pre-upgrade check is successful, if you create a plugin on the primary instance, you must perform the check again.
Step 2: Upgrade the major version
Click the Upgrade Instance tab and read the warnings. Then, select a version from Select The Destination Version and click Create Upgrade Task.
In the dialog box that appears, read the prompt and click OK.
In the Create Major Engine Version Upgrade Task section, set Upgrade Mode to Zero Downtime.
Click Create.
When the instance status changes to Migrating, the upgrade task has started.
The time required for the upgrade is closely related to the number of database objects in the instance. The more database objects there are, the longer the upgrade takes. During a major version upgrade, you can view the upgrade progress in the Task Hub.
ImportantYou cannot modify or delete an upgrade task after it is created.
When the source instance is in the Migrating state, operations and maintenance (O&M) tasks such as modifying parameters, restarting the instance, or releasing the instance are not supported.
Step 3: Switch to the new version
Verify the destination instance.
When the instance status changes from Migrating to Migrating Data Out, logical replication is set up and the upgrade task creation is complete. You can then verify the data on the destination instance.
Go to the Upgrade History tab. Use the Later Version Verification URL from the target upgrade record to connect to the destination instance and verify the upgraded data.
NoteThe destination instance is in read-only mode. You cannot perform write operations.
Switch to the destination instance.
After you confirm that the data on the destination instance meets your expectations and the Upgrade Result is Synchronizing, in the Upgrade Log column, click Switchover to switch your services to the destination instance.
NoteIf the Upgrade Result is in another state, see Upgrade result descriptions for information about how to proceed.
If you decide to abandon this upgrade, in the Upgrade Log column, click Cancel. This action deletes the logical replication slot, cancels the impact of logical replication on the source instance, and allows it to perform Data Definition Language (DDL) operations.
In the Switchover dialog box, set Write Downtime Tolerance (in seconds) and click OK.
When the Upgrade Result changes to Read-only, the switchover is in progress and the instance status is Migrating. On the Upgrade History tab of the Major Version Upgrade page, you can click the Interrupted button in the Upgrade Log column to cancel the switchover.
NoteYou can set the Write Downtime Tolerance during the switchover to actively wait for the replication delay to be eliminated. This ensures data consistency. During this process, the Upgrade Result changes to Read-only. If the time limit is exceeded, the system returns to the Synchronizing state and removes the read-only restriction.
View the switchover result.
When the Upgrade Result changes to Succeeded, the switchover is successful. The instance status is Running.
On the Basic Information page of the instance, you can view the current version information of the instance.
NoteAfter the upgrade is complete, go to the Upgrade History tab. In the Upgrade Log column of the target upgrade task, click View Information to view the read-only time of the instance and the detailed upgrade process. The read-only time is the period between the Switching time and the Switching completion time. This period does not include the time when the instance is unreachable because the DNS cache is not purged.
Upgrade result descriptions
During the upgrade process, the upgrade record on the Upgrade History tab shows one of the following Upgrade Result values.
Upgrade result | Instance status | Description | Available actions |
Running | Migrating | The upgrade task is running. | None. |
Synchronizing | Migrating Data Out | Logical replication is normal. |
|
Replication Interrupted | Migrating Data Out | Logical replication is abnormal. |
|
Read-only | Migrating | The switchover is in progress. The instance is in read-only mode, and sequences are being synchronized. | Break: Cancel this switchover. |
Switchover | Migrating | Sequence synchronization is complete. Finalizing the process. | None. |
Cancel | Running | The upgrade task is canceled. | None. |
Succeeded | Running | The upgrade task is successful. | None. |
Related API operations
API operation | Description |
Performs a pre-upgrade check for a major version upgrade of an ApsaraDB RDS for PostgreSQL instance. | |
Queries the pre-upgrade check report for a major version upgrade of an ApsaraDB RDS for PostgreSQL instance. | |
Upgrades the major version of an ApsaraDB RDS for PostgreSQL instance. | |
Queries the historical tasks of major version upgrades for an ApsaraDB RDS for PostgreSQL instance. |
References
Perform a major version upgrade in blue-green deployment mode
Perform a major version upgrade in local upgrade mode
Interpret an ApsaraDB RDS for PostgreSQL major version upgrade check report