From: Tom Lane <tgl@sss.pgh.pa.us>
To: Haribabu Kommi <kommi.haribabu@gmail.com>
Cc: Heikki Linnakangas <hlinnaka@iki.fi>
Cc: Michael Paquier <michael.paquier@gmail.com>
Cc: Behn, Edward (EBEHN) <EBEHN@arinc.com>
Cc: pgsql-bugs@postgresql.org <pgsql-bugs@postgresql.org>
Subject: Re: Memory leak with PL/Python trigger
Date: Wed, 19 Aug 2015 16:18:26 -0400
Message-ID: <18770.1440015506@sss.pgh.pa.us> (raw)
In-Reply-To: <CAJrrPGcBLU88heef0TB_imuj5VBsz5nDSC-QwmO4-TtAx0_TsA@mail.gmail.com>
References: <93F16B4BD93A7840AC75EB16E9494C7B211084DA@EXANPMB1.arinc.com>
<CAJrrPGf4s5QKU2VrYWBeqTf+4kHekj4uEnnx6P0ShdVZN6kZKA@mail.gmail.com>
<CAJrrPGc0grzvEcFrMjFzEzE8veVt4A8hyLZrmdCj_XGReWWpQA@mail.gmail.com>
<55BB3C53.2030603@iki.fi>
<CAJrrPGcnjrz5pFVLcOwtoCMcgX-Qcv4M2x+cDrR8hCwPpEfmNw@mail.gmail.com>
<CAB7nPqRFjq4aT_GSkUyuYda4XBtrLN3xgOnsR=fERD2dUfnFuA@mail.gmail.com>
<CAJrrPGdRgHqSueBxd43xw-utovF4WB-4f8MXyYL798jAenKE-w@mail.gmail.com>
<CAJrrPGcBLU88heef0TB_imuj5VBsz5nDSC-QwmO4-TtAx0_TsA@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
Haribabu Kommi <kommi.haribabu@gmail.com> writes:
> Here I attached updated patch with a context allocation in
> "PLy_procedure_create" function and the same context is reset
> in every function call of "PLy_procedure_get" for all PLY types.
This isn't really going in the direction I had in mind.
I think what we want is to get rid of *all* of plpython's retail
allocations in TopMemoryContext. All the long-lived data about
a given procedure, starting with its PLyProcedure struct and
certainly including all the associated PLyTypeInfo stuff, ought
to be in a per-procedure context, similarly to the way plpgsql
manages it. Then you can just delete that context if the procedure
definition changes, and not need any retail cleanup.
Also, you can't just reset the context being used as fn_mcxt
without any regard for the possibility that functions have
stored pointers into that space (probably in their fn_extra).
Really you ought to redo fmgr_info() if you do that. That
means that this approach is fundamentally giving up the ability
to cache type lookup data across calls at all, which is surely
not what we want.
I would envision the PLyTypeInfo structs as usually living in the
per-procedure context, and that's where fn_mcxt would point as well.
There might be some cases where we have to have shorter-lived
PLyTypeInfos, but the normal case ought to work like that.
regards, tom lane
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, kommi.haribabu@gmail.com, hlinnaka@iki.fi, michael.paquier@gmail.com, EBEHN@arinc.com
Subject: Re: Memory leak with PL/Python trigger
In-Reply-To: <18770.1440015506@sss.pgh.pa.us>
References: <93F16B4BD93A7840AC75EB16E9494C7B211084DA@EXANPMB1.arinc.com> <CAJrrPGf4s5QKU2VrYWBeqTf+4kHekj4uEnnx6P0ShdVZN6kZKA@mail.gmail.com> <CAJrrPGc0grzvEcFrMjFzEzE8veVt4A8hyLZrmdCj_XGReWWpQA@mail.gmail.com> <55BB3C53.2030603@iki.fi> <CAJrrPGcnjrz5pFVLcOwtoCMcgX-Qcv4M2x+cDrR8hCwPpEfmNw@mail.gmail.com> <CAB7nPqRFjq4aT_GSkUyuYda4XBtrLN3xgOnsR=fERD2dUfnFuA@mail.gmail.com> <CAJrrPGdRgHqSueBxd43xw-utovF4WB-4f8MXyYL798jAenKE-w@mail.gmail.com> <CAJrrPGcBLU88heef0TB_imuj5VBsz5nDSC-QwmO4-TtAx0_TsA@mail.gmail.com> <18770.1440015506@sss.pgh.pa.us>
* 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