Tuesday, July 14, 2015

GREENPLUM DB -ERROR: Query to obtain distribution policy of table “test_f” returned more than one policy


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

GREENPLUM DB- Install error -Failed to insert port


I was installing Greenplum database  with standby and mirror segments on one of the clusters and the initialization failed. The message said "Failed to insert port"

20140429:07:19:56:043669 gpcreateseg.sh:gp-rpt--master:gpadmin-[WARN]:-Failed to insert port=41001 in /gpdata/mirror/gpseg9/postgresql.conf on gp-rpt--ss07-1
20140429:07:19:56:043669 gpcreateseg.sh:gp-rpt--master:gpadmin-[INFO]:-End Function ED_PG_CONF
20140429:07:19:56:043669 gpcreateseg.sh:gp-rpt--master:gpadmin-[FATAL][27]:-Failed Update port number to 41001
20140429:07:19:57:018921 gpinitsystem:gp-rpt--master:gpadmin-[INFO]:-End Function PARALLEL_WAIT
20140429:07:19:57:018921 gpinitsystem:gp-rpt--master:gpadmin-[INFO]:-End Function PARALLEL_COUNT
20140429:07:19:57:018921 gpinitsystem:gp-rpt--master:gpadmin-[INFO]:-Start Function PARALLEL_SUMMARY_STATUS_REPORT
20140429:07:19:57:018921 gpinitsystem:gp-rpt--master:gpadmin-[INFO]:------------------------------------------------
20140429:07:19:57:018921 gpinitsystem:gp-rpt--master:gpadmin-[INFO]:-Parallel process exit status
20140429:07:19:57:018921 gpinitsystem:gp-rpt--master:gpadmin-[INFO]:------------------------------------------------
20140429:07:19:57:018921 gpinitsystem:gp-rpt--master:gpadmin-[INFO]:-Total processes marked as completed = 0
20140429:07:19:57:018921 gpinitsystem:gp-rpt--master:gpadmin-[INFO]:-Total processes marked as killed = 0
20140429:07:19:57:018921 gpinitsystem:gp-rpt--master:gpadmin-[WARN]:-Total processes marked as failed = 28 <<<<<
20140429:07:19:57:018921 gpinitsystem:gp-rpt--master:gpadmin-[INFO]:------------------------------------------------
20140429:07:19:57:018921 gpinitsystem:gp-rpt--master:gpadmin-[INFO]:-End Function PARALLEL_SUMMARY_STATUS_REPORT
FAILED:gp-rpt--ss02-2~41000~/gpdata/mirror/gpseg0~30~0~43000

Later I found out that the error was because of a missing package in the servers. The package in question was "ed". I installed the package on all the servers and the installation completed successfully.

GREENPLUM DB- WARNING: PID 1234 is not a PostgreSQL server process


In one of the GreenPlum databases I encountered the below issue while killing sessions belonging to a particular schema. I got the below warning message.

select pg_terminate_backend(pid) from (select distinct t.relname,l.pid from pg_locks l, pg_stat_all_tables t where l.relation=t.relid and t.schemaname = 'test') x;
WARNING: PID 1234 is not a PostgreSQL server process
WARNING: PID 1234 is not a PostgreSQL server process
WARNING: PID 1234 is not a PostgreSQL server process
WARNING: PID 1234 is not a PostgreSQL server process
WARNING: PID 1234 is not a PostgreSQL server process

I found it bit strange as it was showing some process as non PostgreSQL server process.When checked for that particular pid,we got the below output.

select * from pg_locks where pid='1234';
locktype | database | relation | page | tuple | transactionid | classid | objid | objsubid | transaction | pid | mode | granted | mppsessionid | mppiswriter | gp_segment_id
----------+----------+----------+------+-------+---------------+---------+-------+----------+-------------+-------+-----------------+---------+--------------+-------------+---------------
relation | 16992 | 5560001 | | | | | | | 0 | 1234 | AccessShareLock | t | 17261 | f | 27
relation | 16992 | 5565834 | | | | | | | 0 | 1234 | AccessShareLock | t | 17261 | f | 27
relation | 16992 | 5522075 | | | | | | | 0 | 1234 | AccessShareLock | t | 17261 | f | 27
relation | 16992 | 5527866 | | | | | | | 0 | 1234 | AccessShareLock | t | 17261 | f | 27
relation | 16992 | 5536419 | | | | | | | 0 | 1234 | AccessShareLock | t | 17261 | f | 27
relation | 16992 | 5514445 | | | | | | | 0 | 1234 | AccessShareLock | t | 17261 | f | 27
relation | 16992 | 5568505 | | | | | | | 0 | 1234 | AccessShareLock | t | 17261 | f | 27
relation | 16992 | 5523793 | | | | | | | 0 | 1234 | AccessShareLock | t | 17261 | f | 27
relation | 16992 | 5555297 | | | | | | | 0 | 1234 | AccessShareLock | t | 17261 | f | 27
(9 rows)

From the above we could find out that the process was running on segment 27 in one of the segment servers and we killed the same on the segment server. This was a SELECT zombie process and could not find any link to this. 

After killing the process we were able to kill the sessions belonging to the 'test' schema.We were not able to terminate this process using pg_terminate since this was running on the segment server and not on the master.