| From: | Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> |
|---|---|
| To: | Michael Paquier <michael(at)paquier(dot)xyz> |
| Cc: | Xuneng Zhou <xunengzhou(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: Fix a relcache reference leak in reorderbuffer.c |
| Date: | 2026-08-19 02:18:53 |
| Message-ID: | 242A430C-6109-4372-9875-A00ECE70CA0A@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
> On Aug 19, 2026, at 06:35, Michael Paquier <michael(at)paquier(dot)xyz> wrote:
>
> On Tue, Aug 18, 2026 at 01:59:01PM +0800, Xuneng Zhou wrote:
>> I think this is not a session-level *leak*. The resource owner of
>> ongoing txn would take care of the reference once the
>> ReorderBufferProcessTXN aborts its internal transaction. Yeah, it
>> could be more troublesome if the skipped references keep accumulating
>> until the decoding of txn finishes. That said, it's not very clear to
>> me whether this code is actually excerised. Can you provide a
>> reproducer or a test?
>
> More to the point, looking at code paths producing XLOG_HEAP_TRUNCATE
> records in core, we specifically discard any relation that does not
> satisfy RelationIsLogicallyLogged().
>
> In short, it is not possible in practice to reach this code at all.
> We would do a decoding of the generated record after an historical
> snapshot, so something like a SET UNLOGGED should not be seen in
> practice. I think that it does not hurt to be defensive in practice
> here, still I am wondering about code outside of core that may play it
> unfair, even if the consequences are minimal.
> --
> Michael
I just took a deeper look at the code. If we handle the continue defensively, then in theory nrelations could be 0. We should also defensively skip ReorderBufferApplyTruncate() when nrelations == 0. Looking at a callback function, for example, pgoutput_truncate() in src/backend/replication/pgoutput/pgoutput.c appears to assume that nrelations > 0, it doesn't specially handle nrelations == 0.
Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Michael Paquier | 2026-08-19 02:34:56 | Re: Fix a relcache reference leak in reorderbuffer.c |
| Previous Message | Richard Guo | 2026-08-19 01:41:59 | Re: Reduce LEFT/FULL JOIN to ANTI JOIN in more cases |