| From: | Álvaro Herrera <alvherre(at)kurilemu(dot)de> |
|---|---|
| To: | Zhijie Hou <houzhijie22(at)gmail(dot)com> |
| Cc: | Pg Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Antonin Houska <ah(at)cybertec(dot)at> |
| Subject: | Re: logical decoding: removing change_useless_for_repack() |
| Date: | 2026-11-28 15:21:30 |
| Message-ID: | awrWlXTzTc5Gzn3M@alvherre.pgsql |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On 2026-Nov-28, Zhijie Hou wrote:
> 1.
> + * If the given RelFileLocator matches one of the locators being processed
> by
> + * REPACK, return true to have this record be skipped by decoding.
> Otherwise
> + * return false.
>
> The comment has the return value inverted; that is, when the locator matches
> one of the locators being processed by REPACK, the function returns false
> (so it is decoded), and returns true otherwise.
Oh, yeah, this is my bug: I wanted to invert the sense of the booleans,
because as it is, it makes little sense to me. But then I noticed
Antonin was just doing the same as the FilterByOrigin callback does. So
it's not Antonin's or this patch's fault, but that of the old code, and
so for consistency we should keep it that way. But after that
realization I forgot to revert my update of the comment. Thanks for
noticing.
Also fixed #2 and #4 in this new version, thanks. The nocfbot patch is
the (trivial) diff from v2.
> 3.
>
> The patch does not call the callback in DecodeTruncate(). Since
> thedocumentation describes this as a generic callback, it would be better to
> allowfiltering TRUNCATE as well.
Interesting thought. What happens with repack is that we don't filter,
thus the record is decoded and processed by decode.c. But pgrepack
doesn't have a truncate callback, so when it reaches logical.c, that
code simply skips the record doing nothing. That's perfectly fine,
because if you're repacking a table, nobody can truncate it, so this
cannot actually happen.
You suggest that we should look at the list of relations being
truncated, then skip decoding if none of these relations match the
RelFileLocator. I suspect you're right that for the general use case we
should do this. I didn't do this in this version, but we should do that
before commit. (Being of course careful not to waste time trying to
skip a record only to later find out that there's no truncate_cb
callback in the first place.)
--
Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/
| Attachment | Content-Type | Size |
|---|---|---|
| nocfbot-0001-fixups.patch | text/x-diff | 4.3 KB |
| v3-0001-Introduce-an-output-plugin-callback-to-filter-cha.patch | text/x-diff | 21.0 KB |
| From | Date | Subject | |
|---|---|---|---|
| Previous Message | Xuneng Zhou | 2026-11-28 14:15:13 | Re: Set 1s WaitLatch timeout if standby limit has expired in ResolveRecoveryConflictWithBufferPin |