Re: Getting better results from valgrind leak tracking
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andres Freund <andres@anarazel.de>
Cc: Robert Haas <robertmhaas@gmail.com>, pgsql-hackers@lists.postgresql.org
Date: 2021-03-18T02:33:59Z
Lists: pgsql-hackers
Andres Freund <andres@anarazel.de> writes: > On 2021-03-17 21:30:48 -0400, Tom Lane wrote: >> I believe I've just tracked down the cause of that. Those errors >> are (as far as I've seen) only happening in parallel workers, and >> the reason is this gem in RestoreGUCState: ... > Ouch. At least it's a short lived issue rather than something permanently > leaking memory on every SIGHUP... Yeah. This leak is really insignificant in practice, although I'm suspicious that randomly init'ing GUCs like this might have semantic issues that we've not detected yet. >> I've not yet tried to grok the comment that purports to justify it, >> but I fail to see why it'd ever be useful to drop values inherited >> from the postmaster. > I can't really make sense of it either. I think it may be trying to > restore the GUC state to what it would have been in postmaster, > disregarding all the settings that were set as part of PostgresInit() > etc? At least in a non-EXEC_BACKEND build, the most reliable way to reproduce the postmaster's settings is to do nothing whatsoever. And I think the same is true for EXEC_BACKEND, really, because the guc.c subsystem is responsible for restoring what would have been the inherited-via-fork settings. So I'm really not sure what this is on about, and I'm too tired to try to figure it out tonight. In other news, I found that there's a genuine leak in RelationBuildLocalRelation: RelationInitTableAccessMethod was added in a spot where CurrentMemoryContext is CacheMemoryContext, which is bad because it does a syscache lookup that can lead to a table access which can leak some memory. Seems easy to fix though. The plpgsql situation looks like a mess. As a short-term answer, I'm inclined to recommend adding an exclusion that will ignore anything allocated within plpgsql_compile(). Doing better will require a fair amount of rewriting. (Although I suppose we could also consider adding an on_proc_exit callback that runs through and frees all the function cache entries.) regards, tom lane
Commits
-
Improve our support for Valgrind's leak tracking.
- bb049a79d344 19 (unreleased) landed
-
Increment xactCompletionCount during subtransaction abort.
- 90c885cdab8b 14.0 landed
-
Adjust design of per-worker parallel seqscan data struct
- af527705edc3 14.0 landed
-
Don't leak compiled regex(es) when an ispell cache entry is dropped.
- d303849b059c 14.0 landed
- eba939551afe 13.3 landed
- 92bc14a1027d 12.7 landed
- 0b618ddf8bb2 10.17 landed
- 09e961929614 9.6.22 landed
- 099d2914f30b 11.12 landed
-
Don't leak malloc'd error string in libpqrcv_check_conninfo().
- 9bacdf9f536a 14.0 landed
- ba986b7bc5cf 10.17 landed
- 4eca51d44641 12.7 landed
- 20f11ca0dbc2 11.12 landed
- 12354839e874 13.3 landed
-
Don't leak malloc'd strings when a GUC setting is rejected.
- 377b7a83007d 14.0 landed
- fc552f8680a7 12.7 landed
- 7e25217701cc 9.6.22 landed
- 642b0b69b063 13.3 landed
- 5058e95a6ef9 10.17 landed
- 26a3ae06d85c 11.12 landed
-
Don't leak rd_statlist when a relcache entry is dropped.
- 28644fac1073 14.0 landed
- fbcc9fe33c43 12.7 landed
- 967b693eaef1 11.12 landed
- 536836970144 13.3 landed
- 2bed650c4841 10.17 landed
-
Don't run RelationInitTableAccessMethod in a long-lived context.
- 415ffdc2205e 14.0 landed
- ea3989f3496c 13.3 landed
- 1452a0bb87c7 12.7 landed