Re: Using ProcSignal to get memory context stats from a runningbackend - Mailing list pgsql-hackers

From Andres Freund
Subject Re: Using ProcSignal to get memory context stats from a runningbackend
Date
Msg-id 20171221065810.4khb3naphokov4ml@alap3.anarazel.de
Whole thread Raw
In response to Re: Using ProcSignal to get memory context stats from a running backend  (Craig Ringer <craig@2ndquadrant.com>)
Responses Re: Using ProcSignal to get memory context stats from a running backend  (Craig Ringer <craig@2ndquadrant.com>)
List pgsql-hackers
Hi,

On 2017-12-21 14:49:28 +0800, Craig Ringer wrote:
> +/*
> + * Accumulate writes into the buffer in diag_request_buf,
> + * for use with functions that expect a printf-like callback.
> + */
> +static void
> +printwrapper_stringinfo(void *extra, const char * fmt, ...)
> +{
> +    StringInfo out = extra;
> +    for (;;)
> +    {
> +        va_list        args;
> +        int            needed;
> +        va_start(args, fmt);
> +        needed = appendStringInfoVA(out, fmt, args);
> +        va_end(args);
> +        if (needed == 0)
> +            break;
> +        enlargeStringInfo(out, needed);
> +    }
>  }

Hm, so I'm not entirely sure it's ok to use something that ERRORs on
OOM. There's plenty of scenarios with thousands of memory contexts,
making this output fairly large. If we want to make this usable in
production, I'm not sure it's ok to introduce additional ERRORs.  I
wonder if we can change this to emit a static message if collecting the
output exhausted memory.

Greetings,

Andres Freund


pgsql-hackers by date:

Previous
From: Craig Ringer
Date:
Subject: Re: Using ProcSignal to get memory context stats from a running backend
Next
From: Craig Ringer
Date:
Subject: Re: Using ProcSignal to get memory context stats from a running backend