pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tatsuhito Kasahara <kasahara.tatsuhito@oss.ntt.co.jp>
To: pgsql-bugs@postgresql.org
Subject: memory leaks? using savepoint
Date: Thu, 16 Dec 2010 16:11:14 +0900
Message-ID: <4D09BB92.6080309@oss.ntt.co.jp> (raw)

Hi!

When I tested simple query as following, backend process used much memory
and not freed until the backend was finished.
# This is reproduced on PostgreSQL8.3 (PostgreSQL8.3.6 - PostgreSQL8.3.12)

-------
 BEGIN;
 SAVEPOINT sp0;
 INSERT INTO tbl VALUES (1);
 RELEASE sp0;
 SAVEPOINT sp1;
 INSERT INTO tbl VALUES (1);
 RELEASE sp1;
 (repeats 10k)
 ROLLBACK;
 SELECT pg_sleep(10000);
-------

I think this caused by following fix.
http://archives.postgresql.org/pgsql-committers/2008-12/msg00100.php
http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/tcop/postgres.c?r1=1.560&r2=1.561)

Should "CopySnapshot()" be performed in MessageContext ?
Attached simple pathch to solve it...

Best regards,
-- 
NTT OSS Center
Tatsuhito Kasahara
kasahara.tatsuhito@oss.ntt.co.jp

Attachments:

test20101216.patch (text/plain, 916B) download diff -rcN postgresql-8.3.12/src/backend/tcop/postgres.c postgresql-8.3.12_dev/src/backend/tcop/postgres.c *** postgresql-8.3.12/src/backend/tcop/postgres.c 2010-10-01 22:36:12.000000000 +0900 --- postgresql-8.3.12_dev/src/backend/tcop/postgres.c 2010-12-16 15:46:43.000000000 +0900 *************** *** 914,919 **** --- 914,921 ---- /* * Set up a snapshot if parse analysis/planning will need one. */ + oldcontext = MemoryContextSwitchTo(MessageContext); + if (analyze_requires_snapshot(parsetree)) { mySnapshot = CopySnapshot(GetTransactionSnapshot()); *************** *** 926,932 **** * Switch to appropriate context for constructing querytrees (again, * these must outlive the execution context). */ - oldcontext = MemoryContextSwitchTo(MessageContext); querytree_list = pg_analyze_and_rewrite(parsetree, query_string, NULL, 0); --- 928,933 ----

view thread (9+ messages)  latest in thread

Message-ID: <4D09BB92.6080309@oss.ntt.co.jp>
Permalink:  ../4D09BB92.6080309@oss.ntt.co.jp/
Also on:    postgresql.org/message-id/4D09BB92.6080309@oss.ntt.co.jp

 ·  · 

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: kasahara.tatsuhito@oss.ntt.co.jp
  Subject: Re: memory leaks? using savepoint
  In-Reply-To: <4D09BB92.6080309@oss.ntt.co.jp>
  References: <4D09BB92.6080309@oss.ntt.co.jp>

* 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