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

pgsql: Fix CLUSTER/VACUUM FULL for toast values owned byrecently-updat

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix CLUSTER/VACUUM FULL for toast values owned byrecently-updat
Date: 2012-01-12 21:40:44
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-committers
Fix CLUSTER/VACUUM FULL for toast values owned by recently-updated rows.

In commit 7b0d0e9356963d5c3e4d329a917f5fbb82a2ef05, I made CLUSTER and
VACUUM FULL try to preserve toast value OIDs from the original toast table
to the new one.  However, if we have to copy both live and recently-dead
versions of a row that has a toasted column, those versions may well
reference the same toast value with the same OID.  The patch then led to
duplicate-key failures as we tried to insert the toast value twice with the
same OID.  (The previous behavior was not very desirable either, since it
would have silently inserted the same value twice with different OIDs.
That wastes space, but what's worse is that the toast values inserted for
already-dead heap rows would not be reclaimed by subsequent ordinary
VACUUMs, since they go into the new toast table marked live not deleted.)

To fix, check if the copied OID already exists in the new toast table, and
if so, assume that it stores the desired value.  This is reasonably safe
since the only case where we will copy an OID from a previous toast pointer
is when toast_insert_or_update was given that toast pointer and so we just
pulled the data from the old table; if we got two different values that way
then we have big problems anyway.  We do have to assume that no other
backend is inserting items into the new toast table concurrently, but
that's surely safe for CLUSTER and VACUUM FULL.

Per bug #6393 from Maxim Boguk.  Back-patch to 9.0, same as the previous



Modified Files
src/backend/access/heap/tuptoaster.c |   67 +++++++++++++++++++++++++++-------
src/backend/commands/cluster.c       |   11 ++++--
src/include/utils/rel.h              |    3 +-
3 files changed, 62 insertions(+), 19 deletions(-)

pgsql-committers by date

Next:From: Alex HunsakerDate: 2012-01-13 02:28:22
Subject: Re: [COMMITTERS] pgsql: Fix breakage from earlier plperl fix.
Previous:From: Simon RiggsDate: 2012-01-12 19:19:54
Subject: Re: Re: [COMMITTERS] pgsql: Send new protocol keepalive messages to standby servers.

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