pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
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 00:11:55 -0400
Message-ID: <20722.1438402315@sss.pgh.pa.us> (raw)
In-Reply-To: <20150731220618.2987.1731@wrigleys.postgresql.org>
References: <20150731220618.2987.1731@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

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.  So it would fail only if we exhausted allowedMem on
the same tuple that would cause an enlargement of the memtuples[] array,
which would be unusual enough to explain why this isn't terribly
reproducible.

Could you try something like this at the head of grow_memtuples() to
see if it makes things better?

	/* Forget it if we've already maxed out memtuples, per comment above */
	if (!state->growmemtuples)
		return false;
+	/* Forget it if we already exhausted memory */
+	if (LACKMEM(state))
+		return false;


			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



view thread (7+ messages)  latest in thread

Message-ID: <20722.1438402315@sss.pgh.pa.us>
Permalink:  ../20722.1438402315@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/20722.1438402315@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, brent_despain@selinc.com
  Subject: Re: BUG #13530: sort receives "unexpected out-of-memory situation during sort"
  In-Reply-To: <20722.1438402315@sss.pgh.pa.us>
  References: <20150731220618.2987.1731@wrigleys.postgresql.org> <20722.1438402315@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