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

Commit 811969b

Browse files
committed
Allocate enough shared string memory for stats of auxiliary processes.
This fixes a bug whereby the st_appname, st_clienthostname, and st_activity_raw fields for auxiliary processes point beyond the end of their respective shared memory segments. As a result, the application_name of a backend might show up as the client hostname of an auxiliary process. Backpatch to v10, where this bug was introduced, when the auxiliary processes were added to the array. 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 a820b4c commit 811969b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/backend/postmaster/pgstat.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -2650,7 +2650,7 @@ CreateSharedBackendStatus(void)
26502650
}
26512651

26522652
/* Create or attach to the shared appname buffer */
2653-
size = mul_size(NAMEDATALEN, MaxBackends);
2653+
size = mul_size(NAMEDATALEN, NumBackendStatSlots);
26542654
BackendAppnameBuffer = (char *)
26552655
ShmemInitStruct("Backend Application Name Buffer", size, &found);
26562656

@@ -2668,7 +2668,7 @@ CreateSharedBackendStatus(void)
26682668
}
26692669

26702670
/* Create or attach to the shared client hostname buffer */
2671-
size = mul_size(NAMEDATALEN, MaxBackends);
2671+
size = mul_size(NAMEDATALEN, NumBackendStatSlots);
26722672
BackendClientHostnameBuffer = (char *)
26732673
ShmemInitStruct("Backend Client Host Name Buffer", size, &found);
26742674

0 commit comments

Comments
 (0)