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 1hLZui-0007sr-5f for pgsql-admin@arkaria.postgresql.org; Tue, 30 Apr 2019 21:03:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hLZug-00068g-Ry for pgsql-admin@arkaria.postgresql.org; Tue, 30 Apr 2019 21:03:42 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hLZug-00060M-Bw for pgsql-admin@lists.postgresql.org; Tue, 30 Apr 2019 21:03:42 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hLZuZ-0001hP-Sf for pgsql-admin@postgresql.org; Tue, 30 Apr 2019 21:03:41 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x3UL3UMX025358; Tue, 30 Apr 2019 17:03:30 -0400 From: Tom Lane To: John Lumby cc: Rui DeSousa , pgsql-admin , Simon Riggs Subject: Re: admin control over cancelling autovacuum when blocked by a lock In-reply-to: References: <19835.1556588662@sss.pgh.pa.us> Comments: In-reply-to John Lumby message dated "Tue, 30 Apr 2019 20:46:33 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <25356.1556658210.1@sss.pgh.pa.us> Content-Transfer-Encoding: 8bit Date: Tue, 30 Apr 2019 17:03:30 -0400 Message-ID: <25357.1556658210@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk John Lumby writes: > On 04/30/2019 04:34 PM, Rui DeSousa wrote: >> Not really… analyze takes an exclusive lock; I believe. The result is >> that readers/analyze will block other readers and writes which is bad >> for concurrency. Readers should never be blocked :)… > Apparently not - at least, not on the table being analyzed : from > the 11.2 Reference : > |ANALYZE| requires only a read lock on the target table, so it can run > in parallel with other activity on the table. That's kind of inaccurate. A moment's experimentation will show you that what it really takes is ShareUpdateExclusiveLock, which it does mostly to ensure that no other ANALYZE is running concurrently on the same table. That lock type doesn't block ordinary reads or writes on the table. It probably conflicts with autovacuum though ... regards, tom lane