All Products
Search
Document Center

ApsaraDB RDS:Upgrade a major version using blue-green deployment

Last Updated:Oct 14, 2026

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

    Note

    To 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_sup parameter to off after 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:

  • 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_timeout is temporarily set to 0 during 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

  1. 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.

  2. (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.

    Note

    To ensure service stability, we recommend that you change the application endpoint during off-peak hours.

  3. In the navigation pane on the left, click Major Version Upgrade.

    Note

    If 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.

  4. On the Upgrade Check tab, click Create upgrade check report.

  5. 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.

  6. 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

  1. Click the Upgrade Instance tab, read the warning, Select an upgrade version, and then click Create Upgrade Task.

  2. In the dialog box that appears, read the message and click OK.

  3. 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.

      Note
      • The 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.

    Note
    • You 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.

    When you upgrade the major version of an instance that uses a high-performance local disk, you can scale in the storage capacity.

    The minimum selectable storage capacity must meet the following conditions:

    • The smaller of the following two values:

      • Used storage capacity of the source instance × 120%. If the result (in GB) is not a multiple of 5, round the result up to the nearest multiple of 5.

        Note

        To view the used storage capacity of the source instance, go to the Monitoring and Alerts page and check the Disk Space (MB) metric. For more information, see View enhanced monitoring data.

      • Storage capacity of the source instance.

    • Greater than or equal to the minimum purchasable storage capacity of an ESSD. If this condition is not met, the following values are used as the minimum purchasable storage capacity:

      • ESSD PL1: 20 GB.

      • ESSD PL2: 500 GB.

      • ESSD PL3: 1,500 GB.

    Note

    Examples:

    • Your source instance has a storage capacity of 100 GB, and 70 GB of the storage capacity is used. When you upgrade the major version, you select ESSD PL1 for the storage type.

      Calculation: 70 × 120% = 84. The value is rounded up to the nearest multiple of 5, which is 85. Therefore, the minimum purchasable storage capacity is 85 GB.

    • Your source instance has a storage capacity of 700 GB, and 350 GB of the storage capacity is used. When you upgrade the major version, you select ESSD PL2 for the storage type.

      Calculation: 350 × 120% = 420. The value 420 GB is less than the minimum purchasable storage capacity of a PL2 ESSD, which is 500 GB. Therefore, the minimum purchasable storage capacity is 500 GB.

    Instance specification

    Select the instance specification for the new instance. For more information about instance specifications, see Primary ApsaraDB RDS for PostgreSQL instance types.

  4. 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.

    Important
    • After 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.

  5. View the upgrade result.

    When the status of both the source and new instances is Running, the upgrade is complete.

    Note
    • In 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

  1. 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.

    Note
    • If 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.

  2. (Optional) The new instance does not include read-only instances. If you deleted a read-only instance before the upgrade, perform the following steps:

    1. Create an ApsaraDB RDS for PostgreSQL read-only instance on the new instance.

    2. 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.

Related topics

FAQ

Can I modify the instance during a major version upgrade?

No. Instance modifications — including changing the instance type — are not supported during an upgrade. Perform other operations only after the upgrade completes.

Are automatic major version upgrades supported?

No. Automatic upgrades to major engine versions are not supported.

Are major version downgrades supported?

No. Downgrading to a lower major version after an upgrade is not supported. To run a lower version, purchase a new instance running that version and use DTS to migrate the data.

After a major version upgrade, a `raster_overviews` conflict appears when I create a `raster_overviews` view on the destination instance. How do I fix this?

This conflict can occur when the PostGIS version is earlier than 2.5.2 and the source instance runs PostgreSQL 10 or 11, and you upgrade to PostgreSQL 12.

Step 1: Upgrade the PostGIS plugin on the source instance.

Run the following command twice to make sure it succeeds.

SELECT PostGIS_Extensions_Upgrade();
SELECT PostGIS_Extensions_Upgrade();

Step 2: Choose the fix based on whether you use the PostGIS Raster plugin.

If the PostGIS Raster plugin is in use:

  1. Run the following on the source instance to detach the raster_overviews view from the extension:

    ALTER EXTENSION PostGIS_Raster DROP VIEW raster_overviews;
    CREATE OR REPLACE VIEW raster_overviews AS SELECT 1;
  2. Upgrade the PostgreSQL instance to at least PostgreSQL 12.

  3. After the upgrade, recreate the view on the destination instance:

    CREATE OR REPLACE VIEW raster_overviews AS
    SELECT
      current_database() AS o_table_catalog,
      n.nspname AS o_table_schema,
      c.relname AS o_table_name,
      a.attname AS o_raster_column,
      current_database() AS r_table_catalog,
      split_part(split_part(s.consrc, '''::name', 1), '''', 2)::name AS r_table_schema,
      split_part(split_part(s.consrc, '''::name', 2), '''', 2)::name AS r_table_name,
      split_part(split_part(s.consrc, '''::name', 3), '''', 2)::name AS r_raster_column,
      trim(both from split_part(s.consrc, ',', 2))::integer AS overview_factor
    FROM
      pg_class c,
      pg_attribute a,
      pg_type t,
      pg_namespace n,
      (SELECT connamespace, conrelid, conkey, pg_get_constraintdef(oid) AS consrc FROM pg_constraint) AS s
    WHERE
      t.typname = 'raster'::name
      AND a.attisdropped = false
      AND a.atttypid = t.oid
      AND a.attrelid = c.oid
      AND c.relnamespace = n.oid
      AND c.relkind = ANY(ARRAY['r'::char, 'v'::char, 'm'::char, 'f'::char])
      AND s.connamespace = n.oid
      AND s.conrelid = c.oid
      AND s.consrc LIKE '%_overview_constraint(%'
      AND NOT pg_is_other_temp_schema(c.relnamespace)
      AND has_table_privilege(c.oid, 'SELECT'::text);
    ALTER EXTENSION PostGIS_Raster ADD VIEW raster_overviews;

If the PostGIS Raster plugin is not in use:

  1. Drop the plugin on the source instance:

    DROP EXTENSION PostGIS_Raster;
  2. Upgrade the PostgreSQL instance to at least PostgreSQL 12.

How do I prevent data inconsistency caused by replication slot preemption during an upgrade?

  • If you need to keep the subscription data on the source (lower-version) instance, make sure that the source instance does not fail due to an excessive load during the upgrade. Otherwise, the replication slot may be preempted by the destination (higher-version) instance, which can lead to data inconsistency.

    After the upgrade is complete, run the following SQL statement to disable the subscription on the database of the destination instance:

    \c your_database
    ALTER SUBSCRIPTION your_subscription_name DISABLE;
  • If you need to save the subscription data on the destination instance, disable the subscription on the source instance before you upgrade the major version. After the upgrade is complete, enable the subscription on the destination instance. The following SQL statements are provided for your reference:

    • Disable the subscription on the source instance.

      \c your_database
      ALTER SUBSCRIPTION your_subscription_name DISABLE;
    • Enable the subscription on the destination instance.

      \c your_database
      ALTER SUBSCRIPTION your_subscription_name ENABLE;
Note

How do I handle subscription data inconsistency after an upgrade?

After the upgrade succeeds, delete the table data on the destination instance (running the higher version), then recreate the subscription with copy_data=true. For details, see ALTER SUBSCRIPTION.

Alternatively, use the ON CONFLICT clause to merge data consumed by the source instance into the destination. The following example shows how to handle conflicts by timestamp:

CREATE TABLE my_tbl(id INT PRIMARY KEY, t TIMESTAMP, val TEXT);

INSERT INTO my_tbl VALUES (1, CURRENT_TIMESTAMP, 'a');
INSERT INTO my_tbl VALUES (2, CURRENT_TIMESTAMP, 'b');
INSERT INTO my_tbl VALUES (3, CURRENT_TIMESTAMP, 'c');

-- Update if the incoming row has a newer timestamp
INSERT INTO my_tbl VALUES (1, CURRENT_TIMESTAMP, 'd')
ON CONFLICT(id) DO UPDATE
  SET t = excluded.t, val = excluded.val
  WHERE my_tbl.t < excluded.t;

-- Skip if the incoming row has an older timestamp
INSERT INTO my_tbl VALUES (2, CURRENT_TIMESTAMP - '10 hours'::interval, 'e')
ON CONFLICT(id) DO UPDATE
  SET t = excluded.t, val = excluded.val
  WHERE my_tbl.t < excluded.t;

-- Insert new rows normally
INSERT INTO my_tbl VALUES (5, CURRENT_TIMESTAMP - '10 hours'::interval, 'f')
ON CONFLICT(id) DO UPDATE
  SET t = excluded.t, val = excluded.val
  WHERE my_tbl.t < excluded.t;

Why do I need to delete read-only instances before a major version upgrade?

After the upgrade, user-created read-only instances and replication slots remain on the source instance and are not automatically transferred to the new instance. Therefore, before you perform a major version upgrade, you must change the endpoint of the read-only instance in your application to the endpoint of the primary instance and delete the existing read-only instance. After the upgrade is complete, create and configure a new read-only instance.