From: Tom Lane <tgl@sss.pgh.pa.us>
To: brent_despain@selinc.com
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #13530: sort receives "unexpected out-of-memory situation during sort"
Date: Sat, 01 Aug 2015 13:55:53 -0400
Message-ID: <6977.1438451753@sss.pgh.pa.us> (raw)
In-Reply-To: <20722.1438402315@sss.pgh.pa.us>
References: <20150731220618.2987.1731@wrigleys.postgresql.org>
<20722.1438402315@sss.pgh.pa.us>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
I wrote:
> brent_despain@selinc.com writes:
>> We are occasionally receiving "unexpected out-of-memory situation during
>> sort".
> Hmm. Looking at the code here, it suddenly strikes me that it's assuming
> that LACKMEM() wasn't true to begin with, and that this is not guaranteed,
> because we adjust the memory consumption counter *before* we call
> puttuple_common.
In the light of day that theory doesn't hold up, because if LACKMEM
were true on entry (ie, availMem < 0) then we'd compute a grow_ratio
less than one, so that the "Must enlarge array by at least one element"
check would trigger, and we'd never get to the code that's failing.
Another idea that occurred to me is that the "memory chunk overhead won't
increase" assumption could fail if sizeof(SortTuple) weren't a multiple of
MAXALIGN (because repalloc internally rounds the request up to a MAXALIGN
boundary) but that doesn't seem plausible either. I'd expect that struct
to be 16 bytes on 32-bit or 24 bytes on 64-bit, so it should be maxaligned
on any hardware I know about.
So I'm about out of ideas. Could you modify your copy of the code to
log interesting details when you get this error, like the old and new
memtupsize and chunk space measurements? That might give us a clue
what's the problem.
regards, tom lane
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
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, brent_despain@selinc.com
Subject: Re: BUG #13530: sort receives "unexpected out-of-memory situation during sort"
In-Reply-To: <6977.1438451753@sss.pgh.pa.us>
References: <20150731220618.2987.1731@wrigleys.postgresql.org> <20722.1438402315@sss.pgh.pa.us> <6977.1438451753@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