Skip to content

Upgrading RDS postgres from 16.8 to 17.4 permission error

0

I am trying to upgrade Postgres from version 16.8 to 17.4. When I perform the upgrade I get the following error.

--------------------------------------- -- GRANT ALL ON PARAMETER "session_replication_role" TO "rds_superuser"; psql:/rdsdbdata/upgrade/db/pg_upgrade_output.d/20250224T124249.631/dump/pg_upgrade_dump_globals.sql:127: ERROR: permission denied for parameter session_replication_role

The rds_superuser I believe is something managed internally by AWS so I am unsure how to allow the permissions needed to perform this upgrade. Any advice on what I may be missing?

asked 2 years ago1.7K views

2 Answers
0
Accepted Answer

Identifying the Role Grant To determine which role has been granted the session_replication_role parameter, run the following SQL:

SELECT * FROM pg_parameter_acl;

For example, you might see output like this:

  oid  |         parname          |                          paracl
-------+--------------------------+-----------------------------------------------------------
 16467 | session_replication_role | {rds_superuser=sA/rds_superuser,postgres=s/rds_superuser}

In this output, notice that the role postgres is listed as having the parameter set GRANT.

Upgrade Error Scenario

When attempting to perform an upgrade, you might encounter an error similar to:

**Database instance is in a state that cannot be upgraded: command: "/rdsdbbin/postgres/bin/psql" --echo-queries --set ON_ERROR_STOP=on --no-psqlrc --dbname=template1 --host /rdsdbdata/log/upgrade --port 8193 --username rdsadmin -f "/rdsdbdata/upgrade/db/pg_upgrade_output.d/20250225T155427.196/dump/pg_upgrade_dump_globals.sql" >> "/rdsdbdata/upgrade/db/pg_upgrade_output.d/20250225T155427.196/log/pg_upgrade_utility.log" 2>&1
...
ERROR: permission denied for parameter session_replication_role**

This error occurs because the postgres role has been granted the session_replication_role parameter, which interferes with the upgrade process.

Resolving the Issue

To resolve the error, you need to revoke the permission from the role that was granted this parameter. if the postgres role is the one set with the parameter, execute:

REVOKE SET ON PARAMETER "session_replication_role" FROM "postgres";

This command removes the parameter assignment from postgres so that the upgrade can proceed without permission issues.

Context and Best Practices

Highest-privileged Role:

In Amazon RDS for PostgreSQL, the rds_superuser is a critical role. It is assigned by default to the master user (postgres) to simulate superuser capabilities (note that the actual RDS superuser is rdsadmin managed by AWS). Although postgres appears to have this parameter, it’s not the same as the native PostgreSQL superuser and has additional restrictions.

Role Nesting

When you grant additional roles to a user, those roles become nested within their existing privileges. This means that a user may inherit the capabilities of both the rds_superuser and any other role they are assigned. As a result, careful management of parameters like session_replication_role is essential.

Upgrade Considerations:

Always verify parameter assignments before performing an upgrade. This check ensures that roles with elevated privileges are not inadvertently interfering with system processes.

For further details, refer to: https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Appendix.PostgreSQL.CommonDBATasks.Roles.rds_superuser.html

AWS

answered 2 years ago

  • I tried this and didn't work but I noticed rds_superuser didn't have "SET" permissions

    oid | parname | paracl -------+--------------------------+----------------------------------------------------------- 16439 | session_replication_role | {rds_superuser=A/rds_superuser}

    Running GRANT SET ON PARAMETER "session_replication_role" TO "rds_superuser"; fixed the issue and allowed me to upgrade

0

The error you're encountering during the RDS PostgreSQL upgrade from 16.8 to 17.4 is related to permissions on the "session_replication_role" parameter. This issue is not typically something you can directly resolve as a user, since the rds_superuser role is indeed managed internally by AWS.

However, there are a few steps you can take to troubleshoot and potentially resolve this issue:

  1. First, ensure that you're using the latest default parameter group for the target version (17.4 in this case). Sometimes, using an outdated or custom parameter group can lead to unexpected errors during upgrades.

  2. If you're using a custom parameter group, try modifying your upgrade process to use the default parameter group for the target version instead. You can always reapply your custom settings after a successful upgrade.

  3. Before attempting the upgrade again, it's a good practice to perform a backup of your database. This ensures you have a safe rollback point if needed.

  4. Check if there are any pending updates or patches for your current RDS instance. Applying these before the upgrade might resolve some issues.

  5. If the problem persists, you should contact AWS Support. They have access to more detailed logs and can investigate why the rds_superuser is encountering permission issues during the upgrade process.

  6. In some cases, performing the upgrade in stages (e.g., upgrading to an intermediate version first) might help avoid certain issues. However, given that you're already on version 16.8, this is less likely to be necessary for an upgrade to 17.4.

Remember, major version upgrades can be complex, especially when dealing with permission-related issues on managed services like RDS. If these steps don't resolve the issue, AWS Support will be your best resource for addressing this specific error.
Sources
Resolve RDS DB update resource errors in CloudFormation | AWS re:Post
How to perform a major version upgrade for RDS for PostgreSQL - Amazon Relational Database Service

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