When doing a database restore with gprestore, we might see some of the views may fail to be restored with the below error: (ERROR: schema "xxx" does not exist (SQLSTATE 3F000))
20220725:11:42:20 gprestore:gpadmin:gp-aio-01:102030-[DEBUG]:-Error encountered when executing statement: CREATE VIEW a.view1 AS SELECT table1.generate_series FROM b.table1; Error was: ERROR: schema "b" does not exist (SQLSTATE 3F000)
20220725:11:42:20 gprestore:gpadmin:gp-aio-01:102030-[CRITICAL]:-ERROR: schema "b" does not exist (SQLSTATE 3F000)
The issue may be observed when matching the below condition:1. restore data to a new database
2. the schema we are restoring includes tables from other schema.
Here is an example:
# create view a.view1 as select * from b.table1 ;
# gpbackup --backup-dir /data/backup/test_0725 --include-schema a --dbname gpadmin
# gprestore --create-db --include-schema a --timestamp 20220725114122 --redirect-db gpadmin_new --backup-dir /data/backup/test_0725
20220725:11:42:18 gprestore:gpadmin:gp-aio-01:102030-[INFO]:-Restore Key = 20220725114122
20220725:11:42:18 gprestore:gpadmin:gp-aio-01:102030-[INFO]:-Creating database
20220725:11:42:20 gprestore:gpadmin:gp-aio-01:102030-[INFO]:-Database creation complete for: gpadmin_new
20220725:11:42:20 gprestore:gpadmin:gp-aio-01:102030-[INFO]:-Restoring pre-data metadata
Pre-data objects restored: 0 / 4 [--------------------------------------------------------] 0.00%20220725:11:42:20 gprestore:gpadmin:gp-aio-01:102030-[CRITICAL]:-ERROR: schema "b" does not exist (SQLSTATE 3F000)
20220725:11:42:20 gprestore:gpadmin:gp-aio-01:102030-[INFO]:-Found neither /opt/greenplum_5.29.1/bin/gp_email_contacts.yaml nor /home/gpadmin/gp_email_contacts.yaml
20220725:11:42:20 gprestore:gpadmin:gp-aio-01:102030-[INFO]:-Email containing gprestore report /data/backup/test_0725/gpdb_5.29.1_-1/backups/20220725/20220725114122/gprestore_20220725114122_20220725114218_report will not be sent