| From: | David Rowley <dgrowleyml(at)gmail(dot)com> |
|---|---|
| To: | Mario Karuza <mkaruza(dot)pg(at)icloud(dot)com> |
| Cc: | pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: tuplesort_putdatum() does not account for tuple memory |
| Date: | 2026-10-05 06:06:54 |
| Message-ID: | CAApHDvoCj0CZjhvW+yNvMt0Anzb0S7W607hptUOVJjH5obJyYQ@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Fri, 11 Sept 2026 at 08:36, Mario Karuza <mkaruza(dot)pg(at)icloud(dot)com> wrote:
> Memory allocated for copied pass-by-reference Datums was not accounted
> against work_mem because tuplesort_putdatum() passed a hardcoded tuplen
> of 0 to tuplesort_puttuple_common(). Function free_sort_tuple() adjusts
> the accounting by the amount actually allocated, so freeing such a
> tuple subtracts an amount that was never added.
>
> This was introduced in 6ed83d5fa55, which switched non-bounded sorts to
> bump contexts. That commit correctly changed the other tuplesort_put*()
> functions to compute the size, leaving only this one passing hardcoded
> 0.
Can you share how you found this issue? e.g., was it a problem you
found in production because of excessive memory usage? or was it
human, AI, or other tooling looking at the code?
David
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Richard Guo | 2026-10-05 06:21:19 | Re: Assert failure in get_baserel_parampathinfo with lateral UNION ALL |
| Previous Message | Hayato Kuroda (Fujitsu) | 2026-10-05 05:53:45 | RE: Fix apply worker crash when subscriber table has only a deferrable primary key |