pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: chad.wagner@gmail.com
To: pgsql-bugs@postgresql.org
Subject: BUG #8279: Apparent memory leak with use of INTO STRICT in plpgsql?
Date: Thu, 04 Jul 2013 01:58:21 +0000
Message-ID: <E1UuYoP-0002hX-FV@wrigleys.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

The following bug has been logged on the website:

Bug reference:      8279
Logged by:          Chad
Email address:      chad.wagner@gmail.com
PostgreSQL version: 9.2.4
Operating system:   Ubuntu 10.04
Description:        

If I use the "SELECT ... INTO STRICT" clause with plpgsql it appears to leak
memory, until I disconnect my session and the backend dies.  If I remove the
"INTO STRICT" clause then there is no apparent memory leak.


Below is a test case to reproduce on 9.2.4, and the pmap diff of
before/after on the backend process.


Pmap on backend process (diff of before/after), about a 400MB leak:
inline patch 1: x2.out (+4/-0 lines) download inline-1.patch--- x1.out 2013-07-03 21:50:02.472438435 -0400 +++ x2.out 2013-07-03 21:51:02.462435759 -0400 @@ -1,5 +1,9 @@ 11945: postgres: wagnerch wagnerch [local] idle Address Kbytes RSS Anon Locked Mode Mapping +00007f4aae074000 148 - - - r-x-- plpgsql.so +00007f4aae099000 2048 - - - ----- plpgsql.so +00007f4aae299000 8 - - - r---- plpgsql.so +00007f4aae29b000 4 - - - rw--- plpgsql.so 00007f4aae29c000 252 - - - r---- LC_CTYPE 00007f4aae2db000 560320 - - - rw-s- [ shmid=0xa9c8000
] 00007f4ad060b000 48 - - - r-x-- libnss_files-2.11.1.so @@ -129,9 +133,9 @@ 00007f4ad4c36000 116 - - - r---- postgres 00007f4ad4c53000 52 - - - rw--- postgres 00007f4ad4c60000 364 - - - rw--- [ anon ] -00007f4ad5f8b000 1192 - - - rw--- [ anon ] +00007f4ad5f8b000 415820 - - - rw--- [ anon ] 00007ffff3396000 144 - - - rw--- [ stack ] 00007ffff33c6000 4 - - - r-x-- [ anon ] ffffffffff600000 4 - - - r-x-- [ anon ] ---------------- ------ ------ ------ ------ -total kB 632108 - - - +total kB 1048944 - - - Test case: /* CREATE TABLE head_tb AS SELECT generate_series (1, 30) AS id; CREATE TABLE det_tb AS SELECT a.a header_id, b.b detail_id, rpad ('X', 1000, 'X') AS data FROM generate_series (1,30) AS a, generate_series (1, 50000) AS b; CREATE INDEX det_tb_n1 ON det_tb (header_id); CREATE UNIQUE INDEX det_tb_u1 ON det_tb (header_id, detail_id); */ DO LANGUAGE plpgsql $$ DECLARE l_head_rec RECORD; l_det_rec RECORD; l_next_det_rec RECORD; BEGIN FOR l_head_rec IN SELECT id, LEAD (id) OVER ( ORDER BY id RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) next_id FROM head_tb ORDER BY id LOOP FOR l_det_rec IN SELECT * FROM det_tb WHERE header_id = l_head_rec.id LOOP BEGIN SELECT * INTO STRICT l_next_det_rec FROM det_tb WHERE detail_id = l_det_rec.detail_id AND header_id = l_head_rec.next_id; EXCEPTION WHEN NO_DATA_FOUND THEN NULL; END; END LOOP; END LOOP; END; $$; -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs

Message-ID: <E1UuYoP-0002hX-FV@wrigleys.postgresql.org>
Permalink:  ../E1UuYoP-0002hX-FV@wrigleys.postgresql.org/
Also on:    postgresql.org/message-id/E1UuYoP-0002hX-FV@wrigleys.postgresql.org

 ·  · 

reply

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: chad.wagner@gmail.com
  Subject: Re: BUG #8279: Apparent memory leak with use of INTO STRICT in plpgsql?
  In-Reply-To: <E1UuYoP-0002hX-FV@wrigleys.postgresql.org>
  References: <E1UuYoP-0002hX-FV@wrigleys.postgresql.org>

* 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