summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2019-09-04 15:47:01 +0900
committerMichael Paquier <michael@paquier.xyz>2019-09-04 15:47:01 +0900
commitf4b91a50e9e6757679322c454916bcd6b1dcbc15 (patch)
tree6562691bd6227d9bde593c8d689abb20e2f2bd2e
parentb0b2ef25e3ff240dc1887742bfed1d044c0938a0 (diff)
Fix thinko when ending progress report for a backend
The logic ending progress reporting for a backend entry introduced by b6fb647 causes callers of pgstat_progress_end_command() to do some extra work when track_activities is enabled as the process fields are reset in the backend entry even if no command were started for reporting. This resets the fields only if a command is registered for progress reporting, and only if track_activities is enabled. Author: Masahiho Sawada Discussion: https://postgr.es/m/CAD21AoCry_vJ0E-m5oxJXGL3pnos-xYGCzF95rK5Bbi3Uf-rpA@mail.gmail.com Backpatch-through: 9.6
-rw-r--r--src/backend/postmaster/pgstat.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/backend/postmaster/pgstat.c b/src/backend/postmaster/pgstat.c
index bc624c27a92..f98003555b5 100644
--- a/src/backend/postmaster/pgstat.c
+++ b/src/backend/postmaster/pgstat.c
@@ -3024,10 +3024,10 @@ pgstat_progress_end_command(void)
{
volatile PgBackendStatus *beentry = MyBEEntry;
- if (!beentry)
+ if (!beentry || !pgstat_track_activities)
return;
- if (!pgstat_track_activities
- && beentry->st_progress_command == PROGRESS_COMMAND_INVALID)
+
+ if (beentry->st_progress_command == PROGRESS_COMMAND_INVALID)
return;
PGSTAT_BEGIN_WRITE_ACTIVITY(beentry);