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

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Fix pg_upgrade to not fail when new-cluster TOAST rules differ f
Дата
Msg-id E1ayrdA-0008HV-Jg@gemulon.postgresql.org
обсуждение исходный текст
Список 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_3_STABLE

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

Modified Files
--------------
contrib/pg_upgrade/dump.c       | 72 -----------------------------------------
contrib/pg_upgrade/pg_upgrade.c |  4 +--
contrib/pg_upgrade/pg_upgrade.h |  1 -
src/backend/catalog/toasting.c  | 58 ++++++++++++---------------------
4 files changed, 22 insertions(+), 113 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Kevin Grittner
Дата:
Сообщение: Re: [HACKERS] Re: pgsql: Avoid extra locks in GetSnapshotData if old_snapshot_threshold <
Следующее
От: Tom Lane
Дата:
Сообщение: pgsql: Fix pg_upgrade to not fail when new-cluster TOAST rules differ f