Skip to content

Commit 1acf105

Browse files
committed
Fix temporary memory leak in system table index scans
Commit 811af97 introduced palloc() calls into systable_beginscan() and systable_beginscan_ordered(). But there was no pfree(), as is the usual style. It turns out that an ANALYZE of a partitioned table can invoke many thousand system table index scans, and this memory is not cleaned up until the end of the command, so this can temporarily leak quite a bit of memory. Maybe there are improvements to be made at a higher level about this, but for now, insert a couple of corresponding pfree() calls to fix this particular issue. Reported-by: Justin Pryzby <pryzby@telsasoft.com> Discussion: https://www.postgresql.org/message-id/Z0XTfIq5xUtbkiIh@pryzbyj2023
1 parent 1ba0782 commit 1acf105

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/backend/access/index/genam.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,8 @@ systable_beginscan(Relation heapRelation,
449449
snapshot, nkeys, 0);
450450
index_rescan(sysscan->iscan, idxkey, nkeys, NULL, 0);
451451
sysscan->scan = NULL;
452+
453+
pfree(idxkey);
452454
}
453455
else
454456
{
@@ -713,6 +715,8 @@ systable_beginscan_ordered(Relation heapRelation,
713715
index_rescan(sysscan->iscan, idxkey, nkeys, NULL, 0);
714716
sysscan->scan = NULL;
715717

718+
pfree(idxkey);
719+
716720
/*
717721
* If CheckXidAlive is set then set a flag to indicate that system table
718722
* scan is in-progress. See detailed comments in xact.c where these

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy