pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Make walsenders show their replication commands in pg_stat_activ
Date: Mon, 14 Sep 2020 16:35:08 +0000
Message-ID: <E1kHrRc-00054R-Nw@gemulon.postgresql.org> (raw)

Make walsenders show their replication commands in pg_stat_activity.

A walsender process that has executed a SQL command left the text of
that command in pg_stat_activity.query indefinitely, which is quite
confusing if it's in RUNNING state but not doing that query.  An easy
and useful fix is to treat replication commands as if they were SQL
queries, and show them in pg_stat_activity according to the same rules
as for regular queries.  While we're at it, it seems also sensible to
set debug_query_string, allowing error logging and debugging to see
the replication command.

While here, clean up assorted silliness in exec_replication_command:

* The SQLCmd path failed to restore CurrentMemoryContext to the caller's
value, and failed to delete the temp context created in this routine.
It's only through great good fortune that these oversights did not
result in long-term memory leaks or other problems.  It seems cleaner
to code SQLCmd as a separate early-exit path, so do it like that.

* Remove useless duplicate call of SnapBuildClearExportedSnapshot().

* replication_scanner_finish() was never called.

None of those things are significant enough to merit a backpatch,
so this is for HEAD only.

Discussion: https://postgr.es/m/880181.1600026471@sss.pgh.pa.us

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/f560209c6e99e000f3f6c972f34f1d9dc3857f25

Modified Files
--------------
src/backend/replication/walsender.c | 62 ++++++++++++++++++++-----------------
1 file changed, 34 insertions(+), 28 deletions(-)



view thread (5+ messages)  latest in thread

Message-ID: <E1kHrRc-00054R-Nw@gemulon.postgresql.org>
Permalink:  ../E1kHrRc-00054R-Nw@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1kHrRc-00054R-Nw@gemulon.postgresql.org

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Make walsenders show their replication commands in pg_stat_activ
  In-Reply-To: <E1kHrRc-00054R-Nw@gemulon.postgresql.org>
  References: <E1kHrRc-00054R-Nw@gemulon.postgresql.org>

* 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