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: Tue, 04 Aug 2015 18:22:17 -0400
Message-ID: <3506.1438726937@sss.pgh.pa.us> (raw)
In-Reply-To: <15011.1438717384@sss.pgh.pa.us>
References: <20150731220618.2987.1731@wrigleys.postgresql.org>
<20722.1438402315@sss.pgh.pa.us>
<6977.1438451753@sss.pgh.pa.us>
<OF3C210022.1E6B6368-ON88257E97.0059E2AE-87257E97.005C0096@selinc.com>
<15011.1438717384@sss.pgh.pa.us>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
I wrote:
> But in tuplestore.c, the array elements are just "void *". On a 32-bit
> machine that's small enough that the very first allocation is a standard
> palloc chunk not a separate chunk. So then the allocation overhead *does*
> increase at the first enlargement, and if you're close to exhausting
> work_mem then LACKMEM can happen due to that. The new code that made
> sorting run closer to full memory utilization may have increased the odds
> of this, but it did not create the problem.
> So you need both a 32-bit machine and fairly small work_mem to trigger
> this failure; that explains why I could not reproduce it here (I was
> using a 64-bit machine).
Actually that's not true; the problem can happen on 64-bit as well.
I was thinking that the behavior change occurred at 8K allocation
requests, but actually it happens for requests larger than 8K.
> I think the best fix really is to increase the initial array size
> so that it's at least large enough to force palloc to do what we want.
> As a quick hack you could just s/1024/2048/ in tuplestore_begin_common,
> but what would be more maintainable in the long run is for the memory
> allocation code to export a #define for its "large chunk" threshold,
> and make the initial allocation here depend on that.
If you want to use the "official" patch for this, see
http://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=8bd45a394958c3fd7400654439ef2a1130...
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: <3506.1438726937@sss.pgh.pa.us>
References: <20150731220618.2987.1731@wrigleys.postgresql.org> <20722.1438402315@sss.pgh.pa.us> <6977.1438451753@sss.pgh.pa.us> <OF3C210022.1E6B6368-ON88257E97.0059E2AE-87257E97.005C0096@selinc.com> <15011.1438717384@sss.pgh.pa.us> <3506.1438726937@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