Commit 811969b2 authored by Heikki Linnakangas's avatar Heikki Linnakangas

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
parent a820b4c3
...@@ -2650,7 +2650,7 @@ CreateSharedBackendStatus(void) ...@@ -2650,7 +2650,7 @@ CreateSharedBackendStatus(void)
} }
/* Create or attach to the shared appname buffer */ /* Create or attach to the shared appname buffer */
size = mul_size(NAMEDATALEN, MaxBackends); size = mul_size(NAMEDATALEN, NumBackendStatSlots);
BackendAppnameBuffer = (char *) BackendAppnameBuffer = (char *)
ShmemInitStruct("Backend Application Name Buffer", size, &found); ShmemInitStruct("Backend Application Name Buffer", size, &found);
...@@ -2668,7 +2668,7 @@ CreateSharedBackendStatus(void) ...@@ -2668,7 +2668,7 @@ CreateSharedBackendStatus(void)
} }
/* Create or attach to the shared client hostname buffer */ /* Create or attach to the shared client hostname buffer */
size = mul_size(NAMEDATALEN, MaxBackends); size = mul_size(NAMEDATALEN, NumBackendStatSlots);
BackendClientHostnameBuffer = (char *) BackendClientHostnameBuffer = (char *)
ShmemInitStruct("Backend Client Host Name Buffer", size, &found); ShmemInitStruct("Backend Client Host Name Buffer", size, &found);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment