pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bossart, Nathan <bossartn@amazon.com>
To: Michael Paquier <michael@paquier.xyz>
Cc: Andres Freund <andres@anarazel.de>
Cc: Masahiko Sawada <sawada.mshk@gmail.com>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: Lyes Ameddah <lyes.amd@gmail.com>
Cc: Tomas Vondra <tomas.vondra@2ndquadrant.com>
Cc: pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>
Cc: pgsql-bugs@postgresql.org <pgsql-bugs@postgresql.org>
Subject: Re: BUG #14941: Vacuum crashes
Date: Fri, 30 Mar 2018 18:39:01 +0000
Message-ID: <4D1115BF-ED38-44E2-B799-C7F9E421A3B8@amazon.com> (raw)
In-Reply-To: <3834EFB8-2A90-41C7-A7C8-8B956150479D@amazon.com>
References: <32F4B778-292B-41AF-891A-497B8127CD59@amazon.com>
	<CAD21AoCsbqVh5P=ZA479DHrXmtUY2TxPxotE0jPiwM2+gQUjxw@mail.gmail.com>
	<5B80D67E-A664-495A-A0BE-CEA847676164@amazon.com>
	<20180109042720.GG76418@paquier.xyz>
	<4B232BD7-A97D-4461-81E6-28A49764B60E@amazon.com>
	<20180110025331.GE336@paquier.xyz>
	<CBEE19BB-6C70-424C-95E5-F8ABC7AA2185@amazon.com>
	<20180110231442.GA22983@paquier.xyz>
	<20180304001252.5sxn3glccnu5qxjm@alap3.anarazel.de>
	<7327B413-1A57-477F-A6A0-6FD80CB5482D@amazon.com>
	<20180307050345.GA3095@paquier.xyz>
	<3834EFB8-2A90-41C7-A7C8-8B956150479D@amazon.com>

On 3/7/18, 9:34 AM, "Bossart, Nathan" <bossartn@amazon.com> wrote:
> On 3/6/18, 11:04 PM, "Michael Paquier" <michael@paquier.xyz> wrote:
>> +       if (!(options & VACOPT_SKIP_LOCKED))
>> +           relid = RangeVarGetRelid(vrel->relation, AccessShareLock,
>> false);
>> +       else
>> +       {
>> +           relid = RangeVarGetRelid(vrel->relation, NoLock, false);
>> Yeah, I agree with Andres that getting all this logic done in
>> RangeVarGetRelidExtended would be cleaner.  Let's see where the other
>> thread leads us to:
>> https://www.postgresql.org/message-id/20180306005349.b65whmvj7z6hbe2y%40alap3.anarazel.de
>
> I had missed that thread.  Thanks for pointing it out.

I've noticed one more problem with ACCESS EXCLUSIVE.  If an ACCESS
EXCLUSIVE lock is held on a child relation of a partitioned table,
an ANALYZE on the partitioned table will be blocked at
acquire_inherited_sample_rows().

static int
acquire_inherited_sample_rows(Relation onerel, int elevel,
							  HeapTuple *rows, int targrows,
							  double *totalrows, double *totaldeadrows)
{
...
	/*
	 * Find all members of inheritance set.  We only need AccessShareLock on
	 * the children.
	 */
	tableOIDs =
		find_all_inheritors(RelationGetRelid(onerel), AccessShareLock, NULL);

It also seems possible for the call to vac_open_indexes() in
do_analyze_rel() to block.

	/*
	 * Open all indexes of the relation, and see if there are any analyzable
	 * columns in the indexes.  We do not analyze index columns if there was
	 * an explicit column list in the ANALYZE command, however.  If we are
	 * doing a recursive scan, we don't want to touch the parent's indexes at
	 * all.
	 */
	if (!inh)
		vac_open_indexes(onerel, AccessShareLock, &nindexes, &Irel);
	else
	{
		Irel = NULL;
		nindexes = 0;
	}

I think the most straightforward approach for fixing this is to add
skip-locked functionality in find_all_inheritors(),
find_inheritance_children(), and vac_open_indexes(), but I am curious
what others think.

Nathan



view thread (42+ messages)  latest in thread

Message-ID: <4D1115BF-ED38-44E2-B799-C7F9E421A3B8@amazon.com>
Permalink:  ../4D1115BF-ED38-44E2-B799-C7F9E421A3B8@amazon.com/
Also on:    postgresql.org/message-id/4D1115BF-ED38-44E2-B799-C7F9E421A3B8@amazon.com

 · 

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-bugs@postgresql.org
  Cc: bossartn@amazon.com, michael@paquier.xyz, andres@anarazel.de, sawada.mshk@gmail.com, robertmhaas@gmail.com, lyes.amd@gmail.com, tomas.vondra@2ndquadrant.com, pgsql-hackers@postgresql.org
  Subject: Re: BUG #14941: Vacuum crashes
  In-Reply-To: <4D1115BF-ED38-44E2-B799-C7F9E421A3B8@amazon.com>
  References: <32F4B778-292B-41AF-891A-497B8127CD59@amazon.com> <CAD21AoCsbqVh5P=ZA479DHrXmtUY2TxPxotE0jPiwM2+gQUjxw@mail.gmail.com> <5B80D67E-A664-495A-A0BE-CEA847676164@amazon.com> <20180109042720.GG76418@paquier.xyz> <4B232BD7-A97D-4461-81E6-28A49764B60E@amazon.com> <20180110025331.GE336@paquier.xyz> <CBEE19BB-6C70-424C-95E5-F8ABC7AA2185@amazon.com> <20180110231442.GA22983@paquier.xyz> <20180304001252.5sxn3glccnu5qxjm@alap3.anarazel.de> <7327B413-1A57-477F-A6A0-6FD80CB5482D@amazon.com> <20180307050345.GA3095@paquier.xyz> <3834EFB8-2A90-41C7-A7C8-8B956150479D@amazon.com> <4D1115BF-ED38-44E2-B799-C7F9E421A3B8@amazon.com>

* 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