Re: pg_upgrade < 9.3 -> >=9.3 misses a step around multixacts

From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Bruce Momjian <bruce(at)momjian(dot)us>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, PostgreSQL Bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: pg_upgrade < 9.3 -> >=9.3 misses a step around multixacts
Date: 2014-07-21 16:34:09
Message-ID: 20140721163409.GB14989@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On 2014-07-21 12:20:56 -0400, Tom Lane wrote:
> Andres Freund <andres(at)2ndquadrant(dot)com> writes:
> > 2) From a pedantic POV lastSane* should be initialized to
> > ReadNewTransactionId()/ReadNextMultiXactId(). On a busy system we could
> > otherwise consider concurrently updated values as being too new if some
> > longrunning transaction finishes. Also GetOldestXmin() can sometimes go
> > backwards...
>
> If it's wrong then that's a pre-existing bug, but I don't think it's
> wrong.

I'm not wondering so much about vac_update_relstats(). There indeed the
calls aren't new and the worst that can happen is a slightly older
freeze limit. I'm more wondering about vac_update_datfrozenxid(). Afaics
we very well could hit
newFrozenXid = lastSaneFrozenXid = GetOldestXmin(NULL, true);
newMinMulti = lastSaneMinMulti = GetOldestMultiXactId();
...
/*
* If things are working properly, no relation should have a
* relfrozenxid or relminmxid that is "in the future". However, such
* cases have been known to arise due to bugs in pg_upgrade. If we
* see any entries that are "in the future", chicken out and don't do
* anything. This ensures we won't truncate clog before those
* relations have been scanned and cleaned up.
*/
if (TransactionIdPrecedes(lastSaneFrozenXid, classForm->relfrozenxid) ||
MultiXactIdPrecedes(lastSaneMinMulti, classForm->relminmxid))
{
bogus = true;
break;
}

for a relation that has just been vacuumed by another backend. In a
database with a high number of pg_class entries/much bloat it's not that
unrealistic that relfrozenxid/relminmxid have been updated since the
GetOldest* calls above. Since vac_update_relstats() writes them using
heap_inplace_update() the window for that isn't particularly small. That
could potentially lead to never updating the database freeze limits,
right?

Greetings,

Andres Freund

--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2014-07-21 16:43:24 Re: pg_upgrade < 9.3 -> >=9.3 misses a step around multixacts
Previous Message Tom Lane 2014-07-21 16:20:56 Re: pg_upgrade < 9.3 -> >=9.3 misses a step around multixacts