Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZLMLF-0004rq-RS for pgsql-bugs@arkaria.postgresql.org; Sat, 01 Aug 2015 02:16:05 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZLMLF-0006f2-Cm for pgsql-bugs@arkaria.postgresql.org; Sat, 01 Aug 2015 02:16:05 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZLISN-0007fc-2C for pgsql-bugs@postgresql.org; Fri, 31 Jul 2015 22:07:11 +0000 Received: from wrigleys.postgresql.org ([204.145.124.246]) by magus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1ZLISH-00054s-P4 for pgsql-bugs@postgresql.org; Fri, 31 Jul 2015 22:07:08 +0000 MIME-Version: 1.0 Subject: BUG #13530: sort receives "unexpected out-of-memory situation during sort" To: pgsql-bugs@postgresql.org From: brent_despain@selinc.com Date: Fri, 31 Jul 2015 22:06:18 +0000 Message-ID: <20150731220618.2987.1731@wrigleys.postgresql.org> X-Pg-Spam-Score: -1.2 (-) Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org The following bug has been logged on the website: Bug reference: 13530 Logged by: Brent DeSpain Email address: brent_despain@selinc.com PostgreSQL version: 9.3.4 Operating system: Ubuntu Description: We are occasionally receiving "unexpected out-of-memory situation during sort". This happens mostly when we are running our version of pg_dump. It returns the data from each table in primary key order. The amount of data in each table is relatively small (< 100k in the larges tables). The error is not predictably reproducible. work_mem is set to 1536kB. Setting work_mem back to default seems to decrease the occurrence of the error. We did not have the problem reported in PostgreSQL 8.3.x. << Speculation >> I have not contributed before to PostgreSQL so take this with a grain of salt. I reviewed the code and found that the error comes from grow_memtuples(Tuplesortstate *state) in src\backend\utils\sort\tuplesort.c or src\backend\utils\sort\tuplestore.c. The problem seems to come from the new 9.x algorithm to grow memtupsize by grow_ratio when doubling memtupsize is no longer possible. It seems if we get really close to availMem the addition of the chunk header returned by GetMemoryChunkSpace() pushes us over the edge and LACKMEM() becomes TRUE. This is my speculation. -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs