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, 22 Oct 2014 15:21:44 +0200
Message-ID: <20141022132144.GE5790@alap3.anarazel.de> (raw)
In-Reply-To: <20648.1413943949@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>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
On 2014-10-21 22:12:29 -0400, Tom Lane wrote:
> I don't much care for this patch. Aside from cosmetic issues like having
> named the new argument backwards and failed to update the function header
> comment that the patch largely invalidates, it seems to me to be likely
> to have unforeseen side effects, in that there may now be assumptions
> elsewhere that we don't force a pg_class update for this type of change.
> The implications are particularly ticklish for pg_class itself...
I'm unconvinced that that's a problem. We already do transactional
updates of pg_class for stuff like CREATE INDEX - while the relation is
*not* locked exclusively. And e.g. CLUSTER pg_class does transactional
updates of pg_class itself, without problems afaics. The latter is under
an exclusive lock admittedly.
What's the problem you're suspecting?
Even if it doesn't arrise to the level of data corruption, I suspect in
many cases updating the stats nontransactionally in an later aborted
transaction will surprise some users. The normal reason for doing a
ANALYZE in a transaction is that you changed the data dramatically.
> 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.
That'd fix the corruption, so it'd certainly be an improvement. But I'm
unconvinced that it's the best way forward.
> An interesting question is whether it is ever possible for this function
> to be told to *set* relhasindex when it was clear (or likewise for the
> other flags). Offhand I would say that that should never happen, because
> certainly neither VACUUM nor ANALYZE should be creating indexes etc.
> Should we make it throw an error if that happens, or just go ahead and
> apply the update, assuming that it's correcting somehow-corrupted data?
It probably should at least LOG/WARN, to make it clear that things were
in a bad shape. It might be helpful to allow VACUUM/ANALYZE to fix
existing corrupted relhas* flags. Although there could already be
existing corruption, in which case users might want to get alerted of
that more aggressively.
Greetings,
Andres Freund
--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
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: <20141022132144.GE5790@alap3.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> <20141022132144.GE5790@alap3.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