Re: [WIP] Add relminxid column to pg_class - Mailing list pgsql-patches

From Alvaro Herrera
Subject Re: [WIP] Add relminxid column to pg_class
Date
Msg-id 20060410003603.GF16673@surnet.cl
Whole thread Raw
In response to Re: [WIP] Add relminxid column to pg_class  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: [WIP] Add relminxid column to pg_class
List pgsql-patches
Tom Lane wrote:

> Here's a sketch of the idea as it's developing in my mind:
>
> 1. We consider that relminxid = FrozenXid means that the table is
> frozen, ie is guaranteed to contain no valid XIDs except FrozenXid.
> Otherwise, relminxid must be a lower bound on the non-frozen XIDs in
> the table.
>
> 2. VACUUM FREEZE acquires ExclusiveLock, vacuums the table replacing
> all XIDs with FrozenXid, and if successful sets relminxid = FrozenXid.
> (It might not be successful, eg it might see recently-dead tuples it
> can't remove; we can't replace their xmin/xmax obviously.)  In all other
> cases, VACUUM sets relminxid = Min(oldest unfrozen xid in table,
> transaction xmin) (or some other convenient lower-bound computation,
> eg maybe just use the cutoff instead of actively figuring the min XID).
> I think we have to XLOG the setting of relminxid to be safe.
>
> 3. Any modification of a table (that inserts an XID into it) must check
> to see if relminxid = FrozenXid, and if so change it to transaction xmin
> (or some other lower bound on the oldest running XID).  This action has
> to be WAL-logged.
>
> 4. VACUUM has to recompute datminxid to be the oldest non-frozen
> relminxid in the database (but not more than transaction xmin, to cover
> case where someone else is creating a table concurrently).  We might be
> able to go back to your idea of not having to do this work unless the
> prior value of relminxid matches datminxid.  I think plain VACUUM could
> skip tables having relminxid = FrozenXid altogether.
>
> I'm tempted to say that the "unfreezing" action (#3) could just be done
> at the point where we open a rel and take a stronger-than-AccessShare
> lock on it.  This would minimize the overhead needed, and give us pretty
> good confidence we'd not missed any places.  It'd mean that, say, an
> UPDATE that changed no rows would still mark the table unfrozen, but I
> see no great downside to that.

Seems fine.  I'll devote some time to this.

--
Alvaro Herrera                                http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

pgsql-patches by date:

Previous
From: Tom Lane
Date:
Subject: Re: [WIP] Add relminxid column to pg_class
Next
From: Tom Lane
Date:
Subject: Re: [WIP] Add relminxid column to pg_class