Jira (PDB-5553) Remove foreign keys from report partitions

0 views
Skip to first unread message

Austin Blatt (Jira)

unread,
Oct 20, 2022, 5:03:02 PM10/20/22
to puppe...@googlegroups.com
Austin Blatt created an issue
 
PuppetDB / Improvement PDB-5553
Remove foreign keys from report partitions
Issue Type: Improvement Improvement
Assignee: Unassigned
Created: 2022/10/20 2:02 PM
Priority: Normal Normal
Reporter: Austin Blatt

Foreign keys are "one-directional" in theory (ie. one table references another), but Postgres implements them via bidirectional triggers on each table. This means that when dropping a report partition that has FKs on certnames, environments, and producers we need access exclusive locks on all those tables.

This causes all commands (maybe-create-certname), and queries (active nodes CTE) to back up until it finishes.

Additionally, the GC routine generally gets its locks in the opposite order of command processing (that is both wrong and bad), which can cause deadlocks (see PE-34458).

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v8.20.11#820011-sha1:0629dd8)
Atlassian logo

Nick Lewis (Jira)

unread,
Oct 26, 2022, 1:21:01 PM10/26/22
to puppe...@googlegroups.com
Nick Lewis updated an issue
Change By: Nick Lewis
Team: Skeletor

Austin Blatt (Jira)

unread,
Nov 3, 2022, 2:00:02 PM11/3/22
to puppe...@googlegroups.com
Austin Blatt updated an issue
Change By: Austin Blatt
Foreign keys are "one-directional" in theory (ie. one table references another), but Postgres implements them via bidirectional triggers on each table. This means that when dropping a report partition that has FKs on certnames, environments, and producers we need access exclusive locks on all those tables.

This causes all commands (maybe-create-certname), and queries (active nodes CTE) to back up until it finishes.


Additionally, the GC routine generally gets its locks in the opposite order of command processing (that is both wrong and bad), which can cause deadlocks (see PE-34458).

Cas Donoghue (Jira)

unread,
Nov 3, 2022, 2:23:03 PM11/3/22
to puppe...@googlegroups.com

Cas Donoghue (Jira)

unread,
Nov 9, 2022, 1:17:01 PM11/9/22
to puppe...@googlegroups.com
Cas Donoghue updated an issue
Change By: Cas Donoghue
Sprint: Skeletor 11/23/2022

Austin Blatt (Jira)

unread,
Nov 11, 2022, 12:50:01 PM11/11/22
to puppe...@googlegroups.com
Austin Blatt assigned an issue to Austin Blatt
Change By: Austin Blatt
Assignee: Austin Blatt

Cas Donoghue (Jira)

unread,
Nov 23, 2022, 1:48:02 PM11/23/22
to puppe...@googlegroups.com
Cas Donoghue updated an issue
Change By: Cas Donoghue
Sprint: Skeletor 11/23/2022 , Skeletor 12/07/2022

Sean McDonald (Jira)

unread,
Dec 7, 2022, 1:06:03 PM12/7/22
to puppe...@googlegroups.com
Sean McDonald updated an issue
Change By: Sean McDonald
Sprint: Skeletor 11/23/2022, Skeletor 12/07/2022 , Skeletor 12/21/2022

Cas Donoghue (Jira)

unread,
Jan 4, 2023, 1:13:01 PM1/4/23
to puppe...@googlegroups.com
Cas Donoghue updated an issue
Change By: Cas Donoghue
Sprint: Skeletor 11/23/2022, Skeletor 12/07/2022, Skeletor 12/21/2022 , Skeletor 01/18/2023

Cas Donoghue (Jira)

unread,
Jan 18, 2023, 1:25:03 PM1/18/23
to puppe...@googlegroups.com
Cas Donoghue updated an issue
Change By: Cas Donoghue
Sprint: Skeletor 11/23/2022, Skeletor 12/07/2022, Skeletor 12/21/2022, Skeletor 01/18/2023 , Skeletor 02/01/2023

Cas Donoghue (Jira)

unread,
Feb 1, 2023, 1:17:02 PM2/1/23
to puppe...@googlegroups.com
Cas Donoghue updated an issue
Change By: Cas Donoghue
Sprint: Skeletor 11/23/2022, Skeletor 12/07/2022, Skeletor 12/21/2022, Skeletor 01/18/2023, Skeletor 02/01/2023 , Skeletor 02/15/2023

Cas Donoghue (Jira)

unread,
Feb 15, 2023, 1:23:03 PM2/15/23
to puppe...@googlegroups.com
Cas Donoghue updated an issue
Change By: Cas Donoghue
Sprint: Skeletor 11/23/2022, Skeletor 12/07/2022, Skeletor 12/21/2022, Skeletor 01/18/2023, Skeletor 02/01/2023, Skeletor 02/15/2023 , Skeletor 03/01/2024

Austin Blatt (Jira)

unread,
Feb 15, 2023, 4:18:02 PM2/15/23
to puppe...@googlegroups.com
Austin Blatt commented on Improvement PDB-5553
 
Re: Remove foreign keys from report partitions

Migration and its test are ready for review, I am investigating if the purge nodes GC operation needs modification as a result. I will also add a test if that is the case, given no tests are currently failing.

Austin Blatt (Jira)

unread,
Feb 17, 2023, 7:25:02 PM2/17/23
to puppe...@googlegroups.com
Austin Blatt commented on Improvement PDB-5553

I verified that removing the foreign key resulted in purging nodes failing to remove the reports. I pushed a fix for that issue, but it still needs a test as none of our existing ones failed.

Austin Blatt (Jira)

unread,
Feb 21, 2023, 11:39:02 AM2/21/23
to puppe...@googlegroups.com
Austin Blatt commented on Improvement PDB-5553

added tests, this is ready for merge now

Joshua Partlow (Jira)

unread,
Feb 24, 2023, 2:03:02 PM2/24/23
to puppe...@googlegroups.com

The 7.x pipeline passed, and this is in 2021.7.3-rc1-60-gee127a6 which has been through the 2021.7.x integration pipeline. Adding a merge up pr for main now.

Joshua Partlow (Jira)

unread,
Feb 27, 2023, 2:54:03 PM2/27/23
to puppe...@googlegroups.com

This is merged up to main in ef929079a which is in 2023.1.0-rc1-74-g0c461fa, and that has run in the pe main ci. But that currently has a bunch of failures related to the test forge cert being expired.

Austin Blatt (Jira)

unread,
Feb 28, 2023, 12:46:03 PM2/28/23
to puppe...@googlegroups.com
Austin Blatt updated an issue
 
Change By: Austin Blatt
Release Notes: Not Needed
Release Notes Summary: This has little user-facing effect, the improvement to partition management is probably better documented in the release note for switching to declarative partitioning.

Austin Blatt (Jira)

unread,
Feb 28, 2023, 12:50:02 PM2/28/23
to puppe...@googlegroups.com
Austin Blatt updated an issue
Change By: Austin Blatt
Fix Version/s: PDB 7.12.2
Fix Version/s: PDB 8.0.0

Jonathan Newman (Jira)

unread,
Apr 4, 2023, 4:37:02 PM4/4/23
to puppe...@googlegroups.com
Jonathan Newman updated an issue
Change By: Jonathan Newman
Fix Version/s: PDB 7.12.2
Fix Version/s: PDB 7.13.0
Reply all
Reply to author
Forward
0 new messages