pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andres Freund <andres@anarazel.de>
Cc: pgsql-hackers@postgresql.org
Subject: Re: [COMMITTERS] pgsql: Fix inadequate locking during get_rel_oids().
Date: Mon, 05 Mar 2018 19:49:06 -0500
Message-ID: <30084.1520297346@sss.pgh.pa.us> (raw)
In-Reply-To: <20180306001152.qxguen2kclystz7p@alap3.anarazel.de>
References: <E1dy1ru-0002RK-8q@gemulon.postgresql.org>
	<20180306001152.qxguen2kclystz7p@alap3.anarazel.de>

Andres Freund <andres@anarazel.de> writes:
> On 2017-09-29 20:26:42 +0000, Tom Lane wrote:
>> get_rel_oids used to not take any relation locks at all, but that stopped
>> being a good idea with commit 3c3bb9933, which inserted a syscache lookup
>> into the function.  A concurrent DROP TABLE could now produce "cache lookup
>> failed", which we don't want to have happen in normal operation.  The best
>> solution seems to be to transiently take a lock on the relation named by
>> the RangeVar (which also makes the result of RangeVarGetRelid a lot less
>> spongy).  But we shouldn't hold the lock beyond this function, because we
>> don't want VACUUM to lock more than one table at a time.  (That would not
>> be a big problem right now, but it will become one after the pending
>> feature patch to allow multiple tables to be named in VACUUM.)

> I'm not sure how big a problem this is, but I suspect it is
> one. Autovacuum used to skip relations when they're locked, and the
> vacuum isn't an anti-wraparound one.  But after this change it appears
> we'll get stuck behind this new lock, even if VACOPT_NOWAIT is
> specified.  That's bad because now relations that are AEL locked
> (e.g. because of some longrunning DDL) can block global autovacuum
> progress.

Hm.  Maybe we should take this lock with nowait if the vacuum option
is specified?

Another idea is to revert both this patch and 3c3bb9933, and instead
handle partitioning more like we handle recursion for toast tables, ie
make no decisions until after we do have lock on a relation.  The
really fundamental problem here is that 3c3bb9933 thought it is OK
to do a syscache lookup on a table we have no lock on, which is flat
wrong.  But we don't necessarily have to do it exactly like that.

			regards, tom lane




view thread (8+ messages)  latest in thread

Message-ID: <30084.1520297346@sss.pgh.pa.us>
Permalink:  ../30084.1520297346@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/30084.1520297346@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-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, andres@anarazel.de, pgsql-hackers@postgresql.org
  Subject: Re: [COMMITTERS] pgsql: Fix inadequate locking during get_rel_oids().
  In-Reply-To: <30084.1520297346@sss.pgh.pa.us>
  References: <E1dy1ru-0002RK-8q@gemulon.postgresql.org> <20180306001152.qxguen2kclystz7p@alap3.anarazel.de> <30084.1520297346@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