Re: Fix resource leak in FindConflictTuple() retry path

From: Nisha Moond <nisha(dot)moond412(at)gmail(dot)com>
To: shveta malik <shveta(dot)malik(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, "Zhijie Hou (Fujitsu)" <houzj(dot)fnst(at)fujitsu(dot)com>
Subject: Re: Fix resource leak in FindConflictTuple() retry path
Date: 2026-09-03 06:05:36
Message-ID: CABdArM7OHkRLtGBLs2oEC2rNgsSZvHz5xQFsig1wwPL1TmDUoQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Sep 3, 2026 at 10:54 AM shveta malik <shveta(dot)malik(at)gmail(dot)com> wrote:
>
> On Thu, Sep 3, 2026 at 9:22 AM Nisha Moond <nisha(dot)moond412(at)gmail(dot)com> wrote:
>
> I agree with the idea of patch. But the patch can be improved. Before
> this patch, slot creation happened after the conflict was found. Now
> it happens unconditionally. So every call to FindConflictTuple() now
> allocates a slot and immediately tears it down. So most of the cases
> which are ocnflict-free now will do slot-allocation. I feel this can
> be optimized.
>

Good point, agree.

> Suggestion:
>
> retry:
> if (ExecCheckIndexConstraints(...))
> {
> if (*conflictslot)
> ExecDropSingleTupleTableSlot(*conflictslot);
> *conflictslot = NULL;
> return false;
> }
>
> if (*conflictslot == NULL)
> *conflictslot = table_slot_create(rel, NULL);
>

Adopted in v2, attached.

--
Thanks,
Nisha

Attachment Content-Type Size
v2-0001-Avoid-re-creating-the-conflict-slot-on-retry-in-F.patch application/octet-stream 1.5 KB
v2-0002-TAP-test-for-FindConflictTuple-buffer-pin-leak.patch application/octet-stream 11.8 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message shveta malik 2026-09-03 06:26:03 Re: Remove stale XXX comment in logical launcher
Previous Message Michael Paquier 2026-09-03 05:51:28 Re: pg_upgrade: Test --check with a running source server