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

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Fix CLUSTER/VACUUM FULL for toast values owned by recently-updat
Дата
Msg-id E1RlSO4-0006uJ-GG@gemulon.postgresql.org
обсуждение исходный текст
Список 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
patch.

Branch
------
REL9_1_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/b994c57a8032f55f816768ee55a677e03190abae

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 по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: pgsql: Fix CLUSTER/VACUUM FULL for toast values owned by recently-updat
Следующее
От: Simon Riggs
Дата:
Сообщение: pgsql: Minor but necessary improvements to WAL keepalives