From: Artur Zając <azajac@ang.com.pl>
To: pgsql-general@lists.postgresql.org
Subject: RE: Table locking during backup
Date: Tue, 8 Oct 2019 08:40:58 +0200
Message-ID: <02b701d57da3$57bea1f0$073be5d0$@ang.com.pl> (raw)
In-Reply-To: <20191007211930.r53ockkfjkx3gbzt@development>
References: <021f01d57d52$3397e300$9ac7a900$@ang.com.pl>
<20191007211930.r53ockkfjkx3gbzt@development>
> 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: azajac@ang.com.pl
Subject: Re: Table locking during backup
In-Reply-To: <02b701d57da3$57bea1f0$073be5d0$@ang.com.pl>
References: <021f01d57d52$3397e300$9ac7a900$@ang.com.pl> <20191007211930.r53ockkfjkx3gbzt@development> <02b701d57da3$57bea1f0$073be5d0$@ang.com.pl>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox