Re: Table AM callback for logical decoding support (REPACK CONCURRENTLY)

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Antonin Houska <ah(at)cybertec(dot)at>
Cc: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org, alvherre(at)kurilemu(dot)de
Subject: Re: Table AM callback for logical decoding support (REPACK CONCURRENTLY)
Date: 2026-12-03 14:57:00
Message-ID: 826a62af-a6b1-472f-92c7-92068ccbf1d0@dunslane.net
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On 2026-11-24 Tu 12:49 PM, Antonin Houska wrote:
> Andrew Dunstan <andrew(at)dunslane(dot)net> wrote:
>
>> On 2026-11-20 Fr 7:00 PM, Zsolt Parragi wrote:
>>> + * TABLEAM_SUPPORTS_LOGICAL_DECODING: every change to the relation's rows can
>>> + * be logically decoded, which needs the AM's resource manager to have an
>>> + * rm_decode callback. REPACK (CONCURRENTLY) checks this, as it would
>>> + * otherwise lose the changes made while it runs.
>>>
>>> Doesn't it also require filtering (change_useless_for_repack)?
>>
>> Yes, it does, and the comment should have said so.  pgrepack's change
>> callback asserts that it only sees changes to the relation being rebuilt
>> ("Changes of other relation should not have been decoded"), so an AM whose
>> rm_decode doesn't call change_useless_for_repack() would trip that on an
>> assert build, and on a non-assert build feed other tables' changes into the
>> rewrite.  Our AM's rm_decode already does it for each kind of change, which
>> is how I missed that the contract didn't mention it. I have added it to the
>> comment on the flag and to tableam.sgml.
> When we were working on REPACK (CONCURRENTLY), Alvaro pointed out that the
> filtering might fit better into the plugin. We haven't done it in v19, but the
> mention of change_useless_for_repack() in your patch reminds me that the
> function call really does not fit perfectly into rm_decode() - the problem is
> that rm_decode() is also called during logical replication, which does not
> need the filtering.
>
> Attached is a patch that adds a new filtering callback to the output
> plugin. If it's what Alvaro meant, then I wonder if it makes sense to merge it
> first. (In any case, I added a TODO comment referencing this thread, so that
> your documentation and comments are updated if your patch lands in the tree
> first.)

That's now landed (f7f7101 - thanks Alvaro), so here's a v5. The code is
unchanged, but the contract text has been updated.

cheers

andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com

Attachment Content-Type Size
v5-0001-Add-a-table-AM-callback-to-report-supported-featu.patch text/x-patch 25.6 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Nitin Motiani 2026-12-03 15:05:51 Re: Speed up tuplestore_seek() by starting from the nearest known position
Previous Message Heikki Linnakangas 2026-12-03 14:49:14 Re: several cases of float and integer mixup