From: Petr Jelinek <petr.jelinek@2ndquadrant.com>
To: scott@deltaex.com, pgsql-bugs@postgresql.org, Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Subject: Re: BUG #14769: Logical replication error "cache lookup failed for type 0"
Date: Fri, 4 Aug 2017 11:41:12 +0200
Message-ID: <66cde4f0-7b4c-30a5-e4b6-acebda59b00f@2ndquadrant.com> (raw)
In-Reply-To: <20170802235927.8423.44538@wrigleys.postgresql.org>
References: <20170802235927.8423.44538@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
On 03/08/17 01:59, scott@deltaex.com wrote:
> The following bug has been logged on the website:
>
> Bug reference: 14769
> Logged by: Scott Milliken
> Email address: scott@deltaex.com
> PostgreSQL version: 10beta2
> Operating system: Linux 4.10.0-27-generic #30~16.04.2-Ubuntu
> Description:
>
> I'm testing postgresql 10beta2, and found a bug with logical replication.
> The bug halts logical replication, and produces the error "cache lookup
> failed for type 0" in the secondary's log.
>
> The error can be reproduced by dropping a column in a replicated table. When
> a column is dropped, it zeroes out attypeid in pg_attribute:
>
> ```
> test=# select * from pg_attribute where attrelid =
> 'public.testtbl'::regclass and atttypid = 0 order by attnum;
> -[ RECORD 1 ]-+-----------------------------
> attrelid | 16386
> attname | ........pg.dropped.2........
> atttypid | 0
> attstattarget | 0
> attlen | -1
> attnum | 2
> attndims | 0
> attcacheoff | -1
> atttypmod | -1
> attbyval | f
> attstorage | x
> attalign | i
> attnotnull | f
> atthasdef | f
> attidentity |
> attisdropped | t
> attislocal | t
> attinhcount | 0
> attcollation | 100
> attacl | ¤
> attoptions | ¤
> attfdwoptions | ¤
> ```
>
> Perhaps there's a missing check against pg_attribute.attisdropped
> somewhere?
>
Good catch! Looks like we didn't initialize the attribute map for
locally dropped columns. Once I did that I found there is also typo in
slot_modify_cstrings() which uses wrong value from the remote side, that
is also made visible by your example.
Both are fixed in attached patch.
--
Petr Jelinek http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
Attachments:
0001-Fix-handling-of-dropped-columns-in-logical-replicati.patch (text/x-patch, 0B) download
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: petr.jelinek@2ndquadrant.com, peter.eisentraut@2ndquadrant.com
Subject: Re: BUG #14769: Logical replication error "cache lookup failed for type 0"
In-Reply-To: <66cde4f0-7b4c-30a5-e4b6-acebda59b00f@2ndquadrant.com>
References: <20170802235927.8423.44538@wrigleys.postgresql.org> <66cde4f0-7b4c-30a5-e4b6-acebda59b00f@2ndquadrant.com>
* 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