Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

partman.run_maintenance failed #732

Open
Santoshkumar00723 opened this issue Jan 13, 2025 · 1 comment
Open

partman.run_maintenance failed #732

Santoshkumar00723 opened this issue Jan 13, 2025 · 1 comment

Comments

@Santoshkumar00723
Copy link

Hi Keith,

partman.run_maintenance job failed with below error. Because of this failure other table partition drop also didn't happened.

Can you please let me know the fix for this. partman version is 5

 Name     | Version |   Schema   |                         Description

--------------+---------+------------+--------------------------------------------------------------
pg_partman | 5.1.0 | partman | Extension to manage partitioned tables by time or ID

SELECT partman.run_maintenance('LOADTEST.order_header');

ERROR: cannot drop table order_header_p20241111 because other objects depend on it
CONTEXT: SQL statement "DROP TABLE "LOADTEST".order_header_p20241111"
PL/pgSQL function drop_partition_time(text,interval,boolean,boolean,text,timestamp with time zone) line 247 at EXECUTE
PL/pgSQL function partman.run_maintenance(text,boolean,boolean) line 195 at assignment
DETAIL: constraint order_line_header_fk on table order_line depends on table order_header_p20241111
constraint tender_fk on table tender_details depends on table order_header_p20241111
HINT: Use DROP ... CASCADE to drop the dependent objects too.
CONTEXT: PL/pgSQL function drop_partition_time(text,interval,boolean,boolean,text,timestamp with time zone) line 304 at RAISE
PL/pgSQL function partman.run_maintenance(text,boolean,boolean) line 195 at assignment
DETAIL:
HINT:
CONTEXT: PL/pgSQL function partman.run_maintenance(text,boolean,boolean) line 437 at RAISE

@keithf4
Copy link
Collaborator

keithf4 commented Jan 13, 2025

Do you have foreign keys coming in to this partition set? If so, it sounds like it's trying to drop a child table that has data that the other table referencing it needs.

pg_partman does not have the option to DROP CASCADE because if you do that, the entire foreign key reference to the entire partition set is dropped, not just the child table that is being removed. It's a bug that I believe has been reported to core, but I haven't heard any more on it

The solution would be to ensure that the data that exist in the child table that is being dropped has been deleted in the other table before the maintenance to remove that child table is run.

If this is not the case, please clarify the FK relationships to and from this partition set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants