pg_partman icon indicating copy to clipboard operation
pg_partman copied to clipboard

run_maintenance function fails to drop partition because of (replication set) dependency

Open hrawulwa opened this issue 1 year ago • 3 comments

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

hrawulwa avatar May 03 '23 23:05 hrawulwa

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

keithf4 avatar May 08 '23 01:05 keithf4

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

keithf4 avatar Jan 24 '24 17:01 keithf4

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.

keithf4 avatar Mar 06 '24 22:03 keithf4

Version 5.1 has been released with this fix

keithf4 avatar Apr 05 '24 13:04 keithf4