From: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
To: 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
Subject: Re: BUG #15044: materialized views incompatibility with logical replication in postgres 10
Date: Sat, 17 Feb 2018 22:43:38 -0500
Message-ID: <6e375316-91a4-7825-ef8b-9b8915ab6980@2ndquadrant.com> (raw)
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>
On 2/5/18 10:33, Petr Jelinek wrote:
>> 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.
I think the filtering in pgoutput ought to make use of
is_publishable_class() in some way. That takes care of non-tables such
as materialized views, but it also filters out the information_schema
tables for example. Right now, if you insert something into one of the
IS tables, it gets shipped over the wire but is then dropped by the
apply because there is no pg_subscription_rel entry of the table. That
doesn't quite have the user-visible effect as this bug, but it's bogus
nonetheless.
So I propose this alternative patch that covers all these cases.
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Attachments:0001-Fix-filtering-of-unsupported-relations-in-pgoutput.patch (text/plain, 2.0K) download
From fb9ad748f903e0e67b173022f3fd39b0a82034ba Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter_e@gmx.net>
Date: Sat, 17 Feb 2018 22:30:18 -0500
Subject: [PATCH] Fix filtering of unsupported relations in pgoutput
Bug: #15044
---
src/backend/catalog/pg_publication.c | 9 +++++++++
src/backend/replication/pgoutput/pgoutput.c | 3 +++
src/include/catalog/pg_publication.h | 1 +
3 files changed, 13 insertions(+)
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.cindex 3ef7ba8cd5..a0973f43e2 100644--- a/src/backend/catalog/pg_publication.c+++ b/src/backend/catalog/pg_publication.c@@ -105,6 +105,15 @@ is_publishable_class(Oid relid, Form_pg_class reltuple)
relid >= FirstNormalObjectId;
}
+/*+ * Another variant of this, taking a Relation.+ */+bool+is_publishable_relation(Relation rel)+{+ return is_publishable_class(RelationGetRelid(rel), rel->rd_rel);+}+
/*
* SQL-callable variant of the above
diff --git a/src/backend/replication/pgoutput/pgoutput.c b/src/backend/replication/pgoutput/pgoutput.cindex 61e53aba19..38b0eab7d2 100644--- a/src/backend/replication/pgoutput/pgoutput.c+++ b/src/backend/replication/pgoutput/pgoutput.c@@ -264,6 +264,9 @@ pgoutput_change(LogicalDecodingContext *ctx, ReorderBufferTXN *txn,
MemoryContext old;
RelationSyncEntry *relentry;
+ if (!is_publishable_relation(relation))+ return;+
relentry = get_rel_sync_entry(data, RelationGetRelid(relation));
/* First check the table filter */
diff --git a/src/include/catalog/pg_publication.h b/src/include/catalog/pg_publication.hindex aa148960cd..be4987505d 100644--- a/src/include/catalog/pg_publication.h+++ b/src/include/catalog/pg_publication.h@@ -93,6 +93,7 @@ extern List *GetPublicationRelations(Oid pubid);
extern List *GetAllTablesPublications(void);
extern List *GetAllTablesPublicationRelations(void);
+extern bool is_publishable_relation(Relation rel);
extern ObjectAddress publication_add_relation(Oid pubid, Relation targetrel,
bool if_not_exists);
--
2.16.1
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: peter.eisentraut@2ndquadrant.com, petr.jelinek@2ndquadrant.com, chad@iris.washington.edu, david.g.johnston@gmail.com
Subject: Re: BUG #15044: materialized views incompatibility with logical replication in postgres 10
In-Reply-To: <6e375316-91a4-7825-ef8b-9b8915ab6980@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> <6e375316-91a4-7825-ef8b-9b8915ab6980@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