Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iHjBA-00047Y-7Z for pgsql-general@arkaria.postgresql.org; Tue, 08 Oct 2019 06:41:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iHjB8-00008x-Tz for pgsql-general@arkaria.postgresql.org; Tue, 08 Oct 2019 06:41:02 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iHjB8-00008S-K9 for pgsql-general@lists.postgresql.org; Tue, 08 Oct 2019 06:41:02 +0000 Received: from cloudserver124499.home.pl ([188.128.182.39]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iHjB6-0000j2-FS for pgsql-general@lists.postgresql.org; Tue, 08 Oct 2019 06:41:02 +0000 Received: from host-188.117.168.42.static.3s.pl (188.117.168.42) (HELO DESKTOP5IS4FKS) by serwer1372326.home.pl (188.128.182.39) with SMTP (IdeaSmtpServer 0.83.292) id 7669b71b202a8aa0; Tue, 8 Oct 2019 08:40:58 +0200 From: =?utf-8?Q?Artur_Zaj=C4=85c?= To: References: <021f01d57d52$3397e300$9ac7a900$@ang.com.pl> <20191007211930.r53ockkfjkx3gbzt@development> In-Reply-To: <20191007211930.r53ockkfjkx3gbzt@development> Subject: RE: Table locking during backup Date: Tue, 8 Oct 2019 08:40:58 +0200 Message-ID: <02b701d57da3$57bea1f0$073be5d0$@ang.com.pl> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQE+0JW5D9Rpi2eYBc1OsvvrSBIzPQKFmNfHqGl1b6A= Content-Language: pl List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk > Not sure why would it matter that the pg_dump connection is read-only, = this is about locking because=20 > 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.=20 After all, your answer does not explain everything. I tried to reproduce = the minimum commands: First session: BEGIN;=20 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