Re: Inaccuracy in VACUUM's tuple count estimates

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Kevin Grittner <kgrittn(at)ymail(dot)com>
Cc: Andres Freund <andres(at)2ndquadrant(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Robert Haas <robertmhaas(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Inaccuracy in VACUUM's tuple count estimates
Date: 2014-06-09 18:55:54
Message-ID: 20140609185553.GA18688@eldon.alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Kevin Grittner wrote:
> Andres Freund <andres(at)2ndquadrant(dot)com> wrote:
> > On 2014-06-09 09:45:12 -0700, Kevin Grittner wrote:

> >>> old:
> >>> 1) xmin has committed, xmax is in progress, xmax is not just a locker
> >>> 2) xmin is in progress, xmax is set and not not just a locker
> >>>
> >>> Note that the 2) case here never checked xmax's status.
> >>
> >>  Again, I'm not sure how 2) could happen unless they involve the
> >>  same top-level transaction.  What am I missing?
> >
> > Right, both can only happen if the tuple is created & deleted in the
> > same backend. Is that in contradiction to something you see?
>
> Well, you're making a big point that the status of xmax was not
> checked in the old code.  If xmax is the same as xmin and xmin is
> in progress, the additional check seems redundant -- unless I'm
> missing something.

IIRC the case that prompted the fix was a CREATE INDEX in the same
transaction that created a tuple which was later deleted by an aborted
subtransaction. If the creating transaction is not this backend, that's
fine. But if the creating transaction IsCurrentTransactionId() then we
need to be careful about aborted subxacts: if a tuple was deleted by an
aborted subxact then it's still visible to this transaction. Xmax must
be checked in this case. Note that the difference is pretty specific to
CREATE INDEX. Vacuuming doesn't have to worry about such cases, mainly
because you can't run vacuum in a transaction.

--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Matheus de Oliveira 2014-06-09 18:58:17 Re: Re: Hot standby 9.2.6 -> 9.2.6 PANIC: WAL contains references to invalid pages
Previous Message Kevin Grittner 2014-06-09 18:44:13 Re: Inaccuracy in VACUUM's tuple count estimates