Re: [PATCH] Log crashed backend's query v3 - Mailing list pgsql-hackers

From Robert Haas
Subject Re: [PATCH] Log crashed backend's query v3
Date
Msg-id CA+Tgmoag570DYW7EWaZ_Y+R_eLC3OkwNm7B+9+7RcRQeMrtyNw@mail.gmail.com
Whole thread Raw
In response to Re: [PATCH] Log crashed backend's query v3  (gabrielle <gorthx@gmail.com>)
Responses Re: [PATCH] Log crashed backend's query v3
List pgsql-hackers
On Thu, Oct 6, 2011 at 10:15 PM, gabrielle <gorthx@gmail.com> wrote:
> On Wed, Oct 5, 2011 at 5:14 PM, Marti Raudsepp <marti@juffo.org> wrote:
>> I think you intended to use the "Waiting on Author" status -- that
>> leaves the commitfest entry open. I will re-open the commitfest entry
>> myself, I hope that's OK.
>
> No worries, and yeah, I picked the wrong checkbox. :)
>
>> Here is version 3 of the patch.
>
> Looks good, and performs as advertised.  Thanks!

I think it would be safer to write this so that
pgstat_get_crashed_backend_activity writes its answer into a
statically allocated buffer and returns a pointer to that buffer,
rather than using palloc.  I think the current coding might lead to a
memory leak in the postmaster, but even if it doesn't, it seems better
to make this as simple as possible.

Also, how about having CreateSharedBackendStatus store the length of
the backend activity buffer in a global somewhere, instead of
repeating the calculation here?

For this:
                       if (*(activity) == '\0')                               return "<command string not enabled>";

I'd suggest that we instead return <command string not found>, and
avoid making judgements about how things got that way.

Other than that, it looks good to me.  It's almost making me cry
thinking about how much time this would have saved me debugging server
crashes.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


pgsql-hackers by date:

Previous
From: Greg Jaskiewicz
Date:
Subject: Re: Bug in walsender when calling out to do_pg_stop_backup (and others?)
Next
From: Florian Pflug
Date:
Subject: Re: synchronized snapshots