pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andres Freund <andres@anarazel.de>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix memory leak and inefficiency in CREATE DATABASE ... STRATEGY
Date: Wed, 22 Mar 2023 17:03:53 +0000
Message-ID: <E1pf1sO-004rGU-Nb@gemulon.postgresql.org> (raw)

Fix memory leak and inefficiency in CREATE DATABASE ... STRATEGY WAL_LOG

RelationCopyStorageUsingBuffer() did not free the strategies used to access
the source / target relation. They memory was released at the end of the
transaction, but when using a template database with a lot of relations, the
temporary leak can become big prohibitively big.

RelationCopyStorageUsingBuffer() acquired the buffer for the target relation
with RBM_NORMAL, therefore requiring a read of a block guaranteed to be
zero. Use RBM_ZERO_AND_LOCK instead.

Reviewed-by: Robert Haas <robertmhaas@gmail.com>
Discussion: https://postgr.es/m/20230321070113.o2vqqxogjykwgfrr@awork3.anarazel.de
Backpatch: 15-, where STRATEGY WAL_LOG was introduced

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/5df319f3d55d09fadb4f7e4b58c5b476a3aeceb4

Modified Files
--------------
src/backend/storage/buffer/bufmgr.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)



view thread (2+ messages)  latest in thread

Message-ID: <E1pf1sO-004rGU-Nb@gemulon.postgresql.org>
Permalink:  ../E1pf1sO-004rGU-Nb@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1pf1sO-004rGU-Nb@gemulon.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 using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: andres@anarazel.de, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Fix memory leak and inefficiency in CREATE DATABASE ... STRATEGY
  In-Reply-To: <E1pf1sO-004rGU-Nb@gemulon.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