pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andres Freund <andres@2ndquadrant.com>
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 10:35:24 -0400
Message-ID: <10043.1413988524@sss.pgh.pa.us> (raw)
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>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

Andres Freund <andres@2ndquadrant.com> writes:
> 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.

> I'm unconvinced that that's a problem.

[ shrug... ]  The fact that you haven't thought of a problem doesn't mean
there is not one.  We hadn't thought of the current problem either.

> What's the problem you're suspecting?

If I could put my finger on something, I'd have pointed it out rather
than just handwaving :-(.  But the (theorized) sequence of decisions
that got us into this mess should convince you that switching between
transactional and nontransactional updates is not something to be
done lightly.

> 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.

Well, the pg_statistic updates *are* transactional.  What we're discussing
here is the reltuples/relpages fields, and it's worth thinking twice
before claiming that you want to roll such an update back.  If the
transaction rolls back that's not going to make physically added pages go
away, so its relpages value is unconditionally better than the old one.
In the simplest case of a transaction that's UPDATEd all/most rows of the
table, it'd be best to keep the reltuples/relpages updates because that
will correctly reflect the fact that the live tuple density is about half
what it used to be.  (A rollback would mean that a different half of the
tuples are live, but the ratio is still correct.)  If the transaction was
mostly deletes or mostly inserts, then its reltuples number will be
inaccurate if the transaction rolls back ... but the old relpages number
will be inaccurate too, so it's pretty hard to argue that one state is
better than the other.  Given the complete lack of user complaints in
this area, I'm disinclined to change the behavior more than we have to.

			regards, tom lane


-- 
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: <10043.1413988524@sss.pgh.pa.us>
Permalink:  ../10043.1413988524@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/10043.1413988524@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-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, andres@2ndquadrant.com, 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: <10043.1413988524@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> <20141022132144.GE5790@alap3.anarazel.de> <10043.1413988524@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