| From: | Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> |
|---|---|
| To: | Andrew Dunstan <andrew(at)dunslane(dot)net> |
| Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: Table AM callback for logical decoding support (REPACK CONCURRENTLY) |
| Date: | 2026-11-20 02:40:49 |
| Message-ID: | F4482AB9-41F5-45B8-AC6B-AC15D3856131@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
> On Nov 20, 2026, at 00:34, Andrew Dunstan <andrew(at)dunslane(dot)net> wrote:
>
> Hi,
>
> In [1], REPACK (CONCURRENTLY) was restricted to heap because nothing in
> TableAmRoutine says whether an AM can be logically decoded, and without
> decoding the changes made during the rewrite are silently lost. Masahiko
> suggested a callback for HEAD, and Bharath that it wait for a field report.
> Here is one: a table AM we are developing has its own resource manager
> with rm_decode, and the heap-only check refuses it.
>
> The attached patch adds an optional relation_supports_logical_decoding
> callback, last in TableAmRoutine. An AM without it is taken not to support
> decoding, so existing AMs are unaffected. heap provides it, and REPACK asks
> the AM instead of comparing its routine with heap's.
>
> With the callback set in that AM, REPACK (CONCURRENTLY) with concurrent DML
> converges row for row with a heap oracle, and a logical slot attached
> during it sees no duplicate changes.
>
> The test module has two AMs that copy heap's routine, one without the
> callback. heap_getnext() insists on heap's own routine, so their tables can
> have no index or TOAST table; the test shows one refused and the other past
> the check.
>
> This is for v20 only. It is the second small TableAmRoutine addition that
> out-of-tree AMs need, after the reloptions patch in [2]. The two don't
> conflict (this one is last in the struct), and could be reviewed, or
> committed, as one series if that's easier. Maybe we only need one new test
> module instead of two.
>
> I'd welcome views on the shape: a callback, as suggested, or a plain flag.
>
> [1] https://postgr.es/m/apBkixO4xAGFoiT3@nathan
> [2] https://postgr.es/m/ea1c4d33-0780-473c-96dc-1468cf733a04@dunslane.net
> ("Allow table AMs to define their own reloptions")
>
>
> cheers
>
>
> andrew
>
> --
> Andrew Dunstan
> EDB: https://www.enterprisedb.com
> <0001-Add-a-table-AM-callback-for-logical-decoding-support.patch>
I think it's better to use a table AM method instead of sticking to the heap AM. This seems to be in the same spirit as patch [1] I'm currently working on, which adds a new TAM method to decide whether a relation is empty.
After reading the patch, I just have a question: Why does relation_supports_logical_decoding() need a Relation argument? From my understanding, if or not an AM supports logical decoding seems to be an AM-level capability, and the heap AM's implementation only returns true. Is there a known use case where a table AM needs to make this decision based on an individual relation?
[1] https://www.postgresql.org/message-id/DE69B65E-4621-4AF4-9A00-6A042E565C90%40gmail.com
Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Fujii Masao | 2026-11-20 02:44:13 | Re: A bug in recovery prefetcher, triggering asserts / FATAL: checkpoint request failed |
| Previous Message | John Naylor | 2026-11-20 02:24:33 | Re: Keep TIDBitmap pagetable memory across bitmap scans |