Upgrading the Major Version of a DB Instance on the Console
Scenarios
RDS for PostgreSQL allows you to upgrade the major version of your DB instance in either of the following methods:
- Upgrade without cutover: It does not affect workloads. During the upgrade, a new instance is created using a snapshot, and no operation is performed on the original instance. The major version of the new instance is upgraded. After the upgrade is complete, you can connect to the new instance to test workload compatibility. Upgrading a major version may cause compatibility issues, so compatibility testing is strongly recommended. After the test is passed, perform an upgrade in cutover mode.
- Upgrade with cutover: During this process, a new instance is created using a snapshot, the original instance is set to read-only, and workloads will be interrupted for several minutes. After the major version of the new instance is upgraded, the virtual IP address (VIP) of the original instance is automatically switched to the new instance and your workloads are automatically connected to the new instance. The upgrade is complete. The original instance remains read-only.
To upgrade a major version, submit a service ticket to request required permissions.
Video
Constraints
- Major version upgrades are available to the following versions:
- RDS for PostgreSQL 9.5: 9.5.25 or later
- RDS for PostgreSQL 9.6: 9.6.24 or later
- RDS for PostgreSQL 10: 10.21 or later
- RDS for PostgreSQL 12: 12.6.3 or later
- RDS for PostgreSQL 13: 13.2.3 or later
- RDS for PostgreSQL 14: 14.4 or later
- RDS for PostgreSQL 15: 15.4 or later
- Major version upgrades are unavailable to RDS for PostgreSQL 11 and Enhanced Edition.
- Due to OS restrictions, some DB instances do not support major version upgrades. To check whether your instance can be upgraded, go to the Major Version Upgrade page on the console. For the available target versions, see Upgrade Information on the console.
- The primary DB instance in a DR relationship can only be upgraded without workload cutover. To upgrade it with workload cutover, remove the DR relationship first.
- The DR instance in a DR relationship does not support major version upgrades. To upgrade it, remove the DR relationship first.
- Before a major version upgrade, perform an upgrade check. If there is no successful upgrade check in the validity period, a major version upgrade is not allowed.
Extensions Unsupported for Major Version Upgrades
If any extension listed in Table 1 is detected in the upgrade path during a major version upgrade pre-check, uninstall the extension before the upgrade is performed and reinstall it after the upgrade is complete. If you perform the upgrade without removing this extension, the upgrade will fail, or the extension cannot be used after the instance is upgraded.
| Source Version | Target Version | Extension That Needs to Be Uninstalled Before an Upgrade to Prevent Upgrade Failures | Extension That Cannot Be Used After an Instance Upgrade |
|---|---|---|---|
| 12 | 13 | orafce, postgis_sfcgal | address_standardizer_data_us, pgaudit |
| 14 | orafce, postgis_sfcgal | anon, pgaudit | |
| 15 | orafce, postgis_sfcgal | anon, pgaudit | |
| 16 | orafce, postgis_sfcgal, pgl_ddl_deploy | anon, pgaudit | |
| 17 | orafce, pgl_ddl_deploy, postgis, postgis_raster, postgis_topology, postgis_tiger_geocoder, postgis_sfcgal, pg_track_settings | anon, pgaudit | |
| 13 | 14 | - | anon, pgaudit, pg_stat_kcache, postgis, postgis_raster, address_standardizer, address_standardizer_data_us, postgis_topology, postgis_tiger_geocoder, postgis_sfcgal |
| 15 | - | anon, pgaudit, pg_stat_kcache | |
| 16 | pgl_ddl_deploy | anon, pgaudit, pg_stat_kcache | |
| 17 | pgl_ddl_deploy, postgis, postgis_raster, postgis_topology, postgis_tiger_geocoder, postgis_sfcgal, pg_track_settings | anon, pgaudit, pg_stat_kcache, powa | |
| 14 | 15 | - | pgaudit, pg_stat_kcache |
| 16 | pgl_ddl_deploy | pgaudit, pg_stat_kcache | |
| 17 | pgl_ddl_deploy, postgis, postgis_raster, postgis_topology, postgis_tiger_geocoder, postgis_sfcgal, pg_track_settings | pgaudit, pg_stat_kcache, powa | |
| 15 | 16 | pgl_ddl_deploy | pgaudit |
| 17 | pgl_ddl_deploy, postgis, postgis_raster, postgis_topology, postgis_tiger_geocoder, postgis_sfcgal, pg_track_settings | pgaudit, pg_stat_kcache, powa | |
| 16 | 17 | postgis, postgis_raster, postgis_topology, postgis_tiger_geocoder, postgis_sfcgal, pg_track_settings | pgaudit, pg_stat_kcache, powa |
Billing
- Change the billing mode of the new instance to yearly/monthly. For details, see Pay-per-Use to Yearly/Monthly.
- If the original instance is billed in pay-per-use mode, release the original instance to reduce fees. For details, see Deleting a Pay-per-Use DB Instance or Read Replica.
- If the original instance is billed in yearly/monthly mode, unsubscribe from it. For details, see Unsubscribing from a Yearly/Monthly Instance. Unsubscribing from a yearly/monthly instance before it expires may cause fee loss. Before an upgrade, learn about the unsubscription rules in Unsubscribing from In-Use Resources.
Precautions
- If the major version upgrade is complete and the application is cut over to the new instance but the workloads are incompatible with the new version, you need to roll back the upgrade. Submit a service ticket to unlock the original instance from the read-only status. Then, you can continue to use the original instance.
The data added after an upgrade is complete will not be automatically synchronized to the original instance.
- The major version upgrade check consumes certain resources. Perform the check during off-peak hours.
For instances that contain a large number of table-level objects (such as more than 100,000 tables, views, and functions), system resource usage (especially CPU and I/O) will exhibit significant periodic spikes. The resource consumption mainly occurs during the pre-check phase, where the pg_upgrade tool is invoked on the primary node to compare metadata before and after the upgrade.
- After a major version upgrade is complete, a new DB instance is created. The original DB instance is still retained and billed. You can release the original instance when the workloads on the new instance run stably.
- After a major version upgrade, the audit logs, error logs, and slow query logs of the original instance are still stored in the original instance. You can only view the logs generated after the upgrade on the new instance.
- Read replicas do not support major version upgrades. If your DB instance has a read replica, the read replica will not be upgraded synchronously. You need to recreate one after a major version upgrade. For details, see Creating a Read Replica.
- If your DB instance has a DR instance, the DR instance will not be upgraded synchronously and the DR relationship will be interrupted. After a major version upgrade, recreate a DR instance running the same version as the new instance and set up a DR relationship between them.
- If a major version upgrade check fails and the check report is empty, submit a service ticket.
- A major version upgrade has the following impacts: If you upgrade your instance with workload cutover, the instance will be set to read-only. The instance will not be automatically unlocked from the read-only status even after the upgrade. The upgrade will interrupt your workloads for several minutes. Perform the upgrade during off-peak hours. If you choose to upgrade your instance without cutover, there is no impact on your workloads.
The default_transaction_read_only parameter controls the read-only settings. Before the upgrade, check whether any modification has been made to this parameter. If yes, the data inserted into the instance during the cutover will be lost after the upgrade.
- After a major version upgrade is complete, the parameters of the new version have the following changes:
- New parameters in the parameter template of the new version use the values defined in the template.
- Existing parameters keep the values from the original version. If these values fall outside the new version's allowed ranges, the values specified in selected template are used instead.
- Parameters from the original version that are not supported in the new version are automatically deleted.
- Special parameters: wal_keep_segments (earlier than RDS for PostgreSQL 13) and wal_keep_size (RDS for PostgreSQL 13 or later) are WAL log retention parameters. After an instance is upgraded from a version earlier than RDS for PostgreSQL 13 to RDS for PostgreSQL 13 or later, the wal_keep_size parameter replaces the wal_keep_segments parameter, and the parameter value is automatically converted.
- Upgrading a major version will not upgrade the versions of extensions. For details about supported extension versions, see Supported Extensions. If the new instance supports any extension of a later version, you can run ALTER EXTENSION extension_name UPDATE TO 'new_version'; to update the extension, or uninstall and reinstall the extension of the latest version.
Certain extensions (such as postgis) will cause a major version upgrade to fail. To prevent this issue, uninstall the extensions first before upgrade.
Procedure
- Log in to the RDS console.
- Click
in the upper left corner and select a region. - On the Instances page, click the instance name to go to the Summary page.
- In the navigation pane, choose Major Version Upgrade.
If the Major Version Upgrade tab is not displayed, submit a service ticket to apply for required permissions.
Figure 1 Major Version Upgrade
- On the displayed page, select a target version and click Next. Figure 2 Upgrade Information
- On the pre-check page, start a pre-check. It takes several minutes to complete the check. Figure 3 Pre-check
- If any extensions are installed on the instance after a successful upgrade check, an upgrade may fail due to compatibility issues. If this happens, perform a check again. For details, see Extensions Unsupported for Major Version Upgrades.
- If the upgrade check fails, you can view the check report by clicking View Report on the Upgrade Checks tab page and rectify the incompatibility based on the report.
- After the check is passed, choose a parameter template, select No for Cutover, click Autofill to fill UPGRADE, and click Upgrade Now. Figure 4 Upgrade without cutover
- Confirm the upgrade information and click Submit. Figure 5 Confirming upgrade information
- After the upgrade is complete, check for the new instance of the target version. You can connect to the new instance to test workload compatibility. Figure 6 Checking the upgrade results
- Log in to the RDS console.
- Click
in the upper left corner and select a region. - On the Instances page, click the instance name to go to the Summary page.
- In the navigation pane, choose Major Version Upgrade.
If the Major Version Upgrade tab is not displayed, submit a service ticket to apply for required permissions.
Figure 7 Major Version Upgrade
- On the displayed page, select a target version and click Next. Figure 8 Upgrade Information
- In the Pre-check phase, start a pre-check. It takes several minutes to complete the check. Figure 9 Pre-check
- If any extensions are installed on the instance after a successful upgrade check, an upgrade may fail due to compatibility issues. If this happens, perform a check again. For details, see Extensions Unsupported for Major Version Upgrades.
- If the upgrade check fails, you can view the check report by clicking View Report on the Upgrade Checks tab page and rectify the incompatibility based on the report.
- After the check is passed, choose a parameter template, select Yes for Cutover, specify Collect Statistics, click Autofill to fill UPGRADE, and click Upgrade Now. Figure 10 Upgrade with cutover
During a major version upgrade, optimizer statistics are not automatically synchronized. Statistics need to be collected after the upgrade is complete.
- If you choose to collect them before cutover, workload stability is ensured. If your instance has too much data, the upgrade may take a longer time.
- If you choose to collect them after cutover, faster upgrade is ensured. After the upgrade, accessing tables for which no statistics have been generated may cause inaccurate execution plans and even instance breakdowns during peak hours.
- Confirm the upgrade information and click Submit. Figure 11 Confirming upgrade information
- After the upgrade is complete, check for the new instance of the target version. Your workloads are automatically switched over to the new instance. Figure 12 Checking the upgrade results
Upgrade Check Reports and Upgrade Reports
If an upgrade check or an upgrade fails, you can analyze the causes based on the upgrade check report or upgrade report. The procedure is as follows:
- Check the pg_upgrade_internal.log file.
pg_upgrade_internal.log is an important log file for debugging. If an upgrade fails, check for errors recorded in this file. Common errors are as follows:
- A list of problem libraries is in the file: loadable_libraries.txt
It means there are extensions that are incompatible with the target version. They are listed in loadable_libraries.txt.
- A list of tables with the problem is in the file: tables_with_oids.txt
It means there are tables that are created with the WITH OIDS clause and such tables are recorded in tables_with_oids.txt. The WITH OIDS clause is not supported by RDS for PostgreSQL 12 or later.
- Consult the last few lines of "pg_upgrade_server.log" for the probable cause of failure.
It means that the target version failed to start during the upgrade check and you can check pg_upgrade_server.log for the causes.
- Consult the last few lines of "pg_upgrade_dump_xxxx.log" for the probable cause of failure.
It means that pg_dump failed to back up data during the upgrade and you can check pg_upgrade_dump_xxxx.log for the causes.
- The source cluster contains roles starting with "pg_"
Users whose names start with pg_ are not allowed in the target version. Delete or rename these users first.
- A list of the problematic objects is in the file: incompatible_polymorphics.txt
There is the function parameter type anyarray or anyelement that is incompatible with the target version. Delete the function definitions before the upgrade. After the upgrade is complete, restore the functions and change the parameter type (anyarray to anycompatiblearray or anyelement to anycompatible). The function objects are recorded in the incompatible_polymorphics.txt file.
- A list of problem libraries is in the file: loadable_libraries.txt
- Analyze causes based on the report items.
- loadable_libraries.txt
This item displays incompatible libraries, which usually correspond to incompatible extensions. Check the extensions listed in loadable_libraries.txt and determine whether to delete them. If you are sure that the deletion will not affect workloads, delete them before the upgrade.
- tables_with_oids.txt
This item displays tables created with the WITH OIDS clause. Check the tables listed in tables_with_oids.txt and evaluate whether the workload code depends on the OIDs. If stripping OIDs from the tables does not affect workloads, run the following SQL statement:
ALTER TABLE {table_name} SET WITHOUT OIDS;
- pg_upgrade_server.log
Check the last several lines of the pg_upgrade_server.log file. If an error similar to the following appears, the extension displayed in this error does not exist in the target version. Delete it from shared_preload_libraries as required and then perform the upgrade.
FATAL: could not access file "xxx": No such file or directory.
Example:
FATAL: could not access file "pg_pathman": No such file or directory.
- pg_upgrade_dump_xxxx.log
- Check the last several lines of pg_upgrade_dump_xxxx.log. If an error similar to the following is displayed, there are too many tables in the current instance. In this case, increase the value of max_locks_per_transaction and perform the upgrade again.
pg_dump: error: query failed: ERROR: out of shared memory HINT: You might need to increase max_locks_per_transaction. pg_dump:error: query was: LOCK TABLE "xxx"."xxx" IN ACCESSSHARE MODE
- Check the last several lines of pg_upgrade_dump_xxxx.log. If an error similar to the following is displayed, the pgl_ddl_deploy extension exists in the current instance. This extension is incompatible with the target version, so the upgrade failed. Check whether there are any other incompatible third-party extensions in the instance based on Extensions Unsupported for Major Version Upgrades (some incompatible third-party extensions cannot be identified through an upgrade check). Delete them as required and then perform the upgrade.
pg_restore: error: could not execute query: ERROR: could not find function "xxx" in file xxx Command was: CREATE FUNCTION "pgl_ddl_deploy"."xxx"
- Check the last several lines of pg_upgrade_dump_xxxx.log. If an error similar to the following is displayed, there are too many tables in the current instance. In this case, increase the value of max_locks_per_transaction and perform the upgrade again.
- loadable_libraries.txt
- Troubleshoot the fault if the following error message is displayed after the upgrade check fails.
Relation names for OID 16479 in database postgres do not match toast: relname recyclebin_tb_1;Relation names for OID 16472 in database postgres do not match toast: relname tb_toast;
Handling method (The following operations involve modifications to table objects. To prevent data inconsistency, stop all write operations to the target table.)
- Back up the abnormal table. Table public.tb_toast is used as an example.
CREATE TABLE public.tb_toast_bak AS SELECT * FROM public.tb_toast;
- Uninstall the recyclebin plugin. After it is uninstalled, objects (such as recyclebin_tb_1) in the recycle bin will be automatically deleted.
- Delete the abnormal table.
DROP TABLE public.tb_toast;
- Restore the original table name.
ALTER TABLE public.tb_toast_bak RENAME TO tb_toast;
- Perform the upgrade check again and verify that the error message "do not match toast" no longer appears.
- Back up the abnormal table. Table public.tb_toast is used as an example.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot