pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: John Lumby <johnlumby@hotmail.com>
Cc: Rui DeSousa <rui@crazybean.net>
Cc: pgsql-admin <pgsql-admin@postgresql.org>
Cc: Simon Riggs <simon@2ndquadrant.com>
Subject: Re: admin control over cancelling autovacuum when blocked by a lock
Date: Tue, 30 Apr 2019 17:03:30 -0400
Message-ID: <25357.1556658210@sss.pgh.pa.us> (raw)
In-Reply-To: <DM6PR06MB556232B024E3A05413B1B4D9A33A0@DM6PR06MB5562.namprd06.prod.outlook.com>
References: <DM6PR06MB556272F9CB7629B10CE86829A3390@DM6PR06MB5562.namprd06.prod.outlook.com>
	<CANP8+jJSysBHF_QRdYmT-iKQDy4yw8OaqgiLoNJPdjTX1bJB8w@mail.gmail.com>
	<DM6PR06MB556216D6085FE0B9C267E82CA33A0@DM6PR06MB5562.namprd06.prod.outlook.com>
	<19835.1556588662@sss.pgh.pa.us>
	<CANP8+j+yBChxtUPriLttV=orwdF7RWtpP+zjF_fCB2yscuJz=g@mail.gmail.com>
	<DM6PR06MB55628354552B06395479033BA33A0@DM6PR06MB5562.namprd06.prod.outlook.com>
	<ACF14079-4541-4300-978C-BEC42339B33F@crazybean.net>
	<DM6PR06MB5562C2FDF9D0BCB3617ADB42A33A0@DM6PR06MB5562.namprd06.prod.outlook.com>
	<CB30B39F-CE56-417A-8CFB-C23F07DD51B8@crazybean.net>
	<DM6PR06MB556232B024E3A05413B1B4D9A33A0@DM6PR06MB5562.namprd06.prod.outlook.com>

John Lumby <johnlumby@hotmail.com> 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





view thread (15+ messages)  latest in thread

Message-ID: <25357.1556658210@sss.pgh.pa.us>
Permalink:  ../25357.1556658210@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/25357.1556658210@sss.pgh.pa.us

 · 

reply

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-admin@postgresql.org
  Cc: tgl@sss.pgh.pa.us, johnlumby@hotmail.com, rui@crazybean.net, simon@2ndquadrant.com
  Subject: Re: admin control over cancelling autovacuum when blocked by a lock
  In-Reply-To: <25357.1556658210@sss.pgh.pa.us>
  References: <DM6PR06MB556272F9CB7629B10CE86829A3390@DM6PR06MB5562.namprd06.prod.outlook.com> <CANP8+jJSysBHF_QRdYmT-iKQDy4yw8OaqgiLoNJPdjTX1bJB8w@mail.gmail.com> <DM6PR06MB556216D6085FE0B9C267E82CA33A0@DM6PR06MB5562.namprd06.prod.outlook.com> <19835.1556588662@sss.pgh.pa.us> <CANP8+j+yBChxtUPriLttV=orwdF7RWtpP+zjF_fCB2yscuJz=g@mail.gmail.com> <DM6PR06MB55628354552B06395479033BA33A0@DM6PR06MB5562.namprd06.prod.outlook.com> <ACF14079-4541-4300-978C-BEC42339B33F@crazybean.net> <DM6PR06MB5562C2FDF9D0BCB3617ADB42A33A0@DM6PR06MB5562.namprd06.prod.outlook.com> <CB30B39F-CE56-417A-8CFB-C23F07DD51B8@crazybean.net> <DM6PR06MB556232B024E3A05413B1B4D9A33A0@DM6PR06MB5562.namprd06.prod.outlook.com> <25357.1556658210@sss.pgh.pa.us>

* 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