pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tomas Vondra <tomas.vondra@enterprisedb.com>
To: Alexander Pyhalov <a.pyhalov@postgrespro.ru>
Cc: Andres Freund <andres@anarazel.de>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: memory leak in trigger handling (since PG12)
Date: Sun, 2 Jul 2023 22:26:35 +0200
Message-ID: <d3acafd0-452e-070e-5891-d5e2f2d4370a@enterprisedb.com> (raw)
In-Reply-To: <48e251869b7ef921b7f894a3c7cb154a@postgrespro.ru>
References: <222a3442-7f7d-246c-ed9b-a76209d19239@enterprisedb.com>
	<960113.1684859980@sss.pgh.pa.us>
	<a5d42a2c-0c2e-9fb8-793f-0675d85669be@enterprisedb.com>
	<f706d912-b6fa-f1d7-5a39-dc1be5999183@enterprisedb.com>
	<20230524185559.un4dqfem3u3ktons@awork3.anarazel.de>
	<c3ff31ce-622c-81a9-9dcc-dbb27c5eaf9e@enterprisedb.com>
	<b3c8da23-8850-7697-2aaf-947bb2a4d0a3@enterprisedb.com>
	<acddb17c89b0d6cb940eaeda18c08bbe@postgrespro.ru>
	<36e564f7-6cde-927d-9089-19471a05e8f3@enterprisedb.com>
	<ee964409-fc64-d7d2-d8ad-3a64b72b5dc4@enterprisedb.com>
	<48e251869b7ef921b7f894a3c7cb154a@postgrespro.ru>



On 6/23/23 08:03, Alexander Pyhalov wrote:
> Tomas Vondra писал 2023-06-22 17:16:
>> On 6/22/23 13:46, Tomas Vondra wrote:
>>> ...
>>>
>>> I haven't tried the reproducer, but I think I see the issue - we store
>>> the bitmap as part of the event to be executed later, but the bitmap is
>>> in per-tuple context and gets reset. So I guess we need to copy it into
>>> the proper long-lived context (e.g. AfterTriggerEvents).
>>>
>>> I'll get that fixed.
>>>
>>
>> Alexander, can you try if this fixes the issue for you?
>>
>>
>> regard
> 
> Hi.
> The patch fixes the problem and looks good to me.

Thanks, I've pushed the fix, including backpatch to 13+ (12 is not
affected by the oversight, the bitmap was added by 71d60e2aa0).

I think it'd be good to investigate if it's possible to compute the
bitmap only once - as already suggested by Andres, but that's a matter
for separate patch, not a bugfix.

regards

-- 
Tomas Vondra
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company





view thread (32+ messages)

Message-ID: <d3acafd0-452e-070e-5891-d5e2f2d4370a@enterprisedb.com>
Permalink:  ../d3acafd0-452e-070e-5891-d5e2f2d4370a@enterprisedb.com/
Also on:    postgresql.org/message-id/d3acafd0-452e-070e-5891-d5e2f2d4370a@enterprisedb.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: tomas.vondra@enterprisedb.com, a.pyhalov@postgrespro.ru, andres@anarazel.de, tgl@sss.pgh.pa.us, pgsql-hackers@lists.postgresql.org
  Subject: Re: memory leak in trigger handling (since PG12)
  In-Reply-To: <d3acafd0-452e-070e-5891-d5e2f2d4370a@enterprisedb.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox