postgres.git / summary / log / commit / refs

commit    4c3e750ab4b5f1900abfa7000aad5e6322f47b5d
Author:   Michael Paquier <michael@paquier.xyz>
Date:     Wed Sep 04 06:46:45 2019 +0000
First released in: 13.0, 9.6.16, 10.11, 11.6, 12.0

    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


src/backend/postmaster/pgstat.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/postmaster/pgstat.c b/src/backend/postmaster/pgstat.c index b4f2b28b517..099e14d35e6 100644 --- a/src/backend/postmaster/pgstat.c +++ b/src/backend/postmaster/pgstat.c @@ -3272,10 +3272,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); [parent: 64eb426afc34]