Re: [WIP] Add relminxid column to pg_class

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: [WIP] Add relminxid column to pg_class
Date: 2006-04-10 00:36:03
Message-ID: 20060410003603.GF16673@surnet.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Joshua D. Drake 2006-04-10 01:07:58 Re: Suggestion: Which Binary?
Previous Message Tom Lane 2006-04-10 00:04:41 Re: [WIP] Add relminxid column to pg_class