Re: BUG #13530: sort receives "unexpected out-of-memory situation during sort"

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: brent_despain(at)selinc(dot)com
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #13530: sort receives "unexpected out-of-memory situation during sort"
Date: 2015-08-01 04:11:55
Message-ID: 20722.1438402315@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

brent_despain(at)selinc(dot)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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Peter J. Holzer 2015-08-01 16:04:30 Re: 9.5alpha1: Partial index not used
Previous Message Tom Lane 2015-08-01 00:03:41 Re: 9.5alpha1: Partial index not used