Bug fix. autovacuum.c do_worker_start() associates memory allocations with TopMemoryContext rather than 'Autovacuum start worker (tmp)'
reid.thompson@crunchydata.com
From: Reid Thompson <reid.thompson@crunchydata.com>
To: pgsql-hackers <pgsql-hackers@lists.postgresql.org>
Cc: reid.thompson@crunchydata.com
Date: 2022-08-31T16:10:26Z
Lists: pgsql-hackers
Attachments
- 001-dev-get-dblist-memorycontext.patch (text/x-patch) patch
Hi Hackers, This patch ensures get_database_list() switches back to the memory context in use upon entry rather than returning with TopMemoryContext as the context. This will address memory allocations in autovacuum.c being associated with TopMemoryContext when they should not be. autovacuum.c do_start_worker() with current context 'Autovacuum start worker (tmp)' invokes get_database_list(). Upon return, the current context has been changed to TopMemoryContext by AtCommit_Memory() as part of an internal transaction. Further down in the do_start_worker(), pgstat_fetch_stat_dbentry() is invoked. Previously this didn't pose a issue, however recent changes altered how pgstat_fetch_stat_dbentry() is implemented. The new implementation has a branch utilizing palloc. The patch ensures these allocations are associated with the 'Autovacuum start worker (tmp)' context rather than the TopMemoryContext. Prior to the change, leaving an idle laptop PG instance running just shy of 3 days saw the autovacuum launcher process grow to 42MB with most of that growth in TopMemoryContext due to the palloc allocations issued with autovacuum worker startup. -- Reid Thompson Senior Software Engineer Crunchy Data, Inc. reid.thompson@crunchydata.com www.crunchydata.com -- Reid Thompson Senior Software Engineer Crunchy Data, Inc. reid.thompson@crunchydata.com www.crunchydata.com
Commits
-
Prevent long-term memory leakage in autovacuum launcher.
- 1c1294be716d 16.0 landed
- feec1b2d5af4 14.6 landed
- fd640dbb8674 10.23 landed
- cb9232d166a8 11.18 landed
- 8fc6b9635dd3 12.13 landed
- 45f7152b9b38 13.9 landed
- 0c599e748f2c 15.0 landed