pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Postgresql 9.1.2 - abnormal memory usage
11+ messages / 6 participants
[nested] [flat]

* Postgresql 9.1.2 - abnormal memory usage
@ 2011-12-11 21:15  Jochen Erwied <jochen@pgsql-bugs.erwied.eu>
  0 siblings, 1 reply; 11+ messages in thread

From: Jochen Erwied @ 2011-12-11 21:15 UTC (permalink / raw)
  To: pgsql-bugs

After upgrading from 9.1.1 to 9.1.2, memory usage for some queries 
increased to the amount that the OOM-killer on Linux terminated the server.
Further investigation show the problem to occur under multiple circumstances:

- copying data from an external file into a table with indexes
- creating indexes
- complex queries using row_number() and 'partition over'

There might be other cirumstances, the above are the ones  I could 
reproduce.

Information about the testsystem:

Linux gentoo-test 3.1.5-gentoo #1 SMP Sat Dec 10 22:42:53 CET 2011 i686 Intel(R) Core(TM)2 Duo CPU T8100 @ 2.10GHz GenuineIntel GNU/Linux
PostgreSQL 9.1.2 on i686-pc-linux-gnu, compiled by i686-pc-linux-gnu-gcc (Gentoo 4.4.4-r2 p1.2, pie-0.4.5) 4.4.4, 32-bit

Running in a virtual machine (VMWare Workstation), 2GB of memory, and 512 
MB of swap.

Problem was initially observed on a 64bit-system. Downgrading Postgres from
9.1.2 back to 9.1.1 fixed the problem. The other system is running (after
downgrading):

Linux joker 3.1.1-gentoo #2 SMP Thu Nov 24 22:59:20 CET 2011 x86_64 Intel(R) Xeon(R) CPU 5110 @ 1.60GHz GenuineIntel GNU/Linux
PostgreSQL 9.1.1 on x86_64-pc-linux-gnu, compiled by x86_64-pc-linux-gnu-gcc (Gentoo 4.5.3-r1 p1.0, pie-0.4.5) 4.5.3, 64-bit

Postgres was compiled from source on both machines.

Configuration on the testing machine is mostly unchanged, modified settings 
are:

maintenance_work_mem = 256MB
shared_buffers = 128MB
fsync = off
synchronous_commit = off

The following script can be used to show the behaviour:

create database pgtest;
\c pgtest
create table test(var inet);
insert into test(var) '127.0.0.0'::inet+generate_series(0,256*256*256-1);
create index test_ix on test(var);

The postgres process uses approx. 1000MB during the insert, generating the
index approx. 400MB using Postgres 9.1.1, monitored using top, column VIRT

Same operation with Postgres 9.1.2 uses about the same memory for filling
the table, but generating the index exhausts all available memory, and the
machine slows to a crawl due to swapping.

To me this looks a bit like temporary tables are not correctly used in 9.1.2.

The problem originally was observed with the following tabledefinition and
query:

create table servers_part
  (ip inet not null primary key,
   failcount smallint default -1, 
   lastchange timestamp without time zone default now(),
   cidr smallint default 0);
create index servers_part_fclc on servers_part(failcount,lastchange);

The data for this table contains 2^24 rows, and can be downloaded from
http://www.erwied.eu/~transfer/217.dump.bz2 (116 MB)

The following query shows the same behaviour as index creation (memory 
exhaustion):

SELECT y.ip, y.failcount, y.network
   FROM ( SELECT x.ip, x.failcount, x.network, row_number() OVER (PARTITION BY x.network ORDER BY x.lastchange) AS rc
           FROM ( SELECT servers_part.ip, servers_part.failcount, set_masklen(servers_part.ip::cidr, COALESCE(servers_part.cidr::integer, 8)) AS network, servers_part.lastchange
                   FROM servers_part
                  WHERE servers_part.failcount = 0 AND servers_part.lastchange < '2011-11-11 00:00:00'::timestamp without time zone 
                        OR servers_part.failcount >= 1 AND servers_part.failcount < 5 AND servers_part.lastchange < '2011-12-08 00:00:00'::timestamp without time zone 
                        OR servers_part.failcount >= 5 AND servers_part.failcount < 10 AND servers_part.lastchange < '2011-12-05 00:00:00'::timestamp without time zone 
                        OR servers_part.failcount >= 10 AND servers_part.failcount < 15 AND servers_part.lastchange < '2011-11-28 00:00:00'::timestamp without time zone 
                        OR servers_part.failcount = 15 AND servers_part.lastchange < '2011-10-01 00:00:00'::timestamp without time zone) x) y
  WHERE y.rc <= 128;


-- 
Jochen Erwied     |   home: jochen@erwied.eu     +49-208-38800-18, FAX: -19
Sauerbruchstr. 17 |   work: joe@mbs-software.de  +49-2151-7294-24, FAX: -50
D-45470 Muelheim  | mobile: jochen.erwied@vodafone.de       +49-173-5404164




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

* Re: Postgresql 9.1.2 - abnormal memory usage
@ 2011-12-11 23:45  Andres Freund <andres@anarazel.de>
  parent: Jochen Erwied <jochen@pgsql-bugs.erwied.eu>
  0 siblings, 1 reply; 11+ messages in thread

From: Andres Freund @ 2011-12-11 23:45 UTC (permalink / raw)
  To: pgsql-bugs

Hi,

On Sunday, December 11, 2011 10:15:29 PM Jochen Erwied wrote:
> The following script can be used to show the behaviour:
> 
> create database pgtest;
> \c pgtest
> create table test(var inet);
> insert into test(var) '127.0.0.0'::inet+generate_series(0,256*256*256-1);
> create index test_ix on test(var);
I can reproduce the issue. The memory is being spent at only one place:

TopMemoryContext: 68688 total in 10 blocks; 2736 free (10 chunks); 65952 used
  TopTransactionContext: 8192 total in 1 blocks; 4856 free (0 chunks); 3336 
used
  PortalMemory: 8192 total in 1 blocks; 7888 free (0 chunks); 304 used
    PortalHeapMemory: 15360 total in 4 blocks; 10640 free (17 chunks); 4720 
used
      TupleSort: 6283429096 total in 723 blocks; 1424704 free (0 chunks); 
6282004392 used

Looking.

Andres



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

* Re: Postgresql 9.1.2 - abnormal memory usage
@ 2011-12-12 00:45  Andres Freund <andres@anarazel.de>
  parent: Andres Freund <andres@anarazel.de>
  0 siblings, 2 replies; 11+ messages in thread

From: Andres Freund @ 2011-12-12 00:45 UTC (permalink / raw)
  To: pgsql-bugs; Jochen Erwied <jochen@pgsql-bugs.erwied.eu>

Hi,

On Monday, December 12, 2011 12:45:23 AM Andres Freund wrote:
> On Sunday, December 11, 2011 10:15:29 PM Jochen Erwied wrote:
> > The following script can be used to show the behaviour:
> > 
> > create database pgtest;
> > \c pgtest
> > create table test(var inet);
> > insert into test(var) '127.0.0.0'::inet+generate_series(0,256*256*256-1);
> > create index test_ix on test(var);
> 
> I can reproduce the issue. The memory is being spent at only one place:
> 
> TopMemoryContext: 68688 total in 10 blocks; 2736 free (10 chunks); 65952
> used TopTransactionContext: 8192 total in 1 blocks; 4856 free (0 chunks);
> 3336 used
>   PortalMemory: 8192 total in 1 blocks; 7888 free (0 chunks); 304 used
>     PortalHeapMemory: 15360 total in 4 blocks; 10640 free (17 chunks); 4720
> used
>       TupleSort: 6283429096 total in 723 blocks; 1424704 free (0 chunks);
> 6282004392 used
In 3b8161723c645853021b57330dd2ea0484ec6131 Heikki made DatumGetInetP unpack 
toasted values. Unfortunately the btree support functions for the inet type 
didn't free memory which they have to do in contrast to about everything else.

I fixed a few more functions than strictly necessary but I guess thats ok.


Jochen, could you try the attached patch?

Andres

Attachments:

