This topic describes how to upgrade the major version of an ApsaraDB RDS for PostgreSQL database using the blue-green deployment method.
Prerequisites
The instance runs RDS PostgreSQL 16 or an earlier version.
The instance is not a read-only instance or a cluster instance.
Babelfish is not enabled for the instance. This means that the minor version number does not contain the
babelfishsuffix.
Background information
In a blue-green deployment, the source instance is restored to a new instance. Then, pg_upgrade is used to upgrade the new instance to the target version. If you perform a cutover, the endpoint of the source instance is automatically switched to the new instance.
The ApsaraDB RDS for PostgreSQL console also supports upgrading the major database version using the zero-downtime mode and local upgrade mode. For a comparison of the different modes, see Introduction to major version upgrade solutions.
Upgrade fees
When you upgrade a major version using blue-green deployment, the system creates a new instance based on the source instance. After the upgrade is complete:
The source instance and the new instance are both billed.
The billing method and fees for the source instance remain unchanged.
The billing method for the new instance may be different from that of the source instance.
Billing method of the source instance
Billing method of the new instance
Subscription/Pay-as-you-go
Pay-as-you-go
Serverless
Serverless
NoteTo save costs, after the services on the new instance are running stably, we recommend that you convert the new instance to a subscription and release or unsubscribe from the source instance. However, note the following:
If your source instance is a subscription instance that has not expired, the new instance cannot inherit the remaining subscription duration. Releasing the source instance may result in a financial loss. For more information about unsubscription rules, see the Refund policy.
The new instance does not inherit any discounts that were applied to the source instance. You can view the specific refund amount on the instance unsubscription page before you decide whether to upgrade.
The refund amount and timing for a subscription instance are subject to the actual unsubscription bill. The refund is not processed in real time.
Precautions
Service impact: When you upgrade using blue-green deployment with a cutover, the source instance is set to read-only during the cutover process. This causes a transient connection interruption that lasts for several minutes. We recommend that you perform the upgrade during off-peak hours. If you choose not to perform a cutover, your services are not affected.
The duration for which the source instance is read-only depends on the number of database objects. The more database objects the instance has, the longer the read-only duration. If the number of database objects reaches millions, the read-only duration can be tens of minutes or even hours. You can run the
SELECT count(1) FROM pg_class;command to view the number of database objects.The transient connection interruption duration as perceived by the client depends on the DNS cache refresh time. You can switch the virtual switch and use the service interruption duration to estimate the client's DNS cache refresh time.
The duration of the upgrade process depends on the number of database objects in the instance. The more database objects an instance has, the longer the upgrade takes. For major version upgrades, you can view the task progress in the Task Hub.
For blue-green deployments, if you do not want the source instance to be set to read-only after the switchover, you must set the
rds_force_trans_ro_non_supparameter tooffafter the upgrade. For more information, see Set instance parameters.
Cross-version upgrades: ApsaraDB RDS for PostgreSQL 9.4 and 10 instances that use high-performance local disks can only be upgraded to instances that use cloud disks. You can upgrade them to a maximum version of ApsaraDB RDS for PostgreSQL 14. To upgrade to PostgreSQL 15 or a later version, you must first upgrade to an intermediate version (PostgreSQL 9.4 can be upgraded to 10, 11, 12, 13, or 14; PostgreSQL 10 can be upgraded to 11, 12, 13, or 14), and then upgrade to PostgreSQL 15 or a later version.
Replication Slots:
If the source instance is a publisher with replication slots, the replication slots are lost after the upgrade.
If the source instance is a replication slot subscriber, an upgrade may cause data synchronization issues due to replication slot preemption. To resolve this issue, see How to prevent data inconsistency caused by replication slot preemption during an upgrade.
Virtual IP: For a blue-green deployment with a cutover, the virtual IP address of the new instance changes after the upgrade. You must check the network connectivity, such as firewall configurations.
Impact of virtual IP change: If you have configured the virtual IP in your application, you must modify the application configuration to point to the new instance's virtual IP.
Recommendation: To avoid the complexity of manual configuration, we recommend that you directly configure the connection address of the instance in your application. For more information about how to obtain the connection address, see View or modify connection addresses and ports.
Parameter changes:
If the original instance uses parameters that are not supported by the new version, these parameters are automatically deleted in the new version.
If the value of a parameter in the original instance is not within the valid range of the corresponding parameter in the new version, the parameter is set to the default value in the parameter template of the new version.
During the upgrade, the system temporarily changes the value of the
statement_timeoutparameter to 0 and restores the parameter to its original value after the upgrade is complete.
DTS tasks: If the instance to be upgraded is the source or destination instance of a Data Transmission Service (DTS) task, you must recreate the DTS task after the upgrade.
Plugin compatibility issues: When you perform a major version upgrade, the system automatically updates to the latest minor engine version, and you may encounter plugin compatibility issues.
A new instance does not inherit the Instance Name, tags, CloudMonitor alert rules, or backup data of the source instance.
Step 1: 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.
(Optional) If a read-only instance exists for the source instance, change the read-only instance endpoint in your application to the primary instance endpoint, and then delete the read-only instance.
NoteTo ensure service stability, change the application endpoint during off-peak hours.
In the navigation pane on the left, click Major Version Upgrade.
NoteIf Major Version Upgrade is not displayed 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 upgrade version, set Upgrade Mode to Blue-green Deployment, and then click OK.
The instance status changes to Maintaining Instance. After the 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 subsequent steps of the major engine version upgrade. If the result is Failed, click View Information, fix the abnormal check items based on the report content, and then perform the pre-upgrade check again. For more information about common errors and causes, see Understand the major engine version upgrade check report of an RDS PostgreSQL instance.
ImportantTo ensure a smooth upgrade, if the result of the upgrade check report is Warning, we recommend that you fix the abnormal check items based on the report content and then perform the pre-upgrade check again until the check result is Success.
If you create an extension in the primary instance after the upgrade check is successful, you must perform the check again.
Step 2: Upgrade major version
Click the Upgrade Instance tab, read the warning message, select a version under Select upgrade version, and then click Create Upgrade Task.
In the dialog box that appears, read the message and click OK.
In the Create Major Engine Version Upgrade Task section, Upgrade Mode is set to Blue-green Deployment. Configure the upgrade parameters. The following table describes only the key parameters.
Configuration
Description
Storage type
The new instance supports only enterprise SSDs (ESSDs) and premium performance disks. If you select ESSD, you can change the performance level (PL).
The storage class of the new instance must be the same as that of the source instance.
NoteThe minimum storage capacity of an ESSD varies based on the PL. When you change the PL, the minimum storage capacity of the instance is automatically adjusted based on the selected PL. Make sure that the new value meets the requirements.
If the source instance uses a high-performance local disk, the new instance can only use ESSDs.
The Available Zone
The system lets you configure the new primary and secondary instances in different zones after the upgrade. Set these parameters as needed.
For Available Zone
Primary Instance Switch
Standby Instance Switch
Cutover configuration
Select whether to switch traffic to the new instance based on your requirements.
No cutting: The traffic is not automatically switched. This option is typically used to test the compatibility of your services with the new version before the official upgrade.
Cutover: The traffic is automatically switched. This option is typically used for the official upgrade after you confirm that your services can run stably on the new version. After the cutover, your application is automatically connected to the new instance. You do not need to change the database endpoint in your application.
NoteYou cannot roll back after a cutover. Select this option with caution.
During the cutover, the source instance is set to read-only, which causes a transient connection that lasts for minutes. Perform the upgrade during off-peak hours. If you choose not to perform a cutover, your services are not affected.
We recommend that you select No cutting for your first attempt. After you fully test and verify the application layer, release the new instance, repeat the upgrade operation, and then select Cutover to begin the formal upgrade.
Storage space
Select the storage capacity for the new instance.
Instance specification
Specify the instance type of the new instance. For more information, see List of Primary Instance Types.
Click Create now.
When the instance status changes to Migration in Progress, the upgrade task has started.
The time required for an 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.
ImportantAfter an upgrade task is created, it cannot be modified or deleted.
When the source instance is in the Migration in Progress state, you cannot perform O&M operations such as modifying parameters, restarting, or releasing the instance.
If the Insufficient Resources message appears when you create the task, switch the Target Primary Zone.
View the upgrade result.
When the status of both the source and new instances is Running, the upgrade is successful.
NoteFor blue-green deployment with cutover, traffic is automatically switched to the new (higher-version) instance after the upgrade.
For blue-green deployment without cutover, traffic is not switched to the new (higher-version) instance after the upgrade.
After the upgrade is complete, on the Upgrade History tab, click View Information in the Upgrade Log column for the target upgrade task. You can view the read-only duration of the instance and the detailed upgrade process. The read-only duration is the period between the Cutover Time and the Cutover End Time. This period does not include the time during which the instance is unreachable because the DNS cache is not refreshed.
For blue-green deployment without cutover, the system also displays the Cutover Time and Cutover End Time for your reference and estimation in a cutover scenario.
What to do next
If you upgrade an instance using the blue-green deployment (cutover) pattern, promptly release the source instance after you confirm that your services are running stably on the new instance.
We also recommend that you change the billing method for the new instance to subscription for cost savings.
NoteIf you release a subscription instance before its expiration date, you may incur a loss.
If you received a discount when you purchased the source instance, the new instance does not inherit this discount. The unsubscription of the source instance is subject to the actual unsubscription page.
The refund amount and timing for a subscription instance are subject to the actual unsubscription bill. The refund is not processed in real time.
(Optional) The new instance does not include read-only instances. If you deleted a read-only instance before the upgrade, perform the following steps:
On the new instance, create a PostgreSQL read-only instance again.
In your application, change the endpoint that you previously set to the primary instance endpoint back to the new read-only instance endpoint.
Upgrade result description
The Upgrade Result column on the Upgrade History tab displays one of the following statuses for the upgrade task.
Upgrade result | Instance status | Meaning | Available actions |
Running | Migration in Progress | The upgrade task is running. | None. |
Succeeded | Running | The upgrade task is successful. | None. |
Related API operations
API | Description |
Performs a pre-upgrade check on an RDS PostgreSQL instance. | |
Queries the pre-upgrade check report of an RDS PostgreSQL instance. | |
Upgrades the major engine version of an RDS PostgreSQL instance. | |
Queries the historical major engine version upgrade tasks of an RDS PostgreSQL instance. |