We were running dump on of the schemas and the load failed with the error (ERROR: Query to obtain distribution policy of table “test_f” returned more than one policy)
The data dictionary was showing single entry for the table whereas the pg_class showed two entries for "test_f" table.
This table was dropped and recreated and then we awere having issues for "table_refresh" table.
Again the pg_class shows two entries whereas data dictionary did not!
PROD=# select oid,relname,relnamespace from pg_class where relname ='table_refresh';
oid | relname | relnamespace
---------+------------------------+--------------
907283 | table_refresh | 17423
1108754 | table_refresh | 149417
(2 rows)
Time: 1.128 ms
PROD=# select * from gp_distribution_policy where localoid in (907283,1108754);
localoid | attrnums
----------+----------
907283 | {1}
(1 row)
Time: 1.288 ms
PROD=# select * from gp_distribution_policy where localoid in (1108754);
localoid | attrnums
----------+----------
(0 rows)
Time: 1.056 ms
PROD=# select * from gp_distribution_policy where localoid in (907283);
localoid | attrnums
----------+----------
907283 | {1}
907283 | {1}
(2 rows)
Time: 1.151 ms
PROD=# select * from gp_distribution_policy where localoid = 907283;
localoid | attrnums
----------+----------
907283 | {1}
907283 | {1}
(2 rows)
Time: 1.187 ms
The reason why the load failed was because the catalog table gp_distribution_policy had more than one row for table table_refresh. This looks like bug in Greenplum.
Again setting the distribution for the table as below resolved the issue.
PROD=# alter table base.table_refresh set distributed randomly;
ALTER TABLE
Time: 17435.914 ms
PROD=# select * from gp_distribution_policy where localoid = 907283;
localoid | attrnums
----------+----------
907283 |
(1 row)
-Yadu