Re: BUG #14941: Vacuum crashes

From: "Bossart, Nathan" <bossartn(at)amazon(dot)com>
To: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
Cc: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Lyes Ameddah <lyes(dot)amd(at)gmail(dot)com>, Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>, "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #14941: Vacuum crashes
Date: 2018-01-09 21:40:50
Message-ID: 4B232BD7-A97D-4461-81E6-28A49764B60E@amazon.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

On 1/8/18, 10:28 PM, "Michael Paquier" <michael(dot)paquier(at)gmail(dot)com> wrote:
> Based on the opinions gathered on this thread, 0001 and 0002 seem to be
> in the shape wanted, and those look good for shipping. Now for 0003 we
> are not there yet.

Thanks for taking a look.

> - if (relation == NULL)
> + if (relation != NULL)
> + relname = relation->relname;
> + else if (!rel_lock)
> + relname = get_rel_name(relid);
> +
> + if (relname == NULL)
> I think that you are doing it wrong here. In get_all_vacuum_rels() you
> should build a RangeVar to be reused in the context of this error
> message, and hence you'll save an extra lookup based on the relation
> OID here, saving from any timing issues that you have overseen as in
> this code path a lock on the relation whose name is looked at is not
> taken. Relying on the RangeVar being NULL to not generate any logs is
> fine as a concept to me, but let's fill it where it is needed, and in
> the case of this patch a VACUUM NOWAIT on the whole database is such a
> case.

I understand what you are saying here. I think there are two competing
logging behaviors:

1. If a relation is concurrently dropped, we should skip logging if
the relation was not specified in the original VACUUM/ANALYZE
command [0]
2. If a relation is skipped because the lock is not available, we
should never skip logging

Since we rely on the RangeVar being NULL to determine whether or not
we should log for case 1, filling in the RangeVar during
get_all_vacuum_rels() would add complexity. Any time VACOPT_NOWAIT is
specified, we must construct a RangeVar for all relations. Also, we
must find a new way to track whether or not the relation was specified
in the original command in order to maintain the behavior of case 1.

IMO it is simpler to call get_rel_name() to discover the relation name
in this specific case (NOWAIT is specified, lock is not available, and
the relation was not specified in the original command). I detailed
some potential edge cases of this approach earlier [1]. Even if I am
missing some, I think the worst case is that get_rel_name() returns
NULL and the logging is skipped.

What do you think? I will take a deeper look into how your suggested
approach might be achieved.

Nathan

[0] https://postgr.es/m/28748.1507071576%40sss.pgh.pa.us
[1] https://postgr.es/m/32F4B778-292B-41AF-891A-497B8127CD59%40amazon.com

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Bossart, Nathan 2018-01-09 21:42:26 Re: BUG #14941: Vacuum crashes
Previous Message Devrim Gündüz 2018-01-09 18:42:25 Re: missing repodata for https://download.postgresql.org/pub/repos/yum/9.6/fedora/fedora-26-x86_64

Browse pgsql-hackers by date

  From Date Subject
Next Message Bossart, Nathan 2018-01-09 21:42:26 Re: BUG #14941: Vacuum crashes
Previous Message Robert Haas 2018-01-09 21:00:39 Re: [HACKERS] UPDATE of partition key