Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ddZ6f-0000Ko-KE for pgsql-bugs@arkaria.postgresql.org; Fri, 04 Aug 2017 09:41:21 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1ddZ6e-0008FV-Su for pgsql-bugs@arkaria.postgresql.org; Fri, 04 Aug 2017 09:41:20 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ddZ6e-0008FK-7y for pgsql-bugs@postgresql.org; Fri, 04 Aug 2017 09:41:20 +0000 Received: from mail-wm0-x22c.google.com ([2a00:1450:400c:c09::22c]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1ddZ6a-0001b0-Pr for pgsql-bugs@postgresql.org; Fri, 04 Aug 2017 09:41:18 +0000 Received: by mail-wm0-x22c.google.com with SMTP id m85so15176793wma.0 for ; Fri, 04 Aug 2017 02:41:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language; bh=xGsunH+GAAmwps77lgMr6P5bOibazSnZ8UvcIpOXRtQ=; b=PZv/tQ5AErAGOLk64/UVZcDbnfvwJtTXVEVhwTXTQVRcoEiHIeDg2keVT7ht3WsFVB STdkoVr86xYWysLsHKisW6vq9mv3JG+WgaUiCGRwcgACMi1EACOSYZZm/gb+eIg+vp6x qEZ1ven7HXmqxbo33fdKfP9hSITf1/LOYBFmzLSJlvsBBAt+HWe+0Rwa2wHZvdm5WX7f FoEQF488f31nVJFWM2oHPlBIqwvA7TvWcDI508gDsX0vHOk82YPBq/NU1FF2RiD6EixA r5z0KEHRWp8c2byG+vtJLZmpGe8/FNRSko/KX+9FDbMCydBDiesY2L9l0QVv0X32UFNf DwIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=xGsunH+GAAmwps77lgMr6P5bOibazSnZ8UvcIpOXRtQ=; b=C8Pds/91VmYsE7L8NGbTpGnWpP4RYEoAKhKU8pXLmjKR00C3wbUuCiI9L/LbsqmyX/ jjHkurDeiCZvhFRQHxF9h68cbiNtEpyH3/2W0ikJ1ht4oa2wGxkH5polRuTUhEcrgK4D 12VFfzhKh4F0yvbOGepJR7MvQpxlOza9YgPNOrjPLswD2FboytvAWJaxVh0rYr0GDHPE ELrhy+eDSLe87w8bmse2eGdgfGLqh8x2uicq4UksDUdVQBchLnGnl6GgKXQ6uyCkh/Hv /EYSRkjFk9iGKxHE0JAUreInau7chNOeKHpIFZ6G067s4dmYLJqPGjRh7TMAqreX807i rHgg== X-Gm-Message-State: AIVw1101yZAI9tycPR06eLtFmA2sUoR6Z3YRC6N83W4LSaQBT3UNTwvk ZNulpM3it5tjaQuKgAJLWg== X-Received: by 10.80.129.227 with SMTP id 90mr1967171ede.256.1501839674380; Fri, 04 Aug 2017 02:41:14 -0700 (PDT) Received: from [192.168.50.87] (port-87-193-132-138.static.qsc.de. [87.193.132.138]) by smtp.gmail.com with ESMTPSA id f5sm2011531edj.78.2017.08.04.02.41.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 Aug 2017 02:41:13 -0700 (PDT) Subject: Re: BUG #14769: Logical replication error "cache lookup failed for type 0" To: scott@deltaex.com, pgsql-bugs@postgresql.org, Peter Eisentraut References: <20170802235927.8423.44538@wrigleys.postgresql.org> From: Petr Jelinek Message-ID: <66cde4f0-7b4c-30a5-e4b6-acebda59b00f@2ndquadrant.com> Date: Fri, 4 Aug 2017 11:41:12 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20170802235927.8423.44538@wrigleys.postgresql.org> Content-Type: multipart/mixed; boundary="------------D45B0085D08E2D8DB6D86242" Content-Language: en-US List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org This is a multi-part message in MIME format. --------------D45B0085D08E2D8DB6D86242 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit 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 --------------D45B0085D08E2D8DB6D86242 Content-Type: text/x-patch; name="0001-Fix-handling-of-dropped-columns-in-logical-replicati.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-Fix-handling-of-dropped-columns-in-logical-replicati.pa"; filename*1="tch"