pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Amit Kapila <akapila@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Ignore heap rewrites for materialized views in logical replicati
Date: Fri, 03 Jun 2022 02:51:56 +0000
Message-ID: <E1nwxPo-002RWD-Hh@gemulon.postgresql.org> (raw)

Ignore heap rewrites for materialized views in logical replication.

If you have a publication that specifies FOR ALL TABLES clause, a REFRESH
MATERIALIZED VIEW can break your setup with the following message

ERROR: logical replication target relation "public.pg_temp_NNN" does not exist

Commit 1a499c2520 introduces a heuristic to skip table writes that look
like they are from a heap rewrite for a FOR ALL TABLES publication.
However, it forgot to exclude materialized views (heap rewrites occur when
you execute REFRESH MATERIALIZED VIEW). Since materialized views are not
supported in logical decoding, it is appropriate to filter them too.

As explained in the commit 1a499c2520, a more robust solution was included
in version 11 (commit 325f2ec555), hence only version 10 is affected.

Reported-by: Euler Taveira
Author: Euler Taveira
Reviewed-by: Amit Kapila
Discussion: https://postgr.es/m/bc557ebe-92dc-4afa-b6bb-285a9eeaa614@www.fastmail.com

Branch
------
REL_10_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/37fd181d6dea9675181344ea9364ef6b66919aec

Modified Files
--------------
src/backend/replication/pgoutput/pgoutput.c |  4 +++-
src/test/subscription/t/006_rewrite.pl      | 20 +++++++++++++++++++-
2 files changed, 22 insertions(+), 2 deletions(-)



Message-ID: <E1nwxPo-002RWD-Hh@gemulon.postgresql.org>
Permalink:  ../E1nwxPo-002RWD-Hh@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1nwxPo-002RWD-Hh@gemulon.postgresql.org

 · 

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-committers@postgresql.org
  Cc: akapila@postgresql.org
  Subject: Re: pgsql: Ignore heap rewrites for materialized views in logical replicati
  In-Reply-To: <E1nwxPo-002RWD-Hh@gemulon.postgresql.org>
  References: <E1nwxPo-002RWD-Hh@gemulon.postgresql.org>

* 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