pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: torikoshia <torikoshia@oss.nttdata.com>
To: vignesh C <vignesh21@gmail.com>
Cc: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Cc: Andres Freund <andres@anarazel.de>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Craig Ringer <craig.ringer@enterprisedb.com>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: Peter Eisentraut <peter.eisentraut@enterprisedb.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: Printing backtrace of postgres processes
Date: Mon, 01 Mar 2021 14:13:16 +0900
Message-ID: <979ee93ab2e5d7d51836ced0c38b445c@oss.nttdata.com> (raw)
In-Reply-To: <CALDaNm3aBt1hw+Q=achUxfQgyu3b6DmdxewvMVx5DEikNayAFA@mail.gmail.com>
References: <20210115201011.noomcygirzge43ir@alap3.anarazel.de>
	<CALDaNm2wjFrizmy+yvNbedYKxorZBcGYXNMaoPC6zwSaLsmwLg@mail.gmail.com>
	<3537.1610828491@sss.pgh.pa.us>
	<CA+TgmobpOhhm0poFsShjoM=sOxkbzc78f2TdNyZpGz4GSJHh6g@mail.gmail.com>
	<492025.1611078655@sss.pgh.pa.us>
	<CA+TgmoZ8XeQVCCqfq826kAr804a1ZnYy46FnQB9r2n_iOofh8Q@mail.gmail.com>
	<523589.1611091371@sss.pgh.pa.us>
	<CAGRY4nxmyaGs4-o4JSMwsUmqe++y-9zPEmJTeRn5ZOOdNzxi5w@mail.gmail.com>
	<799340.1611194209@sss.pgh.pa.us>
	<CALDaNm1ig4dKFW1658YBH9338Oysc-MT6-YzeKU-ojv87MhhMQ@mail.gmail.com>
	<20210127170958.vzo33jzmqwhmn7z6@alap3.anarazel.de>
	<CALDaNm1uWKn8KGD0q8HqCPhxSUDKWCEW55aidOiJwd+vfaB+gg@mail.gmail.com>
	<CALj2ACXfXefmdUWiF0twoYEfgJ6Xk4saXctoYyzXtzkjizCdBw@mail.gmail.com>
	<CALDaNm0aEUNLZeiDAXvPsgm4nFUjUhtfeztGofmVJU--irSD8Q@mail.gmail.com>
	<CALj2ACXybys_tzWeatb9htVTuxKp29VErc6iJQYJBbdBZXv2fg@mail.gmail.com>
	<CALDaNm3aBt1hw+Q=achUxfQgyu3b6DmdxewvMVx5DEikNayAFA@mail.gmail.com>

Hi,

I also think this feature would be useful when supporting
environments that lack debugger or debug symbols.
I think such environments are not rare.


+        <xref linkend="runtime-config-logging"/> for more information. 
This
+        will help in identifying where exactly the backend process is 
currently
+        executing.

When I read this, I expected a backtrace would be generated at
the moment when it receives the signal, but actually it just
sets a flag that causes the next CHECK_FOR_INTERRUPTS to print
a backtrace.

How about explaining the timing of the backtrace generation?


+        print backtrace of superuser backends. This feature is not 
supported
+        for postmaster, logging and statistics process.

Since the current patch use BackendPidGetProc(), it does not
support this feature not only postmaster, logging, and
statistics but also checkpointer, background writer, and
walwriter.

And when I specify pid of these PostgreSQL processes, it
says "PID xxxx is not a PostgreSQL server process".

I think it may confuse users, so it might be worth
changing messages for those PostgreSQL processes.
AuxiliaryPidGetProc() may help to do it.


diff --git a/src/backend/postmaster/checkpointer.c 
b/src/backend/postmaster/checkpointer.c
index 54a818b..5fae328 100644
--- a/src/backend/postmaster/checkpointer.c
+++ b/src/backend/postmaster/checkpointer.c
@@ -57,6 +57,7 @@
  #include "storage/shmem.h"
  #include "storage/smgr.h"
  #include "storage/spin.h"
+#include "tcop/tcopprot.h"
  #include "utils/guc.h"
  #include "utils/memutils.h"
  #include "utils/resowner.h"
@@ -547,6 +548,13 @@ HandleCheckpointerInterrupts(void)
         if (ProcSignalBarrierPending)
                 ProcessProcSignalBarrier();

+       /* Process printing backtrace */
+       if (PrintBacktracePending)
+       {
+               PrintBacktracePending = false;
+               set_backtrace(NULL, 0);
+       }
+

Although it implements backtrace for checkpointer, when
I specified pid of checkpointer it was refused from
BackendPidGetProc().


Regards,

--
Atsushi Torikoshi
NTT DATA CORPORATION





view thread (135+ messages)  latest in thread

Message-ID: <979ee93ab2e5d7d51836ced0c38b445c@oss.nttdata.com>
Permalink:  ../979ee93ab2e5d7d51836ced0c38b445c@oss.nttdata.com/
Also on:    postgresql.org/message-id/979ee93ab2e5d7d51836ced0c38b445c@oss.nttdata.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: torikoshia@oss.nttdata.com, vignesh21@gmail.com, bharath.rupireddyforpostgres@gmail.com, andres@anarazel.de, tgl@sss.pgh.pa.us, craig.ringer@enterprisedb.com, robertmhaas@gmail.com, peter.eisentraut@enterprisedb.com, pgsql-hackers@lists.postgresql.org
  Subject: Re: Printing backtrace of postgres processes
  In-Reply-To: <979ee93ab2e5d7d51836ced0c38b445c@oss.nttdata.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox