pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andres Freund <andres@anarazel.de>
Cc: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Cc: pgsql-hackers@postgresql.org
Subject: Re: Transactional sequence stuff breaks pg_upgrade
Date: Mon, 12 Jun 2017 18:31:04 -0400
Message-ID: <16932.1497306664@sss.pgh.pa.us> (raw)
In-Reply-To: <20170612221118.3nkmgbtjvv6eclut@alap3.anarazel.de>
References: <19785.1497215827@sss.pgh.pa.us>
	<9761.1497225808@sss.pgh.pa.us>
	<20170612210221.vz2u373tcwu3g624@alap3.anarazel.de>
	<23291.1497302014@sss.pgh.pa.us>
	<20170612212517.j3xe6am7hlztl6fw@alap3.anarazel.de>
	<11213.1497303337@sss.pgh.pa.us>
	<20170612221118.3nkmgbtjvv6eclut@alap3.anarazel.de>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

Andres Freund <andres@anarazel.de> writes:
> On 2017-06-12 17:35:37 -0400, Tom Lane wrote:
>> I thought about trying to insert an assert in GetNewOidWithIndex to
>> ensure that no type OIDs are selected automatically during upgrade,
>> but it seemed a bit too complicated.  Might be a good idea to figure
>> it out though, unless you have an idea for removing that requirement.

> I think the only type oids assigned during pg_upgrade are the oids for
> toast type types, right?

Perhaps that was a problem once, but it isn't now; see 
binary_upgrade_set_next_toast_pg_type_oid().

In fact, we get through the pg_upgrade regression test with the attached
patch, and I really think we ought to commit it.

Having said that, I wouldn't mind trying to reduce the catalog overhead
for toast tables in v11 or beyond.

> a) Do not create a corresponding composite type for toast tables. Not
>    super pretty, but I doubt it'd be a huge issue.

I suspect there are places that assume all tables have type OIDs.

> b) Use *one* composite type for all of the toast tables.  That'd not be
>    entirely trivial because of pg_type.typrelid.

That might work, with some klugery.  Peter might have some insight about
this --- I'm not sure whether the CREATE TABLE OF TYPE syntax shares
a type OID across all the tables.

			regards, tom lane

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Attachments:

check-upgrade-type-and-relfilenodes-all-assigned.patch (text/x-diff, 1.5K) download diff --git a/src/backend/catalog/catalog.c b/src/backend/catalog/catalog.c index 11ee536..92d943c 100644 *** a/src/backend/catalog/catalog.c --- b/src/backend/catalog/catalog.c *************** *** 38,43 **** --- 38,44 ---- #include "catalog/pg_shseclabel.h" #include "catalog/pg_subscription.h" #include "catalog/pg_tablespace.h" + #include "catalog/pg_type.h" #include "catalog/toasting.h" #include "miscadmin.h" #include "storage/fd.h" *************** GetNewOidWithIndex(Relation relation, Oi *** 340,345 **** --- 341,354 ---- ScanKeyData key; bool collides; + /* + * We should never be asked to generate a new pg_type OID during + * pg_upgrade; doing so would risk collisions with the OIDs it wants to + * assign. Hitting this assert means there's some path where we failed to + * ensure that a type OID is determined by commands in the dump script. + */ + Assert(!IsBinaryUpgrade || RelationGetRelid(relation) != TypeRelationId); + InitDirtySnapshot(SnapshotDirty); /* Generate new OIDs until we find one not in the table */ *************** GetNewRelFileNode(Oid reltablespace, Rel *** 391,396 **** --- 400,412 ---- bool collides; BackendId backend; + /* + * If we ever get here during pg_upgrade, there's something wrong; all + * relfilenode assignments during a binary-upgrade run should be + * determined by commands in the dump script. + */ + Assert(!IsBinaryUpgrade); + switch (relpersistence) { case RELPERSISTENCE_TEMP:

view thread (14+ messages)  latest in thread

Message-ID: <16932.1497306664@sss.pgh.pa.us>
Permalink:  ../16932.1497306664@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/16932.1497306664@sss.pgh.pa.us

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, andres@anarazel.de, peter.eisentraut@2ndquadrant.com
  Subject: Re: Transactional sequence stuff breaks pg_upgrade
  In-Reply-To: <16932.1497306664@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox