Skip site navigation (1) Skip section navigation (2)

[PATCH] Log crashed backend's query (activity string)

From: Marti Raudsepp <marti(at)juffo(dot)org>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: [PATCH] Log crashed backend's query (activity string)
Date: 2011-09-06 20:52:18
Message-ID: CABRT9RDuuV6a+zJN+DMJjt1ahwk1_50iEN0mPdRV9fjE7gHjuQ@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-hackers
Hi list,

This patch adds the backend's current running query to the "backend
crash" message.

The crashing query is often a good starting point in debugging the
cause, and much more easily accessible than core dumps.

Example output:
LOG:  server process (PID 31451) was terminated by signal 9: Killed
DETAIL:  Running query: DO LANGUAGE plpythonu 'import os;os.kill(os.getpid(),9)'

The message "Running query" might not be entirely true, as it might be
e.g. a vacuum activity string too. But it sounds better than "Activity
string" or anything else I could come up with.

Also refactored pgstat_get_backend_current_activity() such that it
always returns consistent results. (Previously it returned a pointer to
shared memory that could theoretically change and was vulnerable to
races) The function can also deal with shared memory corruption (if
isCrashed is true), so that corruption doesn't cause a postmaster crash
or hang.

I'm not happy with the indenting depth in the function, but it would
be hard to split anything out.

Regards,
Marti

Attachment: 0001-Log-crashed-backend-s-query-activity-string.patch
Description: text/x-patch (8.2 KB)

Responses

pgsql-hackers by date

Next:From: Robert HaasDate: 2011-09-06 20:58:48
Subject: Re: [v9.1] sepgsql - userspace access vector cache
Previous:From: Tom LaneDate: 2011-09-06 20:46:29
Subject: Re: timezone GUC

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group