Re: row filtering for logical replication

From: "Euler Taveira" <euler(at)eulerto(dot)com>
To: japin <japinli(at)hotmail(dot)com>
Cc: Önder Kalacı <onderkalaci(at)gmail(dot)com>, "David Steele" <david(at)pgmasters(dot)net>, "Craig Ringer" <craig(at)2ndquadrant(dot)com>, "Tomas Vondra" <tomas(dot)vondra(at)2ndquadrant(dot)com>, "Michael Paquier" <michael(at)paquier(dot)xyz>, "Amit Langote" <amitlangote09(at)gmail(dot)com>, "movead li" <movead(dot)li(at)highgo(dot)ca>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: row filtering for logical replication
Date: 2021-02-01 19:11:50
Message-ID: 5b9fceed-8f91-467f-a64e-2134c5c3f496@www.fastmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Feb 1, 2021, at 6:11 AM, japin wrote:
> Thanks for updating the patch. Here are some comments:
Thanks for your review. I updated the documentation accordingly.

> The documentation says:
>
> > Columns used in the <literal>WHERE</literal> clause must be part of the
> > primary key or be covered by <literal>REPLICA IDENTITY</literal> otherwise
> > <command>UPDATE</command> and <command>DELETE</command> operations will not
> > be replicated.
The UPDATE is an oversight from a previous version.

>
> Does the publication only load the REPLICA IDENTITY columns into oldtuple when we
> execute DELETE? So the pgoutput_row_filter() cannot find non REPLICA IDENTITY
> columns, which cause it return false, right? If that's right, the UPDATE might
> not be limitation by REPLICA IDENTITY, because all columns are in newtuple,
> isn't it?
No. oldtuple could possibly be available for UPDATE and DELETE. However, row
filter consider only one tuple for filtering. INSERT has only newtuple; row
filter uses it. UPDATE has newtuple and optionally oldtuple (if it has PK or
REPLICA IDENTITY); row filter uses newtuple. DELETE optionally has only
oldtuple; row filter uses it (if available). Keep in mind, if the expression
evaluates to NULL, it returns false and the row won't be replicated.

After the commit 3696a600e2, the last patch does not apply cleanly. I'm
attaching another version to address the documentation issues.

--
Euler Taveira
EnterpriseDB: https://www.enterprisedb.com/

Attachment Content-Type Size
v10-0001-Remove-unused-column-from-initial-table-synchronizat.patch text/x-patch 1.7 KB
v10-0002-Rename-a-WHERE-node.patch text/x-patch 1.7 KB
v10-0003-Row-filter-for-logical-replication.patch text/x-patch 61.3 KB
v10-0004-Print-publication-WHERE-condition-in-psql.patch text/x-patch 1.2 KB
v10-0005-Publication-WHERE-condition-support-for-pg_dump.patch text/x-patch 2.8 KB
v10-0006-Debug-messages.patch text/x-patch 2.6 KB
v10-0007-Measure-row-filter-overhead.patch text/x-patch 1.5 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Joel Jacobson 2021-02-01 19:33:26 Re: Recording foreign key relationships for the system catalogs
Previous Message Andres Freund 2021-02-01 19:02:28 Re: Fix DROP TABLESPACE on Windows with ProcSignalBarrier?