pg_partman
pg_partman copied to clipboard
run_maintenance function fails to drop partition because of (replication set) dependency
The partition is part of pglogical replication set. We use pglogical for logical replication. run_maintenance fails because of this. ERROR: cannot drop table pgpoc.part_test_daily_p2023_04_26 because other objects depend on it CONTEXT: SQL statement "DROP TABLE pgpoc.part_test_daily_p2023_04_26" PL/pgSQL function drop_partition_time(text, interval,boolean,boolean,text,timestamp with timezone) line 213 at EXECUTE DETAIL: table pgpoc.part_test_daily_p2023_04_26 membership in replication set rset03 depends on table pgpoc.part_test_daily_p2023_04_26 HINT: Use DROP ... CASCADE to drop the dependent objects too.
What options do I have? Is there a CACADE option that I can provide to run_maintenance to drop the table? I know using DROP CASCADE will remove the table from replication set also. Please advise.
Thanks Hari
I had not planned for this situation, so there's no way that's built into pg_partman to drop a child table that has other dependencies like this. You'll have to remove the child table from the replication set before normal maintenance will work at this time.
I'll leave this open as an issue to investigate adding support for this in the future
I have a beta PR up that should remove tables from publications if they are removed from the partition set as part of retention maintenance. It's a new flag in the part_config
tables that defaults to true. If you're able to test and give any feedback, it would be appreciated.
https://github.com/pgpartman/pg_partman/pull/615
I've added a unit test to check that this feature is working, so hopefully it should be good. If you have a chance to test it, it would still be appreciated. Will hopefully have the release out in the near future.
Version 5.1 has been released with this fix