From: | Andres Freund <andres(at)anarazel(dot)de> |
---|---|
To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
Subject: | pgsql: Fix memory leak and inefficiency in CREATE DATABASE ... STRATEGY |
Date: | 2023-03-22 17:03:53 |
Message-ID: | E1pf1sO-004rGV-O8@gemulon.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
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(at)gmail(dot)com>
Discussion: https://postgr.es/m/20230321070113.o2vqqxogjykwgfrr@awork3.anarazel.de
Backpatch: 15-, where STRATEGY WAL_LOG was introduced
Branch
------
REL_15_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/560bb56c6eba5da7917e67783d46f0d5ca30e89a
Modified Files
--------------
src/backend/storage/buffer/bufmgr.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2023-03-22 17:49:13 | pgsql: Add "-c name=value" switch to initdb. |
Previous Message | Robert Haas | 2023-03-22 13:17:12 | pgsql: Teach verify_heapam() to validate update chains within a page. |