On 2019-Oct-05, Alvaro Herrera wrote:
> While playing around I noticed that depending on the number of parallel
> workers in pg_restore compared to the number of partitions a table has,
> restoring an FK fails because the FK itself is restored before the index
> partitions have completed restoring. The exact conditions to cause the
> failure seem to vary depending on whether the dump is schema-only or not.
>
> This can seemingly be fixed by having pg_dump make the constraint depend
> on the attach of each partition, as in the attached patch. With this
> patch I no longer see failures.
Pushed with some additional tweaks.
Parallel restore of partitioned tables containing data and unique keys
still fails with some deadlock errors, though :-(
--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services