Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit a820b4c

Browse files
committed
Make local copy of client hostnames in backend status array.
The other strings, application_name and query string, were snapshotted to local memory in pgstat_read_current_status(), but we forgot to do that for client hostnames. As a result, the client hostname would appear to change in the local copy, if the client disconnected. Backpatch to all supported versions. Author: Edmund Horner Reviewed-by: Michael Paquier Discussion: https://www.postgresql.org/message-id/CAMyN-kA7aOJzBmrYFdXcc7Z0NmW%2B5jBaf_m%3D_-77uRNyKC9r%3DA%40mail.gmail.com
1 parent 72cf7f3 commit a820b4c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/backend/postmaster/pgstat.c

+7
Original file line numberDiff line numberDiff line change
@@ -3224,6 +3224,7 @@ pgstat_read_current_status(void)
32243224
LocalPgBackendStatus *localtable;
32253225
LocalPgBackendStatus *localentry;
32263226
char *localappname,
3227+
*localclienthostname,
32273228
*localactivity;
32283229
#ifdef USE_SSL
32293230
PgBackendSSLStatus *localsslstatus;
@@ -3242,6 +3243,9 @@ pgstat_read_current_status(void)
32423243
localappname = (char *)
32433244
MemoryContextAlloc(pgStatLocalContext,
32443245
NAMEDATALEN * NumBackendStatSlots);
3246+
localclienthostname = (char *)
3247+
MemoryContextAlloc(pgStatLocalContext,
3248+
NAMEDATALEN * NumBackendStatSlots);
32453249
localactivity = (char *)
32463250
MemoryContextAlloc(pgStatLocalContext,
32473251
pgstat_track_activity_query_size * NumBackendStatSlots);
@@ -3282,6 +3286,8 @@ pgstat_read_current_status(void)
32823286
*/
32833287
strcpy(localappname, (char *) beentry->st_appname);
32843288
localentry->backendStatus.st_appname = localappname;
3289+
strcpy(localclienthostname, (char *) beentry->st_clienthostname);
3290+
localentry->backendStatus.st_clienthostname = localclienthostname;
32853291
strcpy(localactivity, (char *) beentry->st_activity_raw);
32863292
localentry->backendStatus.st_activity_raw = localactivity;
32873293
localentry->backendStatus.st_ssl = beentry->st_ssl;
@@ -3313,6 +3319,7 @@ pgstat_read_current_status(void)
33133319

33143320
localentry++;
33153321
localappname += NAMEDATALEN;
3322+
localclienthostname += NAMEDATALEN;
33163323
localactivity += pgstat_track_activity_query_size;
33173324
#ifdef USE_SSL
33183325
localsslstatus++;

0 commit comments

Comments
 (0)