Re: identify_locking_dependencies is broken for schema-only dumps

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: identify_locking_dependencies is broken for schema-only dumps
Date: 2014-09-24 14:06:30
Message-ID: CA+TgmoawfwbbNyRbp5uZCwazagN52tQzT3WJG4JiH0OYp3h9Fg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Sep 19, 2014 at 11:23 AM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> This can lead to deadlocks during parallel restore. Test case:
>
> create table bar (a int primary key, b int);
> create table baz (z int, a int references bar);
> create view foo as select a, b, sum(1) from bar group by a union all
> select z, a, 0 from baz;
>
> I dumped this with: pg_dump -Fc -s -f test.dmp
> Then: while (dropdb rhaas; createdb; pg_restore -O -d rhaas -j3
> test.dmp); do true; done
>
> This quickly fails for me with:
>
> pg_restore: [archiver (db)] Error while PROCESSING TOC:
> pg_restore: [archiver (db)] Error from TOC entry 2155; 2606 47822 FK
> CONSTRAINT baz_a_fkey rhaas
> pg_restore: [archiver (db)] could not execute query: ERROR: deadlock detected
> DETAIL: Process 81791 waits for AccessExclusiveLock on relation 47862
> of database 47861; blocked by process 81789.
> Process 81789 waits for AccessShareLock on relation 47865 of database
> 47861; blocked by process 81791.
> HINT: See server log for query details.
> Command was: ALTER TABLE ONLY baz
> ADD CONSTRAINT baz_a_fkey FOREIGN KEY (a) REFERENCES bar(a);
> WARNING: errors ignored on restore: 2
>
> The attached patch seems to fix it for me.
>
> Comments?

If there are no comments on this soon-ish, I'm going to push and
back-patched the patch I attached.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2014-09-24 14:08:59 Re: Final Patch for GROUPING SETS
Previous Message Merlin Moncure 2014-09-24 13:59:39 Re: "Core" function in Postgres