[BUG] pg_dump blocked

From: Gilles Darold <gilles(at)darold(dot)net>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: [BUG] pg_dump blocked
Date: 2022-11-17 16:43:38
Message-ID: 45c93d57-9973-248e-d2df-e02ca9af48d4@darold.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

I have an incorrect behavior with pg_dump prior PG version 15. With
PostgreSQL 15, thanks to commit e3fcbbd623b9ccc16cdbda374654d91a4727d173
the problem is gone but for older versions it persists with locks on
partitioned tables.

When we try to dump a database where a table is locked, pg_dump wait
until the lock is released, this is expected. Now if the table is
excluded from the dump using the -T option, obviously pg_dump is not
concerned by the lock. Unfortunately this is not the case when the table
is partitioned because of the call to pg_get_partkeydef(), pg_get_expr()
in the query generated in getTables().  Here is the use case to reproduce.

In a psql session execute:

BEGIN;

LOCK TABLE measurement;

then run a pg_dump command excluding the measurement partitions:

    pg_dump -d test -T "measurement*" > /dev/null

it will not end until the lock on the partition is released.

I think the problem is the same if we use a schema exclusion where the
partitioned table is locked.

Is it possible to consider a backport fix? If yes, does adding the
table/schema filters in the query generated in getTables() is enough or
do you think about of a kind of backport of commit
e3fcbbd623b9ccc16cdbda374654d91a4727d173 ?

Best regards,

--
Gilles Darold

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2022-11-17 16:59:18 Re: [BUG] pg_dump blocked
Previous Message David Christensen 2022-11-17 16:34:48 Re: Moving forward with TDE