| From: | Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com> |
|---|---|
| To: | Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> |
| Cc: | David Rowley <dgrowleyml(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Andres Freund <andres(at)anarazel(dot)de> |
| Subject: | Re: Reducing relcache memory usage: deduping index shapes |
| Date: | 2026-09-01 18:42:22 |
| Message-ID: | CAEze2WgaftjGZjeoixEuHcysVN3-oet224XNwPC7EfE-CBKSAw@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Tue, 1 Sept 2026 at 08:02, Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> wrote:
>
> Hi Matthias,
>
> Thanks for the patch, the idea is interesting. I have just gone through the commits, and got a suspicion.
>
> Basically, the idea is to share common data via a hash table in each backend process, thereby saving some memory. However, sharing rd_supportinfo seems unsafe. In index_getprocinfo(), an entry is initialized lazily by calling fmgr_info_cxt(procId, locinfo, irel->rd_indexcxt);
>
> This stores the current index's private context in locinfo->fn_mcxt. Support functions may then allocate fn_extra in that context. If this index's relcache entry is destroyed while another index still references the shared rd_supportinfo, the first index's rd_indexcxt is deleted, leaving the shared FmgrInfo with a dangling fn_mcxt and possibly a dangling fn_extra.
>
> Am I missing something that guarantees the original rd_indexcxt remains valid for as long as the shared rd_supportinfo is referenced?
That's a good point. It looks like I'll have to make sure to make
that work, because right now that indeed has context lifetime issues.
Thanks for the report, I'll fix it in the next patch version.
Kind regards,
Matthias van de Meent
Databricks (https://www.databricks.com)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Andrey Borodin | 2026-09-01 18:49:41 | Re: Allow ON CONFLICT DO UPDATE to return EXCLUDED values |
| Previous Message | Andrey Borodin | 2026-09-01 18:35:40 | Re: Include sequences in publications created by pg_createsubscriber |