pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Craig Ringer <ringerc@ringerc.id.au>
Cc: luben karavelov <karavelov@mail.bg>
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #6763: Severe memory leak with arrays and hstore
Date: Fri, 27 Jul 2012 01:47:05 -0400
Message-ID: <25326.1343368025@sss.pgh.pa.us> (raw)
In-Reply-To: <50120966.4030903@ringerc.id.au>
References: <E1SuCw0-0007s2-5D@wrigleys.postgresql.org>
	<5010FD0F.4020400@ringerc.id.au>
	<10398EEF-03DE-405E-B276-06F73ABF9E3A@mail.bg>
	<5011FD5D.3040503@ringerc.id.au>
	<5011FDEE.1010008@ringerc.id.au>
	<50120966.4030903@ringerc.id.au>

Craig Ringer <ringerc@ringerc.id.au> writes:
> OK, it's certainly leaking, but not in the same drastic way I was able 
> to reproduce manually a couple of times earlier. Self-contained test 
> case attached.

Using HEAD with stock parameters, I don't see any significant change in
allocated address space (VSZ): it sits right around 170MB.  The reported
resident set size (RSS) starts from very little and rises to about
140MB, but I think that's just an artifact of the process touching more
and more of the shared-buffers array as it runs.  The actual backend
memory consumption seems to be just a few meg.

I can get it to blow out memory if I set work_mem large enough to
persuade the planner to use hash aggregation (whereupon it tries to run
all the array_agg aggregates in parallel).  However, that requires
work_mem set to a couple of GB, and I don't think it's really a bug when
the backend goes ahead and uses a couple of GB after I told it it could.

It's possible that the OP's problem boiled down to the planner making
a drastic underestimate of the number of GROUP BY groups, which could
mislead it into applying hash aggregation when there's not room; or
if the space used per aggregate was a lot more than the 8K that the
planner assumes when dealing with array_agg.  But neither of those
errors seems to be happening in this example case.

			regards, tom lane



view thread (15+ messages)  latest in thread

Message-ID: <25326.1343368025@sss.pgh.pa.us>
Permalink:  ../25326.1343368025@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/25326.1343368025@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-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, ringerc@ringerc.id.au, karavelov@mail.bg
  Subject: Re: BUG #6763: Severe memory leak with arrays and hstore
  In-Reply-To: <25326.1343368025@sss.pgh.pa.us>
  References: <E1SuCw0-0007s2-5D@wrigleys.postgresql.org> <5010FD0F.4020400@ringerc.id.au> <10398EEF-03DE-405E-B276-06F73ABF9E3A@mail.bg> <5011FD5D.3040503@ringerc.id.au> <5011FDEE.1010008@ringerc.id.au> <50120966.4030903@ringerc.id.au> <25326.1343368025@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