From: Tom Lane <tgl@sss.pgh.pa.us>
To: Pavel Stehule <pavel.stehule@gmail.com>
Cc: pgsql-bugs@postgresql.org
Subject: Re: memory leak in postgresql
Date: Tue, 11 Oct 2011 15:49:24 -0400
Message-ID: <2806.1318362564@sss.pgh.pa.us> (raw)
In-Reply-To: <CAFj8pRA_2GLDy_WLCdzx_KmJ2f-s0enxSZ1nO9+mN5xtYV6Vxg@mail.gmail.com>
References: <CAFj8pRA_2GLDy_WLCdzx_KmJ2f-s0enxSZ1nO9+mN5xtYV6Vxg@mail.gmail.com>
Pavel Stehule <pavel.stehule@gmail.com> 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
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, pavel.stehule@gmail.com
Subject: Re: memory leak in postgresql
In-Reply-To: <2806.1318362564@sss.pgh.pa.us>
References: <CAFj8pRA_2GLDy_WLCdzx_KmJ2f-s0enxSZ1nO9+mN5xtYV6Vxg@mail.gmail.com> <2806.1318362564@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