pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andres Freund <andres@2ndquadrant.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Michael Paquier <michael.paquier@gmail.com>
Cc: cg@osss.net
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #11638: Transaction safety fails when constraints are dropped and analyze is done
Date: Wed, 29 Oct 2014 00:52:56 +0100
Message-ID: <20141028235256.GJ5873@awork2.anarazel.de> (raw)
In-Reply-To: <20972.1414538885@sss.pgh.pa.us>
References: <20141010181433.25463.5856@wrigleys.postgresql.org>
	<20141010191401.GA18020@awork2.anarazel.de>
	<CAB7nPqRsXPPNaFXDHZPbBESYR_EJPvQP6eKmhp-p13mJDpGgXw@mail.gmail.com>
	<20141015051254.GC7242@alap3.anarazel.de>
	<CAB7nPqTsZUnDNYgLZ8OO5T4rQY+=XSe7uomiv=OVQnJvVzzHJg@mail.gmail.com>
	<20141015061815.GF7242@alap3.anarazel.de>
	<CAB7nPqR5mpKM6HWh1jE9crWa-8mjri_J9exD3AyYuEEnW0cTQg@mail.gmail.com>
	<20648.1413943949@sss.pgh.pa.us>
	<20972.1414538885@sss.pgh.pa.us>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

On 2014-10-28 19:28:05 -0400, Tom Lane wrote:
> I wrote:
> > I think that a better answer is to continue to do this update
> > nontransactionally, but to not let the code clear relhasindex etc
> > if we're inside a transaction block.  It is certainly safe to put
> > off clearing those flags if we're not sure that we're seeing a
> > committed state of the table's schema.
> 
> Attached is a proposed patch to do it that way.  I borrowed Michael's
> test case.

I still think it'd be better to use a transactional update. But I also
*do* agree that this is the safer way forward for now. So +1 from me.

> +  *		In addition to fundamentally nontransactional statistics such as
> +  *		relpages and relallvisible, we try to maintain certain lazily-updated
> +  *		DDL flags such as relhasindex, by clearing them if no longer correct.
> +  *		It's safe to do this in VACUUM, which can't run in parallel with
> +  *		CREATE INDEX/RULE/TRIGGER and can't be part of a transaction block.

> +  *		However, it's *not* safe to do it in an ANALYZE that's within a
> +  *		transaction block, because the current transaction might've dropped
> +  *		the last index; we'd think relhasindex should be cleared, but if the
> +  *		transaction later rolls back this would be wrong.  So we refrain from
> +  *		updating the DDL flags if we're inside a transaction block.  This is
> +  *		OK since postponing the flag maintenance is always allowable.
> +  *

Absolutely minor nitpick: It nearly sounds like this is only a concern
for relhasindex - but it's just as much a problem for other relhas*
stuff. Not sure if it's worth complicating the text for that. Maybe a
'e.g.'.

Greetings,

Andres Freund


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (19+ messages)  latest in thread

Message-ID: <20141028235256.GJ5873@awork2.anarazel.de>
Permalink:  ../20141028235256.GJ5873@awork2.anarazel.de/
Also on:    postgresql.org/message-id/20141028235256.GJ5873@awork2.anarazel.de

 · 

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: andres@2ndquadrant.com, tgl@sss.pgh.pa.us, michael.paquier@gmail.com, cg@osss.net
  Subject: Re: BUG #11638: Transaction safety fails when constraints are dropped and analyze is done
  In-Reply-To: <20141028235256.GJ5873@awork2.anarazel.de>
  References: <20141010181433.25463.5856@wrigleys.postgresql.org> <20141010191401.GA18020@awork2.anarazel.de> <CAB7nPqRsXPPNaFXDHZPbBESYR_EJPvQP6eKmhp-p13mJDpGgXw@mail.gmail.com> <20141015051254.GC7242@alap3.anarazel.de> <CAB7nPqTsZUnDNYgLZ8OO5T4rQY+=XSe7uomiv=OVQnJvVzzHJg@mail.gmail.com> <20141015061815.GF7242@alap3.anarazel.de> <CAB7nPqR5mpKM6HWh1jE9crWa-8mjri_J9exD3AyYuEEnW0cTQg@mail.gmail.com> <20648.1413943949@sss.pgh.pa.us> <20972.1414538885@sss.pgh.pa.us> <20141028235256.GJ5873@awork2.anarazel.de>

* 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