0001-Release-memory-in-inet-functions.patch (text/x-patch, 4.8K) download From b641f68a96138162935756ed708367e2f162f0a2 Mon Sep 17 00:00:00 2001 From: Andres Freund <andres@anarazel.de> Date: Mon, 12 Dec 2011 01:38:42 +0100 Subject: [PATCH] Release memory in inet functions This is now neccessary because since a recent commit ("Make DatumGetInetP() unpack inet datums") those functions actually allocate memory. Thats not allowed in btree support functions. --- src/backend/utils/adt/network.c | 77 +++++++++++++++++++++++++++++---------- 1 files changed, 58 insertions(+), 19 deletions(-) diff --git a/src/backend/utils/adt/network.c b/src/backend/utils/adt/network.c index e929d6b..7ee2d2b 100644 --- a/src/backend/utils/adt/network.c +++ b/src/backend/utils/adt/network.c @@ -460,7 +460,11 @@ network_cmp(PG_FUNCTION_ARGS) inet *a1 = PG_GETARG_INET_P(0); inet *a2 = PG_GETARG_INET_P(1); - PG_RETURN_INT32(network_cmp_internal(a1, a2)); + int32 r = network_cmp_internal(a1, a2); + + PG_FREE_IF_COPY(a1, 0); + PG_FREE_IF_COPY(a2, 1); + PG_RETURN_INT32(r); } /* @@ -472,7 +476,11 @@ network_lt(PG_FUNCTION_ARGS) inet *a1 = PG_GETARG_INET_P(0); inet *a2 = PG_GETARG_INET_P(1); - PG_RETURN_BOOL(network_cmp_internal(a1, a2) < 0); + bool r = network_cmp_internal(a1, a2) < 0; + + PG_FREE_IF_COPY(a1, 0); + PG_FREE_IF_COPY(a2, 1); + PG_RETURN_BOOL(r); } Datum @@ -481,7 +489,11 @@ network_le(PG_FUNCTION_ARGS) inet *a1 = PG_GETARG_INET_P(0); inet *a2 = PG_GETARG_INET_P(1); - PG_RETURN_BOOL(network_cmp_internal(a1, a2) <= 0); + bool r = network_cmp_internal(a1, a2) <= 0; + + PG_FREE_IF_COPY(a1, 0); + PG_FREE_IF_COPY(a2, 1); + PG_RETURN_BOOL(r); } Datum @@ -490,7 +502,11 @@ network_eq(PG_FUNCTION_ARGS) inet *a1 = PG_GETARG_INET_P(0); inet *a2 = PG_GETARG_INET_P(1); - PG_RETURN_BOOL(network_cmp_internal(a1, a2) == 0); + bool r = network_cmp_internal(a1, a2) == 0; + + PG_FREE_IF_COPY(a1, 0); + PG_FREE_IF_COPY(a2, 1); + PG_RETURN_BOOL(r); } Datum @@ -499,7 +515,11 @@ network_ge(PG_FUNCTION_ARGS) inet *a1 = PG_GETARG_INET_P(0); inet *a2 = PG_GETARG_INET_P(1); - PG_RETURN_BOOL(network_cmp_internal(a1, a2) >= 0); + bool r = network_cmp_internal(a1, a2) >= 0; + + PG_FREE_IF_COPY(a1, 0); + PG_FREE_IF_COPY(a2, 1); + PG_RETURN_BOOL(r); } Datum @@ -508,7 +528,11 @@ network_gt(PG_FUNCTION_ARGS) inet *a1 = PG_GETARG_INET_P(0); inet *a2 = PG_GETARG_INET_P(1); - PG_RETURN_BOOL(network_cmp_internal(a1, a2) > 0); + bool r = network_cmp_internal(a1, a2) > 0; + + PG_FREE_IF_COPY(a1, 0); + PG_FREE_IF_COPY(a2, 1); + PG_RETURN_BOOL(r); } Datum @@ -517,7 +541,11 @@ network_ne(PG_FUNCTION_ARGS) inet *a1 = PG_GETARG_INET_P(0); inet *a2 = PG_GETARG_INET_P(1); - PG_RETURN_BOOL(network_cmp_internal(a1, a2) != 0); + bool r = network_cmp_internal(a1, a2) != 0; + + PG_FREE_IF_COPY(a1, 0); + PG_FREE_IF_COPY(a2, 1); + PG_RETURN_BOOL(r); } /* @@ -541,14 +569,17 @@ network_sub(PG_FUNCTION_ARGS) { inet *a1 = PG_GETARG_INET_P(0); inet *a2 = PG_GETARG_INET_P(1); + bool r = false; if (ip_family(a1) == ip_family(a2)) { - PG_RETURN_BOOL(ip_bits(a1) > ip_bits(a2) - && bitncmp(ip_addr(a1), ip_addr(a2), ip_bits(a2)) == 0); + r = ip_bits(a1) > ip_bits(a2) + && bitncmp(ip_addr(a1), ip_addr(a2), ip_bits(a2)) == 0; } - PG_RETURN_BOOL(false); + PG_FREE_IF_COPY(a1, 0); + PG_FREE_IF_COPY(a2, 1); + PG_RETURN_BOOL(r); } Datum @@ -556,14 +587,17 @@ network_subeq(PG_FUNCTION_ARGS) { inet *a1 = PG_GETARG_INET_P(0); inet *a2 = PG_GETARG_INET_P(1); + bool r = false; if (ip_family(a1) == ip_family(a2)) { - PG_RETURN_BOOL(ip_bits(a1) >= ip_bits(a2) - && bitncmp(ip_addr(a1), ip_addr(a2), ip_bits(a2)) == 0); + r = ip_bits(a1) >= ip_bits(a2) + && bitncmp(ip_addr(a1), ip_addr(a2), ip_bits(a2)) == 0; } - PG_RETURN_BOOL(false); + PG_FREE_IF_COPY(a1, 0); + PG_FREE_IF_COPY(a2, 1); + PG_RETURN_BOOL(r); } Datum @@ -574,11 +608,13 @@ network_sup(PG_FUNCTION_ARGS) if (ip_family(a1) == ip_family(a2)) { - PG_RETURN_BOOL(ip_bits(a1) < ip_bits(a2) - && bitncmp(ip_addr(a1), ip_addr(a2), ip_bits(a1)) == 0); + r = ip_bits(a1) < ip_bits(a2) + && bitncmp(ip_addr(a1), ip_addr(a2), ip_bits(a1)) == 0; } - PG_RETURN_BOOL(false); + PG_FREE_IF_COPY(a1, 0); + PG_FREE_IF_COPY(a2, 1); + PG_RETURN_BOOL(r); } Datum @@ -586,14 +622,17 @@ network_supeq(PG_FUNCTION_ARGS) { inet *a1 = PG_GETARG_INET_P(0); inet *a2 = PG_GETARG_INET_P(1); + bool r = false; if (ip_family(a1) == ip_family(a2)) { - PG_RETURN_BOOL(ip_bits(a1) <= ip_bits(a2) - && bitncmp(ip_addr(a1), ip_addr(a2), ip_bits(a1)) == 0); + r = ip_bits(a1) <= ip_bits(a2) + && bitncmp(ip_addr(a1), ip_addr(a2), ip_bits(a1)) == 0; } - PG_RETURN_BOOL(false); + PG_FREE_IF_COPY(a1, 0); + PG_FREE_IF_COPY(a2, 1); + PG_RETURN_BOOL(r); } /* -- 1.7.6.409.ge7a85.dirty
^ permalink raw reply [nested|flat] 11+ messages in thread

* Re: Postgresql 9.1.2 - abnormal memory usage
@ 2011-12-12 06:26  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Andres Freund <andres@anarazel.de>
  1 sibling, 1 reply; 11+ messages in thread

From: Tom Lane @ 2011-12-12 06:26 UTC (permalink / raw)
  To: Andres Freund <andres@anarazel.de>; +Cc: pgsql-bugs; Jochen Erwied <jochen@pgsql-bugs.erwied.eu>

Andres Freund <andres@anarazel.de> writes:
> In 3b8161723c645853021b57330dd2ea0484ec6131 Heikki made DatumGetInetP unpack 
> toasted values. Unfortunately the btree support functions for the inet type 
> didn't free memory which they have to do in contrast to about everything else.

> I fixed a few more functions than strictly necessary but I guess thats ok.

Seems like the correct fix is to revert these functions to the former
behavior, ie they should be using the PP macros not the unpacking ones.

			regards, tom lane



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

* Re: Postgresql 9.1.2 - abnormal memory usage
@ 2011-12-12 07:04  Jochen Erwied <jochen@pgsql-bugs.erwied.eu>
  parent: Andres Freund <andres@anarazel.de>
  1 sibling, 0 replies; 11+ messages in thread

From: Jochen Erwied @ 2011-12-12 07:04 UTC (permalink / raw)
  To: Andres Freund <andres@anarazel.de>; +Cc: pgsql-bugs

Monday, December 12, 2011, 1:45:42 AM you wrote:

> Jochen, could you try the attached patch?

Patch is missing a variable define for 'r' in network_sup(). Fixed patch 
attached.

Memory usage for insert ~1087MB - no change
Memory usage for index creation ~415MB - fixed.
Memory usage for select ~150MB - no increase, also fixed

The patch works for me, I'll leave the discussion if it's correct way to do
it to the developers :-)


-- 
Jochen Erwied     |   home: jochen@erwied.eu     +49-208-38800-18, FAX: -19
Sauerbruchstr. 17 |   work: joe@mbs-software.de  +49-2151-7294-24, FAX: -50
D-45470 Muelheim  | mobile: jochen.erwied@vodafone.de       +49-173-5404164

Attachments:

0001-Release-memory-in-inet-functions.patch (application/octet-stream, 3.7K) download diff -ru2 a/src/backend/utils/adt/network.c b/src/backend/utils/adt/network.c --- a/src/backend/utils/adt/network.c 2011-12-01 22:47:20.000000000 +0100 +++ b/src/backend/utils/adt/network.c 2011-12-12 07:41:50.672405741 +0100 @@ -461,5 +461,9 @@ inet *a2 = PG_GETARG_INET_P(1); - PG_RETURN_INT32(network_cmp_internal(a1, a2)); + int32 r = network_cmp_internal(a1, a2); + + PG_FREE_IF_COPY(a1, 0); + PG_FREE_IF_COPY(a2, 1); + PG_RETURN_INT32(r); } @@ -473,5 +477,9 @@ inet *a2 = PG_GETARG_INET_P(1); - PG_RETURN_BOOL(network_cmp_internal(a1, a2) < 0); + bool r = network_cmp_internal(a1, a2) < 0; + + PG_FREE_IF_COPY(a1, 0); + PG_FREE_IF_COPY(a2, 1); + PG_RETURN_BOOL(r); } @@ -482,5 +490,9 @@ inet *a2 = PG_GETARG_INET_P(1); - PG_RETURN_BOOL(network_cmp_internal(a1, a2) <= 0); + bool r = network_cmp_internal(a1, a2) <= 0; + + PG_FREE_IF_COPY(a1, 0); + PG_FREE_IF_COPY(a2, 1); + PG_RETURN_BOOL(r); } @@ -491,5 +503,9 @@ inet *a2 = PG_GETARG_INET_P(1); - PG_RETURN_BOOL(network_cmp_internal(a1, a2) == 0); + bool r = network_cmp_internal(a1, a2) == 0; + + PG_FREE_IF_COPY(a1, 0); + PG_FREE_IF_COPY(a2, 1); + PG_RETURN_BOOL(r); } @@ -500,5 +516,9 @@ inet *a2 = PG_GETARG_INET_P(1); - PG_RETURN_BOOL(network_cmp_internal(a1, a2) >= 0); + bool r = network_cmp_internal(a1, a2) >= 0; + + PG_FREE_IF_COPY(a1, 0); + PG_FREE_IF_COPY(a2, 1); + PG_RETURN_BOOL(r); } @@ -509,5 +529,9 @@ inet *a2 = PG_GETARG_INET_P(1); - PG_RETURN_BOOL(network_cmp_internal(a1, a2) > 0); + bool r = network_cmp_internal(a1, a2) > 0; + + PG_FREE_IF_COPY(a1, 0); + PG_FREE_IF_COPY(a2, 1); + PG_RETURN_BOOL(r); } @@ -518,5 +542,9 @@ inet *a2 = PG_GETARG_INET_P(1); - PG_RETURN_BOOL(network_cmp_internal(a1, a2) != 0); + bool r = network_cmp_internal(a1, a2) != 0; + + PG_FREE_IF_COPY(a1, 0); + PG_FREE_IF_COPY(a2, 1); + PG_RETURN_BOOL(r); } @@ -542,12 +570,15 @@ inet *a1 = PG_GETARG_INET_P(0); inet *a2 = PG_GETARG_INET_P(1); + bool r = false; if (ip_family(a1) == ip_family(a2)) { - PG_RETURN_BOOL(ip_bits(a1) > ip_bits(a2) - && bitncmp(ip_addr(a1), ip_addr(a2), ip_bits(a2)) == 0); + r = ip_bits(a1) > ip_bits(a2) + && bitncmp(ip_addr(a1), ip_addr(a2), ip_bits(a2)) == 0; } - PG_RETURN_BOOL(false); + PG_FREE_IF_COPY(a1, 0); + PG_FREE_IF_COPY(a2, 1); + PG_RETURN_BOOL(r); } @@ -557,12 +588,15 @@ inet *a1 = PG_GETARG_INET_P(0); inet *a2 = PG_GETARG_INET_P(1); + bool r = false; if (ip_family(a1) == ip_family(a2)) { - PG_RETURN_BOOL(ip_bits(a1) >= ip_bits(a2) - && bitncmp(ip_addr(a1), ip_addr(a2), ip_bits(a2)) == 0); + r = ip_bits(a1) >= ip_bits(a2) + && bitncmp(ip_addr(a1), ip_addr(a2), ip_bits(a2)) == 0; } - PG_RETURN_BOOL(false); + PG_FREE_IF_COPY(a1, 0); + PG_FREE_IF_COPY(a2, 1); + PG_RETURN_BOOL(r); } @@ -572,12 +606,15 @@ inet *a1 = PG_GETARG_INET_P(0); inet *a2 = PG_GETARG_INET_P(1); + bool r = false; if (ip_family(a1) == ip_family(a2)) { - PG_RETURN_BOOL(ip_bits(a1) < ip_bits(a2) - && bitncmp(ip_addr(a1), ip_addr(a2), ip_bits(a1)) == 0); + r = ip_bits(a1) < ip_bits(a2) + && bitncmp(ip_addr(a1), ip_addr(a2), ip_bits(a1)) == 0; } - PG_RETURN_BOOL(false); + PG_FREE_IF_COPY(a1, 0); + PG_FREE_IF_COPY(a2, 1); + PG_RETURN_BOOL(r); } @@ -587,12 +624,15 @@ inet *a1 = PG_GETARG_INET_P(0); inet *a2 = PG_GETARG_INET_P(1); + bool r = false; if (ip_family(a1) == ip_family(a2)) { - PG_RETURN_BOOL(ip_bits(a1) <= ip_bits(a2) - && bitncmp(ip_addr(a1), ip_addr(a2), ip_bits(a1)) == 0); + r = ip_bits(a1) <= ip_bits(a2) + && bitncmp(ip_addr(a1), ip_addr(a2), ip_bits(a1)) == 0; } - PG_RETURN_BOOL(false); + PG_FREE_IF_COPY(a1, 0); + PG_FREE_IF_COPY(a2, 1); + PG_RETURN_BOOL(r); }
^ permalink raw reply [nested|flat] 11+ messages in thread

* Re: Postgresql 9.1.2 - abnormal memory usage
@ 2011-12-12 08:29  Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 11+ messages in thread

From: Heikki Linnakangas @ 2011-12-12 08:29 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Andres Freund <andres@anarazel.de>; pgsql-bugs; Jochen Erwied <jochen@pgsql-bugs.erwied.eu>

On 12.12.2011 08:26, Tom Lane wrote:
> Andres Freund<andres@anarazel.de>  writes:
>> In 3b8161723c645853021b57330dd2ea0484ec6131 Heikki made DatumGetInetP unpack
>> toasted values. Unfortunately the btree support functions for the inet type
>> didn't free memory which they have to do in contrast to about everything else.
>
>> I fixed a few more functions than strictly necessary but I guess thats ok.
>
> Seems like the correct fix is to revert these functions to the former
> behavior, ie they should be using the PP macros not the unpacking ones.

Agreed, there's no need to unpack here. Fixed, thanks for the report!

-- 
   Heikki Linnakangas
   EnterpriseDB   http://www.enterprisedb.com



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

* Re: Postgresql 9.1.2 - abnormal memory usage
@ 2011-12-12 11:16  Matteo Beccati <php@beccati.com>
  parent: Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
  0 siblings, 1 reply; 11+ messages in thread

From: Matteo Beccati @ 2011-12-12 11:16 UTC (permalink / raw)
  To: pgsql-bugs

Hi Heikki,

On 12/12/2011 09:29, Heikki Linnakangas wrote:
> On 12.12.2011 08:26, Tom Lane wrote:
>> Andres Freund<andres@anarazel.de>  writes:
>>> In 3b8161723c645853021b57330dd2ea0484ec6131 Heikki made DatumGetInetP
>>> unpack
>>> toasted values. Unfortunately the btree support functions for the
>>> inet type
>>> didn't free memory which they have to do in contrast to about
>>> everything else.
>>
>>> I fixed a few more functions than strictly necessary but I guess
>>> thats ok.
>>
>> Seems like the correct fix is to revert these functions to the former
>> behavior, ie they should be using the PP macros not the unpacking ones.
> 
> Agreed, there's no need to unpack here. Fixed, thanks for the report!

Just to clarify, am I correct assuming that the issue does not affect
tables which have non-indexed inet fields?


Cheers
-- 
Matteo Beccati

Development & Consulting - http://www.beccati.com/



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

* Re: Postgresql 9.1.2 - abnormal memory usage
@ 2011-12-12 11:33  Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
  parent: Matteo Beccati <php@beccati.com>
  0 siblings, 1 reply; 11+ messages in thread

From: Heikki Linnakangas @ 2011-12-12 11:33 UTC (permalink / raw)
  To: Matteo Beccati <php@beccati.com>; +Cc: pgsql-bugs

On 12.12.2011 13:16, Matteo Beccati wrote:
> On 12/12/2011 09:29, Heikki Linnakangas wrote:
>> On 12.12.2011 08:26, Tom Lane wrote:
>>> Andres Freund<andres@anarazel.de>   writes:
>>>> In 3b8161723c645853021b57330dd2ea0484ec6131 Heikki made DatumGetInetP
>>>> unpack
>>>> toasted values. Unfortunately the btree support functions for the
>>>> inet type
>>>> didn't free memory which they have to do in contrast to about
>>>> everything else.
>>>
>>>> I fixed a few more functions than strictly necessary but I guess
>>>> thats ok.
>>>
>>> Seems like the correct fix is to revert these functions to the former
>>> behavior, ie they should be using the PP macros not the unpacking ones.
>>
>> Agreed, there's no need to unpack here. Fixed, thanks for the report!
>
> Just to clarify, am I correct assuming that the issue does not affect
> tables which have non-indexed inet fields?

Hmm, I think it might also affect queries that do large merge joins on 
inet fields. Not sure about that. In any case, it's a memory leak that 
gets cleared at the end of statement, so it can only become a problem 
when dealing with large data sets.

-- 
   Heikki Linnakangas
   EnterpriseDB   http://www.enterprisedb.com



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

* Re: Postgresql 9.1.2 - abnormal memory usage
@ 2011-12-12 11:50  Jochen Erwied <jochen@pgsql-bugs.erwied.eu>
  parent: Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
  0 siblings, 1 reply; 11+ messages in thread

From: Jochen Erwied @ 2011-12-12 11:50 UTC (permalink / raw)
  To: pgsql-bugs

Monday, December 12, 2011, 12:33:03 PM you wrote:

> On 12.12.2011 13:16, Matteo Beccati wrote:

>> Just to clarify, am I correct assuming that the issue does not affect
>> tables which have non-indexed inet fields?

> Hmm, I think it might also affect queries that do large merge joins on 
> inet fields. Not sure about that. In any case, it's a memory leak that 
> gets cleared at the end of statement, so it can only become a problem 
> when dealing with large data sets.

The second test case I originally sent uses inet-functions in a complicated
query, and it also shows the described behaviour. 

So the problem is not limited to indexes, but also will appear in queries!

-- 
Jochen Erwied     |   home: jochen@erwied.eu     +49-208-38800-18, FAX: -19
Sauerbruchstr. 17 |   work: joe@mbs-software.de  +49-2151-7294-24, FAX: -50
D-45470 Muelheim  | mobile: jochen.erwied@vodafone.de       +49-173-5404164




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

* Re: Postgresql 9.1.2 - abnormal memory usage
@ 2011-12-16 12:50  Havasvölgyi Ottó <havasvolgyi.otto@gmail.com>
  parent: Jochen Erwied <jochen@pgsql-bugs.erwied.eu>
  0 siblings, 1 reply; 11+ messages in thread

From: Havasvölgyi Ottó @ 2011-12-16 12:50 UTC (permalink / raw)
  To: pgsql-bugs

Hi,

A simple query "insert into mytable default values" on a single
serial-column table also leaks. It can also produced by pgbench.  On
Windows and Linux too.

Best regards,
Otto


2011/12/12 Jochen Erwied <jochen@pgsql-bugs.erwied.eu>

> Monday, December 12, 2011, 12:33:03 PM you wrote:
>
> > On 12.12.2011 13:16, Matteo Beccati wrote:
>
> >> Just to clarify, am I correct assuming that the issue does not affect
> >> tables which have non-indexed inet fields?
>
> > Hmm, I think it might also affect queries that do large merge joins on
> > inet fields. Not sure about that. In any case, it's a memory leak that
> > gets cleared at the end of statement, so it can only become a problem
> > when dealing with large data sets.
>
> The second test case I originally sent uses inet-functions in a complicated
> query, and it also shows the described behaviour.
>
> So the problem is not limited to indexes, but also will appear in queries!
>
> --
> Jochen Erwied     |   home: jochen@erwied.eu     +49-208-38800-18, FAX:
> -19
> Sauerbruchstr. 17 |   work: joe@mbs-software.de  +49-2151-7294-24, FAX:
> -50
> D-45470 Muelheim  | mobile: jochen.erwied@vodafone.de
> +49-173-5404164
>
>
> --
> Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-bugs
>

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

* Re: Postgresql 9.1.2 - abnormal memory usage
@ 2011-12-22 15:03  Andres Freund <andres@anarazel.de>
  parent: Havasvölgyi Ottó <havasvolgyi.otto@gmail.com>
  0 siblings, 0 replies; 11+ messages in thread

From: Andres Freund @ 2011-12-22 15:03 UTC (permalink / raw)
  To: pgsql-bugs; +Cc: Havasvölgyi Ottó <havasvolgyi.otto@gmail.com>

Hi,

On Friday, December 16, 2011 01:50:03 PM Havasvölgyi Ottó wrote:
> A simple query "insert into mytable default values" on a single
> serial-column table also leaks. It can also produced by pgbench.  On
> Windows and Linux too.
Youve mentioned that in several threads now. If you really think that you have 
discovered a memory leak with a simple scenario as that could you please open 
a new bugreport on report your findings there instead of hiding it deep in 
other threads.

Thanks,

Andres



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


end of thread, other threads:[~2011-12-22 15:03 UTC | newest]

Thread overview: 11+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-12-11 21:15 Postgresql 9.1.2 - abnormal memory usage Jochen Erwied <jochen@pgsql-bugs.erwied.eu>
2011-12-11 23:45 ` Andres Freund <andres@anarazel.de>
2011-12-12 00:45   ` Andres Freund <andres@anarazel.de>
2011-12-12 06:26     ` Tom Lane <tgl@sss.pgh.pa.us>
2011-12-12 08:29       ` Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
2011-12-12 11:16         ` Matteo Beccati <php@beccati.com>
2011-12-12 11:33           ` Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
2011-12-12 11:50             ` Jochen Erwied <jochen@pgsql-bugs.erwied.eu>
2011-12-16 12:50               ` Havasvölgyi Ottó <havasvolgyi.otto@gmail.com>
2011-12-22 15:03                 ` Andres Freund <andres@anarazel.de>
2011-12-12 07:04     ` Jochen Erwied <jochen@pgsql-bugs.erwied.eu>

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