pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Petr Jelinek <petr.jelinek@2ndquadrant.com>
To: Chad Trabant <chad@iris.washington.edu>
To: David G. Johnston <david.g.johnston@gmail.com>
To: pgsql-bugs@lists.postgresql.org
Cc: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Subject: Re: BUG #15044: materialized views incompatibility with logical replication in postgres 10
Date: Mon, 5 Feb 2018 16:33:14 +0100
Message-ID: <5754c88e-0ea5-ee34-5b4b-e50a6c66822f@2ndquadrant.com> (raw)
In-Reply-To: <161542b1c98.27af.478e5036e088b5aaf247fa13bcb9f071@iris.washington.edu>
References: <151753299917.1235.5710750500940066850@wrigleys.postgresql.org>
	<CAKFQuwbXMMybbA-p11=P3D4Z0gbYq2hyDE1YV3JHRnu+UF3Abw@mail.gmail.com>
	<161542b1c98.27af.478e5036e088b5aaf247fa13bcb9f071@iris.washington.edu>

Hi,

On 02/02/18 02:39, Chad Trabant wrote:
> On February 1, 2018 17:16:08 "David G. Johnston"
> <david.g.johnston@gmail.com> wrote:
>>> Bug reference:      15044
>>
>> It seems the work-around is to not use "for all tables" in your
> publication
>> definition.
> 
> 
> Indeed.  My real world case 700+ tables with semi regular additions and
> two materialized views so ALL TABLES was the right fit.
> 
> 
>> As described it does seem bugged.  The table matview itself is not being
>> published, as documented, but knowledge of its existence as part of the
>> publication is...
> 
> 
> Exactly.  The matview does not show up in pg_publication_tables but it's
> registered at some level.
> 

Indeed this is a bug. For normal publications we take care of this when
adding the relation to the publication but since ALL TABLES publications
don't check for membership we have to filter this directly in the output
plugin.

The attached patch should fix it (CCing to PeterE as the original
committer).

-- 
  Petr Jelinek                  http://www.2ndQuadrant.com/
  PostgreSQL Development, 24x7 Support, Training & Services

Attachments:

0001-Fix-filtering-of-unsupported-relations-in-pgoutput.patch (text/x-patch, 2.6K) download From 4272e15faefadc692e89ba06dcde64f07f4e075f Mon Sep 17 00:00:00 2001 From: Petr Jelinek <pjmodos@pjmodos.net> Date: Mon, 5 Feb 2018 16:09:37 +0100 Subject: [PATCH] Fix filtering of unsupported relations in pgoutput For normal publications this was already handled when such relation was requested to be added to given publication by user. However the alltables publications don't use relation membership check so we have to handle filtering of unsupported relation kinds directly in pgoutput. --- src/backend/replication/pgoutput/pgoutput.c | 33 ++++++++++++++++++----------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/src/backend/replication/pgoutput/pgoutput.c b/src/backend/replication/pgoutput/pgoutput.c index 40a1ef3c1d..37756474b9 100644 --- a/src/backend/replication/pgoutput/pgoutput.c +++ b/src/backend/replication/pgoutput/pgoutput.c @@ -509,15 +509,16 @@ get_rel_sync_entry(PGOutputData *data, Oid relid) Publication *pub = lfirst(lc); /* - * Skip tables that look like they are from a heap rewrite (see - * make_new_heap()). We need to skip them because the subscriber - * won't have a table by that name to receive the data. That - * means we won't ship the new data in, say, an added column with - * a DEFAULT, but if the user applies the same DDL manually on the - * subscriber, then this will work out for them. + * We might see changes here from relations which we don't know + * how to handle correcly, hence we have to filter them out. * - * We only need to consider the alltables case, because such a - * transient heap won't be an explicit member of a publication. + * These include: + * a) materialized views + * b) temporary relations used for heap rewrite + * + * We only care about those in alltables publications because + * for normal publications they will fail membership test. Also + * see check_publication_add_relation(). */ if (pub->alltables) { @@ -525,12 +526,20 @@ get_rel_sync_entry(PGOutputData *data, Oid relid) unsigned int u; int n; + /* + * We don't allow publishing of anything that's not a + * relation. + */ + if (get_rel_relkind(relid) != RELKIND_RELATION) + break; + + /* + * We also don't allow publishing temporary heaps for relation + * rewrite. See make_new_heap(). + */ if (sscanf(relname, "pg_temp_%u%n", &u, &n) == 1 && relname[n] == '\0') - { - if (get_rel_relkind(u) == RELKIND_RELATION) - break; - } + break; } if (pub->alltables || list_member_oid(pubids, pub->oid)) -- 2.14.1

view thread (7+ messages)  latest in thread

Message-ID: <5754c88e-0ea5-ee34-5b4b-e50a6c66822f@2ndquadrant.com>
Permalink:  ../5754c88e-0ea5-ee34-5b4b-e50a6c66822f@2ndquadrant.com/
Also on:    postgresql.org/message-id/5754c88e-0ea5-ee34-5b4b-e50a6c66822f@2ndquadrant.com

 ·  · 

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 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, chad@iris.washington.edu, david.g.johnston@gmail.com, peter.eisentraut@2ndquadrant.com
  Subject: Re: BUG #15044: materialized views incompatibility with logical replication in postgres 10
  In-Reply-To: <5754c88e-0ea5-ee34-5b4b-e50a6c66822f@2ndquadrant.com>
  References: <151753299917.1235.5710750500940066850@wrigleys.postgresql.org> <CAKFQuwbXMMybbA-p11=P3D4Z0gbYq2hyDE1YV3JHRnu+UF3Abw@mail.gmail.com> <161542b1c98.27af.478e5036e088b5aaf247fa13bcb9f071@iris.washington.edu> <5754c88e-0ea5-ee34-5b4b-e50a6c66822f@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