You're viewing Apigee Edge documentation.
Go to the
Apigee X documentation. info
Symptom
You get an error when updating the PostgreSQL database.
Error Message
ERROR: PostgreSQL Upgrade FAILED
Possible Causes
Cause | Description | Troubleshooting instructions apply to |
---|---|---|
Incorrect replication settings in PostgreSQL configuration file | The PostgreSQL upgrade fails due to incorrect replication settings during the upgrade. | Edge Private Cloud Users |
PostgreSQL installation performed by another install user other than the apigee user | PostgreSQL was installed initially with another user as an install user, which leads to upgrade failure. | Edge Private Cloud Users |
Common Diagnosis Steps
If you get an error when upgrading the PostgreSQL database, perform the following diagnostic steps first:
Rename the PostgreSQL data folder:
mv /opt/apigee/data/apigee-postgresql/pgdata /opt/apigee/data/apigee-postgresql/pgdata-bkp
Ensure that your original backup data is in a folder named
/opt/apigee/data/apigee-postgresql/pgdata-version.old/
For example:
/opt/apigee/data/apigee-postgresql/pgdata-9.6.old/
Restore the backup data in
/opt/apigee/data/apigee-postgresql/pgdata-version.old/
to/opt/apigee/data/apigee-postgresql/pgdata
using following command:mv /opt/apigee/data/apigee-postgresql/pgdata-version.old/ /opt/apigee/data/apigee-postgresql/pgdata
For example:
mv /opt/apigee/data/apigee-postgresql/pgdata-9.6.old/ /opt/apigee/data/apigee-postgresql/pgdata
Rerun the
db_upgrade
command:/opt/apigee/apigee-service/bin/apigee-service apigee-postgresql db_upgrade
If you get following error...
pg_resetxlog: could not open file "global/pg_control" for reading: No such file or directory
...then rename the
pg_control.old
file topg_control
using following command:mv /apigee/apigeeinst/data/apigee-postgresql/pgdata/global/pg_control.old /apigee/apigeeinst/data/apigee-postgresql/pgdata/global/pg_control
Rerun the
db_upgrade
command:/opt/apigee/apigee-service/bin/apigee-service apigee-postgresql db_upgrade
If the problem persists, go to Cause: Incorrect replication settings in PostgreSQL configuration file.
Cause: Incorrect replication settings in PostgreSQL configuration file
Diagnosis
- Check if the PostgreSQL configuration file
/opt/apigee/apigee-postgresql/conf/pg_hba.conf
has the replication settings that you intend. - If this file has the expected replication settings, then go to PostgreSQL installation performed by another install user other than "apigee" user.
- If not, go to Resolution.
Resolution
Rename the PostgreSQL data folder using the following command:
mv /opt/apigee/data/apigee-postgresql/pgdata /opt/apigee/data/apigee-postgresql/pgdata-bkp
Ensure that the original backup data is in a folder named:
/opt/apigee/data/apigee-postgresql/pgdata-version.old/
For example:
/opt/apigee/data/apigee-postgresql/pgdata-9.6.old/
Restore the backup data from
/opt/apigee/data/apigee-postgresql/pgdata-version.old/
to/opt/apigee/data/apigee-postgresql/pgdata
using following command:mv /opt/apigee/data/apigee-postgresql/pgdata-version.old/ /opt/apigee/data/apigee-postgresql/pgdata
For example:
mv /opt/apigee/data/apigee-postgresql/pgdata-9.6.old/ /opt/apigee/data/apigee-postgresql/pgdata
If you ever changed slave host then you must update following property in
/opt/apigee/customer/application/postgresql.properties
to update the config filepg_hba.conf
:conf_pg_hba_replication.connection=host replication apigee existing_slave_ip/32 trust\ \nhost replication apigee new_slave_ip/32 trust
Restart the
apigee-postgresql
service to ensure that the property set in Step 4 above gets updated into the config filepg_hba.conf
:/opt/apigee/apigee-service/bin/apigee-service apigee-postgresql restart
Make the config file
pg_hba.conf
immutable using the following command to ensure that it does not get updated with incorrect settings during the PostgreSQL upgrade:chattr +i /opt/apigee/apigee-postgresql/conf/pg_hba.conf
Rerun the
db_upgrade
command:/opt/apigee/apigee-service/bin/apigee-service apigee-postgresql db_upgrade
Remove the immutable setting on the config file
pg_hba.conf
:chattr -i /opt/apigee/apigee-postgresql/conf/pg_hba.conf
Cause: PostgreSQL installation performed by another install user other than the apigee
user
Diagnosis
Check if there is any other user that has rolesuper set to true by following these steps:
On the PostgreSQL node, log in to PostgreSQL using following command:
psql -h $(hostname -i) -U apigee
Run the following SQL query:
select * from pg_authid;
Check if there are multiple users having rolesuper set to true. If there are, then the PostgreSQL upgrade is failing because another user has been set as install user instead of the apigee user. Any user with the rolesuper role and a lower OID is considered to be an install user.
To check this kind of role problem, run the following SQL queries:
select oid,rolname,rolsuper from pg_roles; select * from pg_user;
Resolution
Login to PostgreSQL using following command:
psql -h $(hostname -i) -U apigee
Rename the existing
apigee
role in old DB to a temporary user (for example:apigee2
):update pg_authid set rolname ='apigee2' where rolname = 'apigee';
Let's say there was another install user
srcapige
. Rename thesrcapige
role toapigee
:update pg_authid set rolname ='apigee' where rolname = 'srcapigee';
Rename the
apigee2
to thesrcapige
user:update pg_authid set rolname ='secapigee' where rolname = 'apigee2';
Update the password for all the renamed users:
ALTER ROLE apigee WITH PASSWORD '<secret>'; ALTER ROLE srcapige WITH PASSWORD '<secret>';
Rename the PostgreSQL data folder using the following command:
mv /opt/apigee/data/apigee-postgresql/pgdata /opt/apigee/data/apigee-postgresql/pgdata-bkp
Ensure that there is original backup data inside a folder named
/opt/apigee/data/apigee-postgresql/pgdata-version.old/
For example:
/opt/apigee/data/apigee-postgresql/pgdata-9.6.old/
Restore the data in the
/opt/apigee/data/apigee-postgresql/pgdata-version.old/
folder to/opt/apigee/data/apigee-postgresql/pgdata
using following command:mv /opt/apigee/data/apigee-postgresql/pgdata-version.old/ /opt/apigee/data/apigee-postgresql/pgdata
For example:
mv /opt/apigee/data/apigee-postgresql/pgdata-9.6.old/ /opt/apigee/data/apigee-postgresql/pgdata
Rerun the
db_upgrade
command:/opt/apigee/apigee-service/bin/apigee-service apigee-postgresql db_upgrade
Restart all
apigee-qpidd
andedge-qpid-server
services:/opt/apigee/apigee-service/bin/apigee-service apigee-qpidd restart
/opt/apigee/apigee-service/bin/apigee-service edge-qpid-server restart
If the problem still persists, go to Must gather diagnostic information.
Must gather diagnostic information
If the problem persists after following the above troubleshooting instructions, gather the following diagnostic information. Contact Apigee Support and share this information with the support team:
- Add
set -x
on the second line of the/opt/apigee/apigee-postgresql/lib/actions/db_upgrade
file. Follow the Common diagnosis steps and provide the console output of the
db_upgrade
command to the support team:opt/apigee/apigee-service/bin/apigee-service apigee-postgresql db_upgrade
Provide the following log files to the support team:
/opt/apigee/var/log/apigee-postgresql/apigee-postgresql.log /opt/apigee/var/log/apigee-postgresql/update.log
Provide the output of the following operating system commands to check if alternatives are set to
auto
.update-alternatives --display psql
OR
update-alternatives --display pgsql
update-alternatives --list psql
OR
update-alternatives --list pgsql
If alternatives are set to
manual
, you can set them toauto
using following command:update-alternatives --auto psql
Setting the alternatives to
auto
points thepsql
andpostgres
binaries to the upgraded versions. Otherwise, the binaries will point to the older version, which can cause issues.