Re: pg_restore: fails to restore post-data items due to circular FK deadlock

From: vaibhave postgres <postgresvaibhave(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: pg_restore: fails to restore post-data items due to circular FK deadlock
Date: 2026-01-25 10:54:51
Message-ID: CAM_eQjxFzak3yGrNbuj0ytSd4WexX5Wehs1ukqDG8mONK9EruQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Thu, May 30, 2024 at 11:59 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> vaibhave postgres <postgresvaibhave(at)gmail(dot)com> writes:
> > 1. Create a database which has circular foreign key dependencies. (or use
> > the sql script which I have shared), restore the pre-data section first.
> > 2. pg_dump -Fc *--section=post-data*
> > 3. pg_restore --jobs > 1
>
> > pg_restore fails to record the dependency between the foreign keys and
> > tries to process them in parallel (see the attached log file for details)
>
> The reason this works in other cases is that pg_restore recognizes
> that two ADD CONSTRAINT steps shouldn't be run concurrently when they
> have dependencies on the same table(s). However, when you use
> --section=post-data to create the dump file, there are no entries for
> the tables.
>
> So this seems like a "don't do that" case. You could get the results
> you want by using --schema-only at dump time and then using
> --section=post-data as a pg_restore switch. (That'd also avoid the
> need to make two separate dump files.)
>
> Possibly we should add something to the docs about this.
>
> regards, tom lane
>

Attachment Content-Type Size
0001-doc-warn-about-post-data-only-schema-dumps-with-para.patch application/octet-stream 1.4 KB

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2026-01-25 16:28:45 BUG #19389: pg_dump output differs after setting schema comment to NULL
Previous Message vaibhave postgres 2026-01-25 10:47:34 Re: BUG #19384: Server crash at textout