This topic describes how to upgrade the major version of an ApsaraDB RDS for PostgreSQL instance using blue-green deployment.
Prerequisites
-
The instance runs ApsaraDB RDS for PostgreSQL 16 or an earlier version.
-
The instance is not a read-only instance or a dedicated cluster instance.
-
Babelfish is not enabled. The minor engine version number must not end with
babelfish.
Background information
In a blue-green deployment, the source instance is restored to a new instance, and then pg_upgrade upgrades 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 version using the zero-downtime mode and in-place upgrade. For a comparison of the different upgrade 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, take note of the following billing details:
The source instance and the new instance are both billed.
The fees and billing method for the source instance remain unchanged.
The billing method for the new instance may differ from that of the source instance.
Source instance billing method
New instance billing method
Subscription/pay-as-you-go
pay-as-you-go
Serverless
Serverless
NoteTo save costs, after you verify that services on the new instance are stable, we recommend that you convert the billing method of the new instance to subscription and release or unsubscribe from the source instance. However, note the following:
If your source instance is on a subscription plan and the subscription 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 the unsubscription rules, see Refund policy.
If you received a discount when you purchased the source instance, the new instance does not inherit this discount. Before you upgrade, go to the instance unsubscription page to check the specific refund amount and evaluate whether to proceed.
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 an instance 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 to perform the upgrade without a cutover, your services are not affected.
The read-only duration of the source instance depends on the number of database objects. A higher number of database objects results in a longer read-only duration. If the number of database objects reaches the millions, the read-only duration can extend to 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 perceived by the client depends on the DNS cache refresh time. You can try switching the virtual switch and use the service interruption duration to estimate the DNS cache refresh time of the client.
The upgrade duration depends on the number of database objects in the instance. A larger number of objects results in a longer upgrade time. During a major version upgrade, you can view the task progress in Task Hub.
For a blue-green deployment, if you do not want the source instance to be set to read-only after a cutover, 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 be upgraded only to instances that use cloud disks. You can directly 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 subscriber with replication slots, an upgrade may cause data synchronization issues due to replication slot preemption. For a solution, see How do I prevent data inconsistency caused by replication slot preemption during an upgrade?
Virtual IP address: 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 address change: If you have configured the virtual IP address in your application, you must update your application to use the new virtual IP address.
Recommended solution: To avoid the complexity of manual configuration, we recommend that you directly configure the endpoint of the instance in your application. For information about how to obtain the instance endpoint, see View or change the endpoint and port number.
Parameter changes:
-
Parameters not supported by the destination version are automatically deleted.
-
Parameters whose values fall outside the valid range for the destination version are reset to the default values of the destination version's parameter template.
-
statement_timeoutis temporarily set to0during the upgrade and restored to its original value afterward.
-
DTS tasks:
If the instance is a source or destination for Data Transmission Service (DTS), 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, which may cause 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 the instance to be upgraded has a read-only instance, you must change the endpoint of the read-only instance in your application to the endpoint of the primary instance and then delete the read-only instance.
NoteTo ensure service stability, we recommend that you 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 an upgrade version, set Upgrade Mode to Blue-green Deployment, and then click OK.The instance status changes to Maintaining Instance. After the check completes, the status returns to Running.
Review the check result: For help interpreting check results, see Interpret an ApsaraDB RDS for PostgreSQL major version upgrade check report.
Success or Warning: proceed to Step 2.
Failed: click View Information, fix the reported issues, and run the check again.
Important- If the result is Warning, fix all reported issues and rerun the check until the result is Success. - If you create a plugin on the primary instance after a successful check, run the check again before upgrading.
Step 2: Upgrade major version
Click the Upgrade Instance tab, read the warning, Select an 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 the key parameters.
Parameter
Description
Storage type
The new instance supports only ESSDs and high-performance cloud disks. If you select an ESSD, you can change its performance level (PL).
If the source instance uses a cloud disk, the new instance must use the same storage type. If the source instance uses a high-performance local disk, the new instance must use an ESSD.
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 use only ESSDs.
The Available Zone
These parameters allow you to place the new primary and secondary instances in different availability zones.
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: 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: 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 automatically connects to the new instance. You do not need to change the database endpoint in your application.
NoteYou cannot roll back the change after a cutover. Select this option with caution.
During the cutover, the source instance is set to read-only, which causes a transient connection interruption that lasts for several minutes. We recommend that you perform the upgrade during off-peak hours. If you choose the option without 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 for the final upgrade.
Storage space
Select the storage capacity for the new instance.
Instance specification
Select the instance specification for the new instance. For more information about instance specifications, see Primary ApsaraDB RDS for PostgreSQL instance types.
Click Create Now.
When the instance state changes to Migrating, 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 Task Hub.
ImportantAfter you create an upgrade task, you cannot modify or delete it.
When the source instance is in the Migrating state, you cannot perform operations such as modifying parameters, restarting, or releasing the instance.
If the Insufficient Resources message appears when you create the task, switch to a different Target Primary Availability Zone.
View the upgrade result.
When the status of both the source and new instances is Running, the upgrade is complete.
NoteIn blue-green deployment with cutover mode, traffic is automatically switched to the new instance that runs a later version after the upgrade.
In blue-green deployment without cutover mode, traffic is not automatically switched to the new instance that runs a later version after the upgrade.
After the upgrade is complete, go to the Upgrade History tab and 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 a blue-green deployment without cutover, the system also displays the Cutover Time and Cutover End Time for your reference and for estimation in a cutover scenario.
Next steps
If you upgrade an instance using the blue-green deployment with cutover mode, promptly release the source instance after you confirm that your services are running correctly on the new instance.
We also recommend that you change the billing method of the new instance to subscription for cost savings.
NoteIf you release a subscription instance before its expiration date, you may incur a financial loss.
If you received a discount when you purchased the source instance, the new instance does not inherit this discount. The actual refund for the source instance is determined on the unsubscription page.
The refund amount and processing time are based on the final unsubscription bill and are not 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:
Create an ApsaraDB RDS for PostgreSQL read-only instance on the new instance.
In your application, change the application endpoint from the primary instance back to the endpoint of the new read-only instance.
Upgrade results
During the upgrade, the Upgrade Result column for the upgrade record on the Upgrade History tab displays one of the following statuses.
Upgrade result | Instance status | Description | Actions |
Running | Migrating | The upgrade task is in progress. | None. |
Succeeded | Running | The upgrade task is successful. | None. |
API reference
| API operation | Description |
|---|---|
| UpgradeDBInstanceMajorVersionPrecheck | Runs a pre-upgrade check for a major version upgrade. |
| DescribeUpgradeMajorVersionPrecheckTask | Queries the pre-upgrade check report. |
| UpgradeDBInstanceMajorVersion | Upgrades the major engine version. |
| DescribeUpgradeMajorVersionTask | Queries the history of major version upgrade tasks. |