pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Aleš Zelený <zeleny.ales@gmail.com>
Cc: Tomas Vondra <tomas.vondra@enterprisedb.com>
Cc: Michael Paquier <michael@paquier.xyz>
Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: PostgreSQL 14.4 ERROR: out of memory issues
Date: Wed, 03 Aug 2022 19:05:52 -0400
Message-ID: <3258036.1659567952@sss.pgh.pa.us> (raw)
In-Reply-To: <CAODqTUZ1KJEEnhw6_+CVBtLkjPuo40hDxy6E5O6ShP4MfhMQTQ@mail.gmail.com>
References: <CAODqTUaZAqkmiFpB-Sy5yqTrC6iJR1GyB5JRXLuitxJjR3_B=Q@mail.gmail.com>
	<Ys4P48i85Nn3xKpD@paquier.xyz>
	<CAODqTUbZG+Fp-NfynbATfGf0y=xsi1XfwBCDQWgXWeAcVOFXZQ@mail.gmail.com>
	<b009e8aa-6e6e-cc22-1ee1-60f8a55aacc0@enterprisedb.com>
	<CAODqTUZLeUiMFCAj8ehzTZyTYae=X5r46OmUFGbuegzrRkqt_A@mail.gmail.com>
	<CAODqTUZ+pxQVKwOa-H4vSP+dbpLpQv-XyGp2Kbgp1H8fQ69oCQ@mail.gmail.com>
	<695843.1658154336@sss.pgh.pa.us>
	<CAODqTUbB+Vt0o2kv5pvNH1XpmWf6NQR2nnkPNvjOVd17Ts6z_w@mail.gmail.com>
	<787006.1658171039@sss.pgh.pa.us>
	<CAODqTUZYWnVWF41ELYxFY_8tzo0165LxFu7t52gRBwi-apx51A@mail.gmail.com>
	<CAODqTUZ1KJEEnhw6_+CVBtLkjPuo40hDxy6E5O6ShP4MfhMQTQ@mail.gmail.com>

=?UTF-8?B?QWxlxaEgWmVsZW7DvQ==?= <zeleny.ales@gmail.com> writes:
> CREATE OR REPLACE FUNCTION tescase (_id_data_provider integer, _external_id
> bigint DEFAULT NULL::bigint, _external_complete_id character varying
> DEFAULT NULL::character varying)
>  RETURNS TABLE(id_gm bigint, id_opp bigint, id_opp_state integer)
>  LANGUAGE sql
> AS $function$
> SELECT ... simple join of two tables...
>      WHERE opd.id_data_provider = _id_data_provider
>        AND CASE WHEN _external_id IS NULL
>                 THEN external_id IS NULL
>                 ELSE external_id = _external_id
>            END
>        AND CASE WHEN _external_complete_id IS NULL
>                 THEN _external_complete_id IS NULL
>                 ELSE external_complete_id = _external_complete_id
>            END;
> $function$
> ;

> It is a kind of creative construct for me, but it works. The key here is
> that if I replace at least one of the "CASEd" where conditions, it seems
> not to suffer from the memory leak issue.

> Finally, I've found, that even having the function as is and before the
> test disabling JIT (SET jit = off;) and calling the function 100k times,
> RssAnon memory for the given process is stable and only 3612 kB, while when
> JIT is enabled (the default setting on the server suffering from the memory
> leak, RssAnon memory for the given process growth in a linear manner over
> time (canceled when it reached 5GB).

Ah.  I bet this is another instance of the known memory leakage problems
with JIT inlining [1].  Per Andres' comments in that thread, it seems
hard to solve properly.  For now all I can recommend is to disable that.

			regards, tom lane

[1] https://www.postgresql.org/message-id/flat/20201001021609.GC8476%40telsasoft.com





view thread (22+ messages)  latest in thread

Message-ID: <3258036.1659567952@sss.pgh.pa.us>
Permalink:  ../3258036.1659567952@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/3258036.1659567952@sss.pgh.pa.us

 · 

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 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-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, zeleny.ales@gmail.com, tomas.vondra@enterprisedb.com, michael@paquier.xyz
  Subject: Re: PostgreSQL 14.4 ERROR: out of memory issues
  In-Reply-To: <3258036.1659567952@sss.pgh.pa.us>
  References: <CAODqTUaZAqkmiFpB-Sy5yqTrC6iJR1GyB5JRXLuitxJjR3_B=Q@mail.gmail.com> <Ys4P48i85Nn3xKpD@paquier.xyz> <CAODqTUbZG+Fp-NfynbATfGf0y=xsi1XfwBCDQWgXWeAcVOFXZQ@mail.gmail.com> <b009e8aa-6e6e-cc22-1ee1-60f8a55aacc0@enterprisedb.com> <CAODqTUZLeUiMFCAj8ehzTZyTYae=X5r46OmUFGbuegzrRkqt_A@mail.gmail.com> <CAODqTUZ+pxQVKwOa-H4vSP+dbpLpQv-XyGp2Kbgp1H8fQ69oCQ@mail.gmail.com> <695843.1658154336@sss.pgh.pa.us> <CAODqTUbB+Vt0o2kv5pvNH1XpmWf6NQR2nnkPNvjOVd17Ts6z_w@mail.gmail.com> <787006.1658171039@sss.pgh.pa.us> <CAODqTUZYWnVWF41ELYxFY_8tzo0165LxFu7t52gRBwi-apx51A@mail.gmail.com> <CAODqTUZ1KJEEnhw6_+CVBtLkjPuo40hDxy6E5O6ShP4MfhMQTQ@mail.gmail.com> <3258036.1659567952@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