RE: row filtering for logical replication

From: "houzj(dot)fnst(at)fujitsu(dot)com" <houzj(dot)fnst(at)fujitsu(dot)com>
To: Peter Smith <smithpb2250(at)gmail(dot)com>
Cc: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Euler Taveira <euler(at)eulerto(dot)com>, Greg Nancarrow <gregn4422(at)gmail(dot)com>, vignesh C <vignesh21(at)gmail(dot)com>, Ajin Cherian <itsajin(at)gmail(dot)com>, "tanghy(dot)fnst(at)fujitsu(dot)com" <tanghy(dot)fnst(at)fujitsu(dot)com>, Dilip Kumar <dilipbalaut(at)gmail(dot)com>, Rahila Syed <rahilasyed90(at)gmail(dot)com>, Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>, Önder Kalacı <onderkalaci(at)gmail(dot)com>, japin <japinli(at)hotmail(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz>, David Steele <david(at)pgmasters(dot)net>, Craig Ringer <craig(at)2ndquadrant(dot)com>, Amit Langote <amitlangote09(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: RE: row filtering for logical replication
Date: 2022-01-31 01:57:33
Message-ID: OS0PR01MB57168F454E33D53551B8D20294259@OS0PR01MB5716.jpnprd01.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Monday, January 31, 2022 8:53 AM Peter Smith <smithpb2250(at)gmail(dot)com> wrote:
>
> PSA v73*.
>
> (A rebase was needed due to recent changes in tab-complete.c.
> Otherwise, v73* is the same as v72*).

Thanks for the rebase.
Attach the V74 patch set which did the following changes:

v74-0000
-----
This patch is borrowed from[1] to fix the cfbot failure[2].

The reason of the cfbot failure is that:
When rel_sync_cache_relation_cb does invalidate an entry, it immediately
free the cached stuff(including the slot), even though that might still be
in use. For the failed testcase, It received invalid message in
logicalrep_write_tuple when invoking "SearchSysCache1(TYPEOID," and free
the slot memory. So, it used the freed slot values to send which could
cause the unexpected result.

And this pending patch[1] fix this problem by move the memory free code
from rel_sync_cache_relation_cb to get_rel_sync_entry. So, before this
patch is committed, attach it here to make the cfbot happy.

[1] https://www.postgresql.org/message-id/CAA4eK1JACZTJqu_pzTu_2Nf-zGAsupqyfk6KBqHe9puVZGQfvw%40mail.gmail.com
[2] https://cirrus-ci.com/task/5450648090050560?logs=test_world#L3975

v74-0001
-----
- Cache the estate in RelationSyncEntry (Andres [3])
- Move the row filter init code to get_rel_sync_entry (Andres [3])
- Remove the static label of map_changetype_pubaction (Andres [3])
- Allocate memory for newly added cached stuff under
a separate memory context which is below ctx->context (Andres [3])
- a commit message change. (Greg [4])

v74-0002
-----
- Add the WHERE clause in the COMPLETE_WITH(",") line. (Alvaro [5])

[3] https://www.postgresql.org/message-id/20220129003110.6ndrrpanem5sb4ee%40alap3.anarazel.de
[4] https://www.postgresql.org/message-id/CAJcOf-d3zBMtpNwRuu23O%3DWeUz9FWBrTxeqtXUV_vyL103aW5A%40mail.gmail.com
[5] https://www.postgresql.org/message-id/202201281351.clzyf4cs6vzb%40alvherre.pgsql

Best regards,
Hou zj

Attachment Content-Type Size
v74-0001-Allow-specifying-row-filters-for-logical-replication.patch application/octet-stream 155.5 KB
v74-0002-Row-filter-tab-auto-complete-and-pgdump.patch application/octet-stream 5.8 KB
v74-0000-clean-up-pgoutput-cache-invalidation.patch application/octet-stream 7.0 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Kyotaro Horiguchi 2022-01-31 02:10:45 Re: Is there a way (except from server logs) to know the kind of on-going/last checkpoint?
Previous Message Tom Lane 2022-01-31 01:54:57 Re: Support tab completion for upper character inputs in psql