aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMagnus Hagander <magnus@hagander.net>2017-12-29 16:19:51 +0100
committerMagnus Hagander <magnus@hagander.net>2017-12-29 16:22:43 +0100
commitb38c3d58ed6f43c14e1e0f78f82db0e60cc2fedb (patch)
treed51a1b8560ab15bf9e764010004487d7893d48ad /src
parentbdbf29aaef7d1c698c1c5838a7b8cb027c406f9c (diff)
downloadpostgresql-b38c3d58ed6f43c14e1e0f78f82db0e60cc2fedb.tar.gz
postgresql-b38c3d58ed6f43c14e1e0f78f82db0e60cc2fedb.zip
Properly set base backup backends to active in pg_stat_activity
When walsenders were included in pg_stat_activity, only the ones actually streaming WAL were listed as active when they were active. In particular, the connections sending base backups were listed as being idle. Which means that a regular pg_basebackup would show up with one active and one idle connection, when both were active. This patch updates to set all walsenders to active when they are (including those doing very fast things like IDENTIFY_SYSTEM), and then back to idle. Details about exactly what they are doing is available in pg_stat_replication. Patch by me, review by Michael Paquier and David Steele.
Diffstat (limited to 'src')
-rw-r--r--src/backend/replication/walsender.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index ba996ed59e2..71b45bb91da 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -1504,6 +1504,9 @@ exec_replication_command(const char *cmd_string)
initStringInfo(&reply_message);
initStringInfo(&tmpbuf);
+ /* Report to pgstat that this process is running */
+ pgstat_report_activity(STATE_RUNNING, NULL);
+
switch (cmd_node->type)
{
case T_IdentifySystemCmd:
@@ -1555,6 +1558,9 @@ exec_replication_command(const char *cmd_string)
ereport(ERROR,
(errmsg("cannot execute SQL commands in WAL sender for physical replication")));
+ /* Report to pgstat that this process is now idle */
+ pgstat_report_activity(STATE_IDLE, NULL);
+
/* Tell the caller that this wasn't a WalSender command. */
return false;
@@ -1570,6 +1576,9 @@ exec_replication_command(const char *cmd_string)
/* Send CommandComplete message */
EndCommand("SELECT", DestRemote);
+ /* Report to pgstat that this process is now idle */
+ pgstat_report_activity(STATE_IDLE, NULL);
+
return true;
}
@@ -2089,9 +2098,6 @@ WalSndLoop(WalSndSendDataCallback send_data)
last_reply_timestamp = GetCurrentTimestamp();
waiting_for_ping_response = false;
- /* Report to pgstat that this process is running */
- pgstat_report_activity(STATE_RUNNING, NULL);
-
/*
* Loop until we reach the end of this timeline or the client requests to
* stop streaming.