pgsql: Fix pg_upgrade to not fail when new-cluster TOAST rules differ f - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Fix pg_upgrade to not fail when new-cluster TOAST rules differ f
Date
Msg-id E1ayrdA-0008HU-Jd@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Fix pg_upgrade to not fail when new-cluster TOAST rules differ from old.

This patch essentially reverts commit 4c6780fd17aa43ed, in favor of a much
simpler solution for the case where the new cluster would choose to create
a TOAST table but the old cluster doesn't have one: just don't create a
TOAST table.

The existing code failed in at least two different ways if the situation
arose: (1) ALTER TABLE RESET didn't grab an exclusive lock, so that the
lock sanity check in create_toast_table failed; (2) pg_upgrade did not
provide a pg_type OID for the new toast table, so that the crosscheck in
TypeCreate failed.  While both these problems were introduced by later
patches, they show that the hack being used to cause TOAST table creation
is overwhelmingly fragile (and untested).  I also note that before the
TypeCreate crosscheck was added, the code would have resulted in assigning
an indeterminate pg_type OID to the toast table, possibly causing a later
OID conflict in that catalog; so that it didn't really work even when
committed.

If we simply don't create a TOAST table, there will only be a problem if
the code tries to store a tuple that's wider than a page, and field
compression isn't sufficient to get it under a page.  Given that the TOAST
creation threshold is intended to be about a quarter of a page, it's very
hard to believe that cross-version differences in the do-we-need-a-toast-
table heuristic could result in an observable problem.  So let's just
follow the old version's conclusion about whether a TOAST table is needed.

(If we ever do change needs_toast_table() so much that this conclusion
doesn't apply, we can devise a solution at that time, and hopefully do
it in a less klugy way than 4c6780fd17aa43ed did.)

Back-patch to 9.3, like the previous patch.

Discussion: <8110.1462291671@sss.pgh.pa.us>

Branch
------
REL9_4_STABLE

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

Modified Files
--------------
contrib/pg_upgrade/dump.c            | 69 ------------------------------------
contrib/pg_upgrade/pg_upgrade.c      |  4 +--
contrib/pg_upgrade/pg_upgrade.h      |  1 -
src/backend/catalog/toasting.c       | 54 +++++++++++-----------------
src/include/catalog/binary_upgrade.h |  5 ---
5 files changed, 22 insertions(+), 111 deletions(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Fix pg_upgrade to not fail when new-cluster TOAST rules differ f
Next
From: Tom Lane
Date:
Subject: pgsql: Clean up after pg_dump test runs.