pgsql: Improve representation of 'moved partitions' indicator on delete

From: Andres Freund <andres(at)anarazel(dot)de>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Improve representation of 'moved partitions' indicator on delete
Date: 2018-05-01 20:33:07
Message-ID: E1fDbxT-00050z-UR@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Improve representation of 'moved partitions' indicator on deleted tuples.

Previously a tuple that has been moved to a different partition (see
f16241bef7c), set the block number on the old tuple to an invalid
value to indicate that fact. But the tuple offset was left
untouched. That turned out to trigger a wal_consistency_checking
failure as reported by Peter Geoghegan, as the offset wasn't
always overwritten during WAL replay.

Heikki observed that we're wasting valuable data by not putting
information also in the offset. Thus set that to
MovedPartitionsOffsetNumber when a tuple indicates it has moved.

We continue to set the block number to MovedPartitionsBlockNumber, as
that seems more likely to cause problems for code not updated to know
about moved tuples.

As t_ctid's offset number is now always set, this refinement also
fixes the wal_consistency_checking issue.

This technically is a minor disk format break, with previously created
moved tuples not being recognized anymore. But since there not even
has been a beta release since f16241bef7c...

Reported-By: Peter Geoghegan
Author: Heikki Linnakangas, Amul Sul
Discussion: https://postgr.es/m/CAH2-Wzm9ty+1BX7-GMNJ=xPRg67oJTVeDNdA9LSyJJtMgRiCMA@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/1667148a4dd98cea28b8b53d57dbc1eece1b0b5c

Modified Files
--------------
src/include/access/htup_details.h | 29 ++++++++++++-----------------
src/include/storage/itemptr.h | 29 +++++++++++++++++++++++++++--
2 files changed, 39 insertions(+), 19 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2018-05-01 23:35:18 pgsql: Clean up warnings from -Wimplicit-fallthrough.
Previous Message Tom Lane 2018-05-01 20:13:29 Re: pgsql: Prevent infinity and NaN in jsonb/plperl transform