pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
memory leak in postgresql
3+ messages / 2 participants
[nested] [flat]

* memory leak in postgresql
@ 2011-10-11 19:23 Pavel Stehule <pavel.stehule@gmail.com>
  2011-10-11 19:49 ` Re: memory leak in postgresql Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 3+ messages in thread

From: Pavel Stehule @ 2011-10-11 19:23 UTC (permalink / raw)
  To: pgsql-bugs

Hello

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

Regards

Pavel Stehule



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: memory leak in postgresql
  2011-10-11 19:23 memory leak in postgresql Pavel Stehule <pavel.stehule@gmail.com>
@ 2011-10-11 19:49 ` Tom Lane <tgl@sss.pgh.pa.us>
  2011-10-11 20:03   ` Re: memory leak in postgresql Pavel Stehule <pavel.stehule@gmail.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Tom Lane @ 2011-10-11 19:49 UTC (permalink / raw)
  To: Pavel Stehule <pavel.stehule@gmail.com>; +Cc: pgsql-bugs

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



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: memory leak in postgresql
  2011-10-11 19:23 memory leak in postgresql Pavel Stehule <pavel.stehule@gmail.com>
  2011-10-11 19:49 ` Re: memory leak in postgresql Tom Lane <tgl@sss.pgh.pa.us>
@ 2011-10-11 20:03   ` Pavel Stehule <pavel.stehule@gmail.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Pavel Stehule @ 2011-10-11 20:03 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-bugs

2011/10/11 Tom Lane <tgl@sss.pgh.pa.us>:
> 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.

ok

On other hand - is necessary to hold a locks for dropped temporary tables?

Regards

Pavel

>
>                        regards, tom lane
>



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2011-10-11 20:03 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-10-11 19:23 memory leak in postgresql Pavel Stehule <pavel.stehule@gmail.com>
2011-10-11 19:49 ` Tom Lane <tgl@sss.pgh.pa.us>
2011-10-11 20:03   ` Pavel Stehule <pavel.stehule@gmail.com>

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