Re: Memory Leak executing small queries without closing the connection - FreeBSD - Mailing list pgsql-general

From Bill Moran
Subject Re: Memory Leak executing small queries without closing the connection - FreeBSD
Date
Msg-id 20151213202718.a3ba03b0a87bc616b82b762a@potentialtech.com
Whole thread Raw
In response to Re: Memory Leak executing small queries without closing the connection - FreeBSD  (Gerhard Wiesinger <lists@wiesinger.com>)
List pgsql-general
On Sun, 13 Dec 2015 22:23:19 +0100
Gerhard Wiesinger <lists@wiesinger.com> wrote:

> On 13.12.2015 21:14, Bill Moran wrote:
> > Wait ... this is a combined HTTP/Postgres server? You didn't mention that
> > earlier, and it's kind of important.
> >
> > What evidence do you have that Postgres is actually the part of
> > this system running out of memory?
>
> For me the complete picture doesn't look consistent.

That's because you haven't gathered enough of the right type of information.

> > I don't see any such evidence in any of
> > your emails, and (based on experience) I find it pretty likely that whatever
> > is running under node is doing something in a horrifically memory-inefficient
> > manner. Since you mention that you see nothing in the PG logs, that makes it
> > even more likely (to me) that you're looking entirely in the wrong place.
> >
> > I'd be willing to bet a steak dinner that if you put the web server on a
> > different server than the DB, that the memory problems would follow the
> > web server and not the DB server.
>
> Changes in config:
> track_activity_query_size = 102400
> work_mem = 100MB
>
> Ok, we restarted PostgreSQL and had it stopped for seconds, and logged
> top every second:
>
> When PostgreSQL was down nearly all memory was freed, looks good to me.
> So it is likely that node and other processes are not the cause.
> Mem: 742M Active, 358M Inact, 1420M Wired, 21G Cache, 871M Buf, 8110M Free
> Swap: 512M Total, 477M Used, 35M Free, 93% Inuse
>
> When PostgreSQL restarted, Inactive was growing fast (~1min):
> Mem: 7998M Active, 18G Inact, 2763M Wired, 1766M Cache, 1889M Buf, 1041M
> Free
> Swap: 512M Total, 472M Used, 41M Free, 92% Inuse
>
> After some few minutes we are back again at the same situation:
> Mem: 8073M Active, 20G Inact, 2527M Wired, 817M Cache, 1677M Buf, 268M Free
> Swap: 512M Total, 472M Used, 41M Free, 92% Inuse
>
> The steak dinner is mine :-) Donating to the PostgreSQL community :-)

Based on the fact that the inactive memory increased? Your understanding
of inactive memory in FreeBSD is incorrect. Those pages are probably DB
pages that the OS is keeping in inactive memory because Postgres requests
them over and over, which is what the OS is supposed to do to ensure the
best performance. Are you seeing any out of swap space errors? Even if
you are, you still haven't determined if the problem is the result of
Postgres or the node.js stuff you have running. I don't know what node.js
might be caching on the client side ... do you?

No. Until you can actually report back something other than wild
speculation, I'll keep that steak dinner for myself. Besides, that bet
was based on you putting the PG server on seperate hardware from the
web server, which you didn't do.

--
Bill Moran


pgsql-general by date:

Previous
From: John R Pierce
Date:
Subject: Re: Postgre Fails To Start in Multi-User Mode
Next
From: Peter Brady
Date:
Subject: Re: [SOLVED] Postgre Fails To Start in Multi-User Mode