Deadlock during run_maintenance_proc #833
Replies: 3 comments 1 reply
-
|
Can you try making a more detailed log_line_prefix that includes at least timestamps, PIDs, log line numbers, and users? Here's an example of one that I frequently use This will allow you to see when things are happening, the PID of the action for the given log line, who did it and a line number to easily keep track of the order of operations for actions by the same PID (in case timestamps are the same). Once you have that set, you should be able to look back through your logs and look up both queries that were running for the PIDs that are involved in the deadlock. There's no guarantee of order for a deadlocked session so it may take some hunting around in the logs to find everything involved. The log line number helps to keep things in the order they happened when extracting them for study. Another user ran into this similar issue here in this issue with only inserts happening: #796 From what we could tell there, it was the locks that PostgreSQL itself takes out around the default table during maintenance due to having to change its constraints whenever a new table is dropped/added. For him, I'd suggested trying to take out an exclusive lock on the partition set before maintenance ran on it to see if that might help. I'd avoided doing that in pg_partman itself since that's a pretty heavyweight lock to be doing by default on normal maintenance runs and it may not even solve the problem. You can also try taking this particular partition set out of the full maintenance run that tries to run on all active partition sets to reduce the length of the transaction involved. Instructions for that are in that issue as well. |
Beta Was this translation helpful? Give feedback.
-
|
Actually, since you said all of your inserts are for "now" you might be able to drop the default table. Note that would cause errors to be thrown and that data would be lost if its outside the expected child table window, but if that's ok for your situation, then that may solve the issue if yours is the same as the other user's. |
Beta Was this translation helpful? Give feedback.
-
|
It doesn't matter if there is data in the default or not. In the case of the other user, it was simply the locks that PG is taking on the default and parent to drop the old table. Either dropping or creating a new table requires a change to the constraint that exists on the default. If that is the case, it's not really anything in pg_partman itself causing the deadlock and you may have to escalate to creating a bug with upstream if you have a reproducible test case. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey everybody! I have pg_partman on my cosmos db for PostgreSQL (16) to partition my table called transactions, in my table my primary key is uuidv7 which I use it as my partition key, the table is under load and all requests are inserts to the table, id generated by current time so all inserts are for right now I don't have inserts for past or future. here you can see my partman config:
Note: I need constraint to be valid at least in the range of 30 days partitions, and also I need to drop tables to free up space on my disk.
after setting retention for my table I'm getting deadlock from
run_maintenance_proc()which happens during dropping old partitionmay you please help me how can I resolve this problem?
Beta Was this translation helpful? Give feedback.
All reactions