RE: Table locking during backup

From: Artur Zając <azajac(at)ang(dot)com(dot)pl>
To: <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: RE: Table locking during backup
Date: 2019-10-08 06:40:58
Message-ID: 02b701d57da3$57bea1f0$073be5d0$@ang.com.pl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


> Not sure why would it matter that the pg_dump connection is read-only, this is about locking because
> pg_dump needs to ensure the schema does not change while it's running.
> pg_dump does not do
>
> LOCK TABLE gm.tableabc;
>
> but
>
> LOCK TABLE gm.tableabc IN ACCESS SHARE MODE;
>
> Which should be visible in pg_locks system view. And it does conflict with the ACCESS EXCLUSIVE mode, > used by the second query.

My mistake. I cited the log incorrectly - of course should be (and there was) LOCK TABLE gm.tableabc IN ACCESS SHARE MODE.
After all, your answer does not explain everything. I tried to reproduce the minimum commands:

First session:

BEGIN;
set transaction isolation level repeatable read, read only;
lock TABLE gm.tableabc IN access share mode;

Second session:
BEGIN;
CREATE TEMP TABLE IF NOT EXISTS tableabc (Id BIGINT DEFAULT random()) INHERITS (gm.tableabc);

"CREATE TEMP TABLE" does not wait for anything. Waiting state is only when I start third session with the same queries as in second.

Maybe "LOCK TABLE ... IN ACCESS SHARE MODE" is the answer, but with correlation with some other query or setting setted by pg_backup.

Table gm.tableabc is created with "create table gm.tableabc (x int default random());"

AZ

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Arnaud L. 2019-10-08 07:06:41 Re: psql \copy hanging
Previous Message Konstantin Izmailov 2019-10-08 02:23:49 Re: COPY command returns "ERROR: invalid XML content"