Skip to content

RDS Serverless v2 PostgreSQL 13.21 fails major version upgrade

0

Can't upgrade to any version (now RDS Serverless PostgreSQL 13.21). Error is always the same: "Database cluster is in a state that cannot be upgraded: Postgres cluster is in a state where pg_upgrade can not be completed successfully."

Steps to reproduce: a) Production database RDS Aurora Serverless v2 PostgreSQL 13.21 I was created in year 2020 and upgraded major version several times with no issues.

b1) Try either to upgrade immediantly aws rds modify-db-cluster --db-cluster-identifier "dev-mydb-cluster" --engine-version 14.18 --allow-major-version-upgrade --apply-immediately

b2) Or try no-immediately and wait for the maintenance windows aws rds modify-db-cluster --db-cluster-identifier "dev-mydb-cluster" --engine-version 14.18 --allow-major-version-upgrade --no-apply-immediately

c) Result is PostgreSQL not upgraded. Error is: "Database cluster is in a state that cannot be upgraded: Postgres cluster is in a state where pg_upgrade can not be completed successfully."

Tried major upgrades to Postgres 14, 15, 16 and 17 (always same error). Unable to identify anything relevant in logs: /aws/rds/cluster/dev-mydb-cluster/postgresql /aws/rds/cluster/dev-mydb-cluster/instance Never used PostGIS (it seems to be the problem in other similar issues). Never used any extension. Unable to indentify the issue in https://repost.aws/knowledge-center/rds-postgresql-version-upgrade-issues

How can I upgrade it to another major version?

3 Answers
0

Based on your description, you're encountering a persistent issue with major version upgrades for your Aurora PostgreSQL Serverless v2 database. The error message "Postgres cluster is in a state where pg_upgrade can not be completed successfully" indicates that there's something in your database configuration or state preventing the upgrade process from completing.

Here are some troubleshooting steps and potential solutions:

  1. Check for precheck log files: Unfortunately, for Aurora PostgreSQL, the precheck log files that contain detailed information about upgrade failures are not directly accessible to customers. These logs would contain the specific reasons why the upgrade is failing.

  2. Common causes for upgrade failures:

  • Open prepared transactions
  • Unsupported DB instance classes for the target version
  • Incompatible extensions or data types
  • Logical replication slots in use
  • Insufficient storage space
  • Database roles with names starting with "pg_"
  • Incompatible parameter settings
  1. Possible solutions:
  • Create a clone: Create a clone of your database cluster and attempt the upgrade on the clone. This might provide more detailed error information in the logs.
  • Dump and restore approach: This is often the most reliable method when direct upgrades are failing: a. Create a logical dump of your current database using pg_dump b. Launch a new Aurora PostgreSQL cluster with the desired engine version c. Restore the dump to the new cluster d. Test your application thoroughly with the new database e. Update your application's database configuration to point to the new cluster
  1. Enable Enhanced Monitoring: If you haven't already, enable Enhanced Monitoring for your cluster, which will send logs and metrics to CloudWatch Logs, potentially providing more insight into the issue.

  2. Contact AWS Support: If you continue to face issues, AWS Support can help access and analyze the precheck logs to identify the specific cause of the upgrade failure.

The dump and restore approach, while requiring more effort, is often the most reliable way to upgrade from a version that's experiencing upgrade issues, especially when direct upgrades are consistently failing.
Sources
How to upgrade Aurora PostgreSQL (Deprecated Engine version 10.21) | AWS re:Post
Troubleshoot PostrgreSQL major version upgrade issues | AWS re:Post
Where is precheck log file for Aurora Serverless Postgres? | AWS re:Post

answered a year ago

0

That's an incredibly common and frustrating scenario with Aurora PostgreSQL. The error message, "Database cluster is in a state that cannot be upgraded: Postgres cluster is in a state where pg_upgrade can not be completed successfully," is the database equivalent of "it's not you, it's me" and is notoriously unhelpful. As an expert, my opinion is that this is a classic AWS "black box" problem where you, the customer, don't have access to the underlying pg_upgrade logs, which would contain the specific error. The upgrade is failing during its precheck, but the details are hidden in a part of the file system that's not exposed via CloudWatch or the RDS console. This forces you to use a process of elimination to find the root cause, or to simply abandon the in-place upgrade.

Based on my experience and the common issues found in the community, the most likely culprits are:

Unsupported or incompatible database objects: This is the most frequent cause. It could be a custom data type, an old extension, or a user-defined function that's not compatible with the new major version.

Open prepared transactions: Any pending PREPARE TRANSACTION statements will block the upgrade.

Logical replication slots: If you have active logical replication slots, the upgrade will fail. You'll need to drop these and re-create them after the upgrade.

Corrupted metadata or system tables: While less common, this can happen, and a dump-and-restore is the only way to resolve it.

My professional opinion, in this situation, is to immediately abandon the in-place upgrade and proceed with a logical dump-and-restore. While more labor-intensive, it is the most reliable and guaranteed path forward. You should use pg_dump to export your database to a file, create a brand-new Aurora Serverless v2 cluster with the desired target version, and then use pg_restore to import the data. This process effectively sanitizes your database by only transferring schema and data that is compatible with the new version, leaving behind any problematic objects. The in-place upgrade is a convenient feature when it works, but when it fails with this vague error, the time you spend troubleshooting is often better spent on a controlled migration. The best path is the one that gets you to the finish line with the least risk, and in this case, that's a dump-and-restore. If you have the time and need to know the specific cause for future reference, you can open a support case with AWS, and their engineers can access the hidden pg_upgrade logs for a more definitive answer.

answered a year ago

0

I have finally been able to upgrade after multiple try-error attempts. In this specific case, the solution was to increase the serverless v2 scaling configuration max capacity.

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.