diff options
author | Tomas Vondra <tomas.vondra@postgresql.org> | 2025-05-02 23:04:39 +0200 |
---|---|---|
committer | Tomas Vondra <tomas.vondra@postgresql.org> | 2025-05-02 23:05:18 +0200 |
commit | 1681a70df3d68b6f9dc82645f97f8d4668edc42f (patch) | |
tree | eeb0bf08f89ac494054a7fdf159ab232dad0e7d6 /src/backend/access/nbtree/nbtutils.c | |
parent | e83a8ae44729bfdd15d31101bd2c99be98cfc691 (diff) | |
download | postgresql-1681a70df3d68b6f9dc82645f97f8d4668edc42f.tar.gz postgresql-1681a70df3d68b6f9dc82645f97f8d4668edc42f.zip |
Fix memory leak in _gin_parallel_merge
To insert the merged GIN entries in _gin_parallel_merge, the leader
calls ginEntryInsert(). This may allocate memory, e.g. for a new leaf
tuple. This was allocated in the PortalContext, and kept until the end
of the index build. For most GIN indexes the amount of leaked memory is
negligible, but for custom opclasses with large keys it may cause OOMs.
Fixed by calling ginEntryInsert() in a temporary memory context, reset
after each insert. Other ginEntryInsert() callers do this too, except
that the context is reset after batches of inserts. More frequent resets
don't seem to hurt performance, it may even help it a bit.
Report and fix by Vinod Sridharan.
Author: Vinod Sridharan <vsridh90@gmail.com>
Reviewed-by: Tomas Vondra <tomas@vondra.me>
Discussion: https://postgr.es/m/CAFMdLD4p0VBd8JG=Nbi=BKv6rzFAiGJ_sXSFrw-2tNmNZFO5Kg@mail.gmail.com
Diffstat (limited to 'src/backend/access/nbtree/nbtutils.c')
0 files changed, 0 insertions, 0 deletions