Unable to upgrade RDS postgres instance from 9.5.15 to 9.6.11

0

Hi,
We are testing a RDS posgres upgrade from 9.5.15 to 9.6.11 and are running in the following error message when performing the upgrade:

Database instance is in a state that cannot be upgraded: PreUpgrade checks failed: The instance could not be upgraded because one or more databases have views or materialized views which depend on 'pg_stat_activity'. Please drop them and try again.

The upgrade is being performed with the following AWS cli command:

aws rds modify-db-instance \
--apply-immediately \
--allow-major-version-upgrade \
--db-parameter-group-name ... \
--engine-version ... \
--db-instance-identifier ...

The problems appears to be that there are some views that are owned by rdsadmin that we cannot drop:

scp=> drop view pg_stat_activity;
ERROR: must be owner of relation pg_stat_activity

Anyone run into this before or has some tips howto resolve it?

posta 5 anni fa880 visualizzazioni
4 Risposte
1

You need to remove/drop all the materialized views which are dependent on the view pg_stat_activity.

In the newer version starting 9.6.X, there is a change in the relation (pg_stat_activity) and so any dependent materialized view which has been created needs to be re-created.

in my case it was from our monitoring tool, we made some of the customized views to monitor locks and other processes via pg_hero.

Query to list the views using pg_stat_activity relation:

 select * from pg_views where definition like '%pg_stat_activity%';

Query to get a list of dependent materialized views across schemas:

select schemaname, viewname, viewowner from pg_views where viewowner != 'rdsadmin' and definition ilike '%pg_stat_activity%' union all select schemaname, matviewname, matviewowner from pg_matviews
  where matviewowner != 'rdsadmin' and definition ilike '%pg_stat_activity%';

Then once you identify the view name, take the back up of the view definition as you might need to apply them again once the instance is upgraded to newer version (9.6.X)

Drop the views using the below query:

 drop view <<view_name>>  ;

you can also use cascade if needed to drop the dependent objects too
EX:

 drop view pghero.pg_stat_activity CASCADE;

Hope this helps.

Thanks,
Bajrang Panigrahi

con risposta 5 anni fa
0

Resolved via AWS technical support.

con risposta 5 anni fa
0

We are glad that AWS Premium Support was able to help you in upgrading the instance from 9.5.15 to 9.6.11.

con risposta 5 anni fa
0

Is there something to resolve this that I can do without opening a support case? I have the same issue.

bja
con risposta 5 anni fa

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande