TAP PostgresNode function to gdb stacks and optional cores for all backends

From: Craig Ringer <craig(dot)ringer(at)enterprisedb(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: TAP PostgresNode function to gdb stacks and optional cores for all backends
Date: 2020-12-23 07:11:58
Message-ID: CAGRY4nz6a_ooOJTEMo0GeGCvkCwKq0HuMqMdq7pwq8-Ad4Eh2g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi all

I recently wrote a utility that adds a $node->gdb_backends() method to
PostgresNode instances - figured I'd share it here in case anyone finds it
useful, or wants to adopt it into the features of the TAP tools.

This function provides a one-line way to dump stacks for all running
backends to per-pid files or to the main test log, as well as the values of
various global variables that are potentially of interest. A default set of
globals will be dumped for each backend and the caller can specify
additional expressions of interest.

If requested, cores will be dumped for each running backend.

A subset of backends may be passed by pid instead, so you can easily target
specific backends you're interested in.

I initially wrote this to help debug a variety of issues with shutdown,
where I hacked the PostgresNode stop() method to trap failed shutdowns and
report stacks for all surviving processes + the postmaster in my wrapper
class for PostgresNode:

sub stop {
my ($self, $mode) = @_;
local($@);
eval {
PostgresNode::stop($self, $mode);
};
if ($@) {
$node->gdb_backends(want_cores => 1);
die $@;
}
}

Attachment Content-Type Size
gdb_backends_pl.txt text/plain 5.9 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message k.jamison@fujitsu.com 2020-12-23 07:37:38 RE: [Patch] Optimize dropping of relation buffers using dlist
Previous Message Craig Ringer 2020-12-23 06:56:07 Logical decoding without slots: decoding in lockstep with recovery