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). |