pgsql: Handle heap rewrites better in logical replication

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Handle heap rewrites better in logical replication
Date: 2017-09-26 14:30:46
Message-ID: E1dwqso-0002P3-Qd@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Handle heap rewrites better in logical replication

A FOR ALL TABLES publication naturally considers all base tables to be a
candidate for replication. This includes transient heaps that are
created during a table rewrite during DDL. This causes failures on the
subscriber side because it will not have a table like pg_temp_16386 to
receive data (and if it did, it would be the wrong table).

The prevent this problem, we filter out any tables that match this
naming pattern and match an actual table from FOR ALL TABLES
publications. This is only a heuristic, meaning that user tables that
match that naming could accidentally be omitted. A more robust solution
might require an explicit marking of such tables in pg_class somehow.

Reported-by: yxq <yxq(at)o2(dot)pl>
Bug: #14785
Reviewed-by: Andres Freund <andres(at)anarazel(dot)de>
Reviewed-by: Petr Jelinek <petr(dot)jelinek(at)2ndquadrant(dot)com>

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/ab28feae2bd3d4629bd73ae3548e671c57d785f0

Modified Files
--------------
src/backend/replication/pgoutput/pgoutput.c | 26 ++++++++++
src/test/subscription/t/006_rewrite.pl | 73 +++++++++++++++++++++++++++++
2 files changed, 99 insertions(+)

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Eisentraut 2017-09-26 16:01:16 pgsql: Sort pg_basebackup options better
Previous Message Robert Haas 2017-09-26 13:26:51 pgsql: Remove lsn from HashScanPosData.