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

Request: undo_parent #706

Open
Faithfinder opened this issue Nov 21, 2024 · 8 comments
Open

Request: undo_parent #706

Faithfinder opened this issue Nov 21, 2024 · 8 comments

Comments

@Faithfinder
Copy link

We're still experimenting with various partition configurations, and sometimes I decide that the current version is not something I want. In that case I just want to drop it, but I don't want garbage to stay in partman config. Can we have an undo_parent that will just remove everything about the table from partman configuration? Template and config entreis, and whatever

@keithf4
Copy link
Collaborator

keithf4 commented Nov 22, 2024

Interesting idea. Maybe something of a more general config clean up function that by default removes the config but with parameters to do other things optionally (remove the template table, cleanup sub-partition config, etc). I'll see what I can come up with or you're free to work on a PR as well.

@keithf4 keithf4 added this to the Future milestone Nov 22, 2024
@keithf4
Copy link
Collaborator

keithf4 commented Nov 22, 2024

Also, what does the undo_partition_proc() do or not do that you're trying to do differently here?

@Faithfinder
Copy link
Author

Faithfinder commented Nov 22, 2024

Also, what does the undo_partition_proc() do or not do that you're trying to do differently here?

Does undo_partition, proc or not, do anything to the config? As I've said, the goal is to just clean up intermediate experimental versions of tables. I can do it as easily as DROP TABLE parent from the database's perspective, but this will obviously leave all the pg_partman config objects.

Cleaning up pg_partman manually is also quite possible, but that would require me to understand precisely what gets created when create_parent is run, which is not something I want to keep in my brain

@keithf4
Copy link
Collaborator

keithf4 commented Nov 22, 2024

Yes, the undo_partition functions/procedure will clean up the configs and template tables as well. undo_partition_proc() just calls undo_partition in commit loops to avoid long transactions. All that's left is the target table with all the data.

I guess another option could be something to undo_partition that does not keep the data. So it just leaves an empty parent and cleans up all the config data and objects.

@Faithfinder
Copy link
Author

Yeah, docs don't make it sound like that's what undo_partition does. In hindsight this line says it:

Once all child tables have been uninherited/dropped, the configuration data is removed from pg_partman automatically.

but I thought it just means that it reverts

When this function is run, the undo_in_progress column in the configuration table is set to true. This causes all partition creation and retention management to stop.

But yeah, in the case I describe there's no need to keep anything

@Faithfinder
Copy link
Author

Also, naming: undo_partition just doesn't sounds like it's a reverse to create_parent

@keithf4
Copy link
Collaborator

keithf4 commented Nov 22, 2024

The undo_in_progress flag is there to avoid issues of maintenance running while an undo session is running, which could be highly likely when undoing a very large partition set.

Good point on the name. It's been like that for a long time now, tho. Maybe I'll reconsider a rename during the next major version update.

@nusratulhassan
Copy link

I was performing some tests in my local and wanted to try partman.create_parent with new parameters but couldn't find something like drop_parent. I had to delete it manually using
Delete from partman.part_config where parent_table= 'public.my_parent_table_name';

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

3 participants