Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 42E6DB5DBD8 for ; Tue, 11 Oct 2011 16:49:35 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 19526-01 for ; Tue, 11 Oct 2011 19:49:24 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id AE4E6B5DBD6 for ; Tue, 11 Oct 2011 16:49:24 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id p9BJnOqB002807; Tue, 11 Oct 2011 15:49:24 -0400 (EDT) To: Pavel Stehule cc: pgsql-bugs@postgresql.org Subject: Re: memory leak in postgresql In-reply-to: References: Comments: In-reply-to Pavel Stehule message dated "Tue, 11 Oct 2011 21:23:15 +0200" Date: Tue, 11 Oct 2011 15:49:24 -0400 Message-ID: <2806.1318362564@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.404 tagged_above=-5 required=5 tests=BAYES_00=-1.9, RP_MATCHES_RCVD=-0.504 X-Spam-Level: X-Archive-Number: 201110/85 X-Sequence-Number: 31355 Pavel Stehule writes: > I found a following issue (tested on PostgreSQL 9.2) > CREATE OR REPLACE FUNCTION public.setfield(a anyelement, text, text) > RETURNS anyelement > LANGUAGE plpgsql > AS $function$ > begin > create temp table aux as select $1.*; > execute 'update aux set ' || quote_ident($2) || ' = ' || quote_literal($3); > select into $1 * from aux; > drop table aux; > return $1; > end; > $function$ > create type mypoint as (a int, b int); > create table omega(p mypoint); > insert into omega select mypoint '(10,20)' from generate_series(1,100000); > update omega set p = setfield(p, 'a', '20'); > WARNING: out of shared memory > CONTEXT: SQL statement "create temp table aux as select $1.*" > PL/pgSQL function "setfield" line 3 at SQL statement > ERROR: out of shared memory > HINT: You might need to increase max_locks_per_transaction. > CONTEXT: SQL statement "create temp table aux as select $1.*" > PL/pgSQL function "setfield" line 3 at SQL statement This is not a memory leak, this is a "your transaction is holding too many locks" problem (namely, one lock for each transient table). Please follow the advice given in the error message. regards, tom lane