Content-Length: 261546 | pFad | http://github.com/postgrespro/postgres/commit/1c1294be716d96e804aadafc249fcbfa8367621d

62 Prevent long-term memory leakage in autovacuum launcher. · postgrespro/postgres@1c1294b · GitHub
Skip to content

Commit 1c1294b

Browse files
committed
Prevent long-term memory leakage in autovacuum launcher.
get_database_list() failed to restore the caller's memory context, instead leaving current context set to TopMemoryContext which is how CommitTransactionCommand() leaves it. The callers both think they are using short-lived contexts, for the express purpose of not having to worry about cleaning up individual allocations. The net effect therefore is that supposedly short-lived allocations could accumulate indefinitely in the launcher's TopMemoryContext. Although this has been broken for a long time, it seems we didn't have any obvious memory leak here until v15's rearrangement of the stats logic. I (tgl) am not entirely convinced that there's no other leak at all, though, and we're surely at risk of adding one in future back-patched fixes. So back-patch to all supported branches, even though this may be only a latent bug in pre-v15. Reid Thompson Discussion: https://postgr.es/m/972a4e12b68b0f96db514777a150ceef7dcd2e0f.camel@crunchydata.com
1 parent c3ffa73 commit 1c1294b

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/backend/postmaster/autovacuum.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1941,6 +1941,9 @@ get_database_list(void)
19411941

19421942
CommitTransactionCommand();
19431943

1944+
/* Be sure to restore caller's memory context */
1945+
MemoryContextSwitchTo(resultcxt);
1946+
19441947
return dblist;
19451948
}
19461949

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/postgrespro/postgres/commit/1c1294be716d96e804aadafc249fcbfa8367621d

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy