Hi, On 2017-12-12 11:57:41 +0800, Craig Ringer wrote: > TL;DR: Lets add a ProcSignalReason that makes a backend > call MemoryContextStats when it sees it and a C func that users can use to > set it on a proc. Sane?
It's not unproblematic. procsignal_sigusr1_handler() runs in a signal handler, so you can't really rely on a lot of stuff being legal to do. It'd be easy to set a flag in the handler and then have CHECK_FOR_INTERRUPTS() do the MemoryContextStats() call. But that'd have the disadvanatage that it possibly would take a while till the MemoryContextStats() is executed. Not sure if that's still good enough for you? Another question is whether printing to stderr, bypassing proper logging!, is good enough for something like this. Greetings, Andres Freund