Skip site navigation (1) Skip section navigation (2)

Re: [HACKERS] Per-table freeze limit proposal

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Simon Riggs <simon(at)2ndquadrant(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: [HACKERS] Per-table freeze limit proposal
Date: 2005-11-16 00:58:44
Message-ID: 20051116005844.GA9402@surnet.cl (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-patches
Simon Riggs wrote:
> On Mon, 2005-11-14 at 23:40 -0300, Alvaro Herrera wrote:
> 
> > The whole thing is pretty fragile is somebody manually updates a
> > catalog.  But we tell people not to do that, so it should be their
> > fault, right?
> 
> Hmmmm...sounds scary. Cool ideas in the patch though.

Yeah, well, actually the problem is solved very easily by setting the
pg_database tuple manually, either to InvalidTransactionId or to the
minimum computed from pg_class.

> > The problem comes when this is done to template1, and it is copied to
> > another database after some millions of transactions have come and go --
> > it will seem like the database has suffered wraparound.  We would need
> > to vacuum it completely after copied for the stats to be accurate.
> 
> I don't understand the issue, can you explain more? I see no problem. If
> an identical copy gives a problem then surely template1 should also.

Actually, template1 has the problem too.  The scenario is this:

- template1 is freezed.  datminxid <- X
- a long time passes, say INT_MAX * 0.75 transactions
- a new database D is created, which coming from template1 has datminxid=X
- the Xid counter is past the vacuum horizon for D.datminxid, so the
  system determines that the Xid counter could be wrapped already.
- The system automatically decides to stop accepting new transactions.

In fact there's no problem because in D, just like in template1, all
tuples are frozen.  How should we mark this on the catalogs?  I don't
see any way.

Note that setting relminxid = FrozenTransactionId is bogus in any case,
because even if we correctly lock and freeze the table, the next
transaction after the vacuum could insert a new tuple into the table.
But we don't want INSERT to be checking pg_class.relminxid!  (Or do we?)


Now, restating the problem, certainly template1 has the problem too.  In
fact we have a bigger problem: we are forcing all tables to be vacuumed
every so often, even if they have been completely frozen before!  This
is because setting relminxid = Frozen is really bogus.

> > I'm not sure what to do about that.  I think storing FrozenXid may not
> > actually be a totally bad idea.  Comments?
> 
> Its not a totally bad idea, but it has some risk, which where
> transactions are concerned is not really acceptable.
> 
> Perhaps we should reinstate VACUUM FULL FREEZE to do just a FREEZE with
> a table lock and skip all that moving data around.

Doesn't work either because of the argument above.

What about assuming that if somebody executes a database-wide FREEZE, he
knows what he is doing and thus we can mark datminxid as
FrozenTransactionId?

Sadly, I see all this as proof that the whole idea doesn't work.  It
seems better than the current state of the system, where we rely on the
user to do certain things, or on pgstat which is inherently inexact.
But there is a big hole in the whole reasoning which hasn't been filled
yet.

Any ideas welcome.  The idea of any insert/delete/update operation
checking a bit in the Relation and resetting relminxid to
TopTransactionId if it's marked Frozen is the only one I have right now.
What do people think about it?

-- 
Alvaro Herrera                                http://www.PlanetPostgreSQL.org
"No hay cielo posible sin hundir nuestras raĆ­ces
 en la profundidad de la tierra"                        (Malucha Pinto)

In response to

Responses

pgsql-hackers by date

Next:From: Tatsuo IshiiDate: 2005-11-16 01:08:15
Subject: Bug or feature?
Previous:From: Michael GlaesemannDate: 2005-11-16 00:56:13
Subject: Re: Long-time 7.4 contrib failure Mac OS X 10.3.8

pgsql-patches by date

Next:From: Qingqing ZhouDate: 2005-11-16 00:59:38
Subject: Re: Add missing const qualifier in ECPG
Previous:From: Philip YarraDate: 2005-11-15 22:59:04
Subject: pl/pgSQL doco patch

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group