]> granicus.if.org Git - postgresql/commit
Repair pg_upgrade's failure to preserve relfrozenxid for matviews.
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 21 Feb 2018 23:40:24 +0000 (18:40 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 21 Feb 2018 23:40:24 +0000 (18:40 -0500)
commit38b41f182a66b67e36e2adf53d078599b1b65483
tree7e2f93f4247f17bd1f98a02db653ad1577562094
parent29d432e477a99f4c1e18820c5fc820a6b178c695
Repair pg_upgrade's failure to preserve relfrozenxid for matviews.

This oversight led to data corruption in matviews, manifesting as
"could not access status of transaction" before our most recent releases,
and "found xmin from before relfrozenxid" errors since then.

The proximate cause of the problem seems to have been confusion between
the task of preserving dropped-column status and the task of preserving
frozenxid status.  Those are required for distinct sets of relkinds,
and the reasoning was entirely undocumented in the source code.  In hopes
of forestalling future errors of the same kind, try to improve the
commentary in this area.

In passing, also improve the remarkably unhelpful comments around
pg_upgrade's set_frozenxids().  That's not actually buggy AFAICS,
but good luck figuring out what it does from the old comments.

Per report from Claudio Freire.  It appears that bug #14852 from Alexey
Ermakov is an earlier report of the same issue, and there may be other
cases that we failed to identify at the time.

Patch by me based on analysis by Andres Freund.  The bug dates back
to the introduction of matviews, so back-patch to all supported branches.

Discussion: https://postgr.es/m/CAGTBQpbrY9CdRGGhyBZ9yqY4jWaGC85rUF4X+R7d-aim=mBNsw@mail.gmail.com
Discussion: https://postgr.es/m/20171013115320.28049.86457@wrigleys.postgresql.org
src/bin/pg_dump/pg_dump.c
src/bin/pg_upgrade/pg_upgrade.c