TAP PostgresNode function to gdb stacks and optional cores for all backends - Mailing list pgsql-hackers

From Craig Ringer
Subject TAP PostgresNode function to gdb stacks and optional cores for all backends
Date
Msg-id CAGRY4nz6a_ooOJTEMo0GeGCvkCwKq0HuMqMdq7pwq8-Ad4Eh2g@mail.gmail.com
Whole thread Raw
List 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

pgsql-hackers by date:

Previous
From: Craig Ringer
Date:
Subject: Logical decoding without slots: decoding in lockstep with recovery
Next
From: "k.jamison@fujitsu.com"
Date:
Subject: RE: [Patch] Optimize dropping of relation buffers using dlist