How can I find the source of postgresql per-connection memory leaks?

From: Eric Jensen <ericcj(at)gmail(dot)com>
To: pgsql-performance(at)postgresql(dot)org
Subject: How can I find the source of postgresql per-connection memory leaks?
Date: 2017-01-12 17:08:30
Message-ID: CAB+ZbRXJWZokibM_PrnD6FrmKOJrP1+E6aK-DQWL=ZMQR1CKAg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

I'm using postgresql 9.5.4 on amazon RDS with ~1300 persistent connections
from rails 4.2 with "prepared_statements: false". Over the course of hours
and days, the "Freeable Memory" RDS stat continues to go down indefinitely
but jumps back up to a relatively small working set every time we reconnect
(restart our servers). If we let it go too long, it goes all the way to
zero and the database instance really does start to go into swap and
eventually fail. Subtracting the freeable memory over days from the peaks
when we restart we see that there are 10's of MB per connection on average.

[image: enter image description here]
Digging into the per-pid RSS from enhanced monitoring, we see the same slow
growth on example connection pids but the total RSS seems to just be a
proxy for actual memory usage per connection (
https://www.depesz.com/2012/06/09/how-much-ram-is-postgresql-using/)

[image: enter image description here]

How can I either:

Change the default.postgres9.5 parameters below to avoid unbounded memory
growth per-connection
Determine what queries cause this unbounded growth and change them to
prevent it
Determine what type of buffering/caching is causing this unbounded growth
so that I can use that to do either of the above

[image: enter image description here]

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Joshua D. Drake 2017-01-12 17:18:08 Re: How can I find the source of postgresql per-connection memory leaks?
Previous Message Stephen Frost 2017-01-06 19:43:03 Re: Sort-of replication for reporting purposes