-
We started seeing a Here is the exact error:
When I try to attach a partition manually there seems to be no problems.
Any help is much appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
Only thing within pg_partman I could think of that could cause this is calling the maintenance procedure more than once at the same time. Only other thing I can think of is to double-check that you don't have multiple cronjobs for maintenance scheduled. If that's not the case, are you able to get the full deadlock log out of the PG logs that shows what all the actual queries for each process were doing at the time of the deadlock? You may have to adjust your log_line_prefix to ensure it includes the PID so you can match things up. If you are seeing two different PIDs both calling maintenance at the same time, then something else is calling maintenance at the same time as your cron. |
Beta Was this translation helpful? Give feedback.
-
Alright, we have set this up in our staging env. However, we have not seen these deadlocks in in our lower environments, lets see what happens. The scheduled job is set to run tonight. Also, is there a difference between what is being run by the procedure and the function
This is an interesting point. We ran the alter table DDL (see below) in our production environment to attach the partition manually, which also created the anti-constraints on the default table. The command execution was almost instanteneous. If this was an issue with the underlying
Having a default table is useful when we may have to support data inserts outside the partition ranges. This paractically does not |
Beta Was this translation helpful? Give feedback.
The procedure just calls the function in a loop over all the partition sets. But the procedure runs individual transactions for each partition set vs one giant transaction if you called just the regular function. So it's mostly just a different transaction state.
One other thing I thought of that you're likely not doing when you make a child table manually is an analyze on the partition set. In the past, the analyze was enabled by default, but later versions of pg_partman disabled it by default (https://github.com/pgpartman/pg_partman/blob/master/sql/functions/run_maintenance.sql#L146). It doesn't look like you're enabling it from what I can see, but it's something else to check.
The dead…