pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stephan Knauss <pgsql@stephans-server.de>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: Debugging leaking memory in Postgresql 13.2/Postgis 3.1
Date: Mon, 5 Apr 2021 09:23:23 +0200
Message-ID: <699cb370-17b8-3e72-02fe-1f96d494dfd7@stephans-server.de> (raw)
In-Reply-To: <3269480.1617215050@sss.pgh.pa.us>
References: <9f73e655-14b8-feaf-bd66-c0f506224b9e@stephans-server.de>
	<2919657.1617129981@sss.pgh.pa.us>
	<6ea52e56-b401-7716-f592-a8fdc98df667@stephans-server.de>
	<3269480.1617215050@sss.pgh.pa.us>

Hello Tom,

On 31.03.2021 20:24, Tom Lane wrote:
> Based on nearby threads, it occurs to me to ask whether you have JIT
> enabled, and if so whether turning it off helps.  There seems to be
> a known leak of the code fragments generated by that in some cases.

That's it!

I am quite surprised that a functionality, which is on by default does 
generate such a massive leak and goes sort of undetected.

A single backend was leaking 250MB/hour, with my multiple connections it 
was 2GB. But exactly that happened.

Doing a set jit=off immediately stopped the leak.


You mentioned that this seems to be known. Do you have pointers to the 
relevant bug-tracker/thread? I would like to follow up on this.

I have not measured the impact of jit, but in theory it could bring 
larger performance benefits. So having it enabled sounds like a good 
idea, once it stops leaking.


I tried running Valgrind on postgres but I had not much success with it. 
processes seemed to terminate quite frequently. My last use of Valgrind 
is a while ago and my use-case back then was probably much simpler.

Is it known which queries are leading to a leak? I still have the 
recording of mine, including explain. Would it help to narrow it further 
down to single queries which leak? Or is the JIT re-creating optimized 
code for each slightly modified one without freeing the old ones? So 
re-running the same query would not leak?

https://downloads.osm-tools.org/postgresql-2021-04-03_183913.csv.gz


Stephan







view thread (8+ messages)  latest in thread

Message-ID: <699cb370-17b8-3e72-02fe-1f96d494dfd7@stephans-server.de>
Permalink:  ../699cb370-17b8-3e72-02fe-1f96d494dfd7@stephans-server.de/
Also on:    postgresql.org/message-id/699cb370-17b8-3e72-02fe-1f96d494dfd7@stephans-server.de

 · 

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: pgsql@stephans-server.de, tgl@sss.pgh.pa.us
  Subject: Re: Debugging leaking memory in Postgresql 13.2/Postgis 3.1
  In-Reply-To: <699cb370-17b8-3e72-02fe-1f96d494dfd7@stephans-server.de>
  References: <9f73e655-14b8-feaf-bd66-c0f506224b9e@stephans-server.de> <2919657.1617129981@sss.pgh.pa.us> <6ea52e56-b401-7716-f592-a8fdc98df667@stephans-server.de> <3269480.1617215050@sss.pgh.pa.us> <699cb370-17b8-3e72-02fe-1f96d494dfd7@stephans-server.de>

* 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