How does partition_data_proc in online make sure new rows that match the partition being created don't get inserted in the default table? #513
-
Hi From looking at the code, partition_data_proc calls partition_data_time or partition_data_id, which in turns create a temporary table and copies data to it before creating the partition. In-between those 2 things, a transaction could insert new rows matching the future partition's range and that row would end up in the default table thus preventing the partition from being created. Is this something pg_partman protects itself against? If so, how does it do it? Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
So, I think one of two things would happen.
This is an interesting case that I hadn't actually thought about and may have some relevance to work I'm doing in 5.x. I may have to leave a setting in place to allow a workaround for this. Thanks for bringing it up! Either way, I don't think PostgreSQL is going to let an inconsistent state exist in the end. Would have to test things out and see which happens. |
Beta Was this translation helpful? Give feedback.
-
So 5.x will ignore data in the default partition by default. But it is done with a flag that is set to true by default (I'd forgotten I'd already done this!). So you could set that to false for the given partition set when this occurs. Once the application moves past inserting data for the child tables that are missing, you should then be able to run After that, I would recommend resetting the flag so it ignores data in the default for partition maintenance and errors out again. Errant data in the default can cause weird child table generation if it is really far out of bounds. Either way, you should also monitor for data going into the default with the |
Beta Was this translation helpful? Give feedback.
So, I think one of two things would happen.