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 $@;
}
}