View Issue Details

IDProjectCategoryView StatusLast Update
0000188Pgpool-IIBugpublic2016-04-20 13:55
ReporterkierenAssigned Topengbo 
PrioritynormalSeveritymajorReproducibilityalways
Status resolvedResolutionopen 
Product Version 
Target VersionFixed in Version 
Summary0000188: pcp_proc_count truncates PIDs over 5 characters long
DescriptionIf the PgPool process IDs are over five digits in length then running pcp_proc_count will result in the PIDs being incorrectly reported. Specifically, each 6 digit PID will be truncated to 5 digits with the right most digit being removed.

Although this is the output from the PgPool command (pcp_proc_count) it results in an error in PgPool admin as the "Process Info" output will error (e1005 - pcp_proc_info command error occurred) - because the PID passed to the command is incorrect and results in a "BackendError".

We are running pgpool-II 3.4 on Centos 7.5.1511 (Core).
Steps To ReproduceThe PgPool PIDs need to be over 5 digits to show the bug but then this can be reproduced consistently using:

$ pcp_proc_count 10 localhost 9898 apgpooluser 'somepassword'
14230 13921 14292 14191 14208 ...

However the reported PIDs will all be incorrect and shortened by one digit as shown by:

$ ps -ef | grep 14230
root 142306 24222 0 17:26 ? 00:00:00 pgpool: wait for connection request

The PID is actually 142306 and not 14230.

Similarly...

$ ps -ef | grep 13921
root 139210 24222 0 16:58 ? 00:00:00 pgpool: wait for connection request

Again, the PID is 139210 and not 13921
TagsNo tags attached.

Activities

t-ishii

2016-04-06 08:05

developer   ~0000758

Interesting. How large is your system's pid max? (/proc/sys/kernel/pid_max)

kieren

2016-04-06 19:26

reporter   ~0000759

pid_max is 147456

t-ishii

2016-04-07 07:48

developer   ~0000760

pcp_proc_count thinks that 5 digit is enough for process ids. Pengbo is working on fixing it.

pengbo

2016-04-08 19:32

developer  

diff.patch (785 bytes)
diff --git a/src/pcp_con/pcp_child.c b/src/pcp_con/pcp_child.c
index 0da3878..59397b3 100644
--- a/src/pcp_con/pcp_child.c
+++ b/src/pcp_con/pcp_child.c
@@ -773,13 +773,13 @@ inform_process_count(PCP_CONNECTION *frontend)
 
 	process_list = pool_get_process_list(&process_count);
 
-	mesg = (char *)palloc(6*process_count);	/* port# is at most 5 characters long (MAX:65535) */
+	mesg = (char *)palloc(7*process_count);	/* PID is at most 6 characters long (MAX:147456) */
 
 	snprintf(process_count_str, sizeof(process_count_str), "%d", process_count);
 
 	for (i = 0; i < process_count; i++)
 	{
-		char port[6];
+		char port[7];
 		snprintf(port, sizeof(port), "%d", process_list[i]);
 		snprintf(mesg+total_port_len, strlen(port)+1, "%s", port);
 		total_port_len += strlen(port)+1;
diff.patch (785 bytes)

pengbo

2016-04-08 19:33

developer   ~0000766

Could you try this patch file that I have attached.

Issue History

Date Modified Username Field Change
2016-04-06 01:45 kieren New Issue
2016-04-06 08:05 t-ishii Note Added: 0000758
2016-04-06 10:26 t-ishii Assigned To => pengbo
2016-04-06 10:26 t-ishii Status new => assigned
2016-04-06 19:26 kieren Note Added: 0000759
2016-04-07 07:48 t-ishii Note Added: 0000760
2016-04-08 19:32 pengbo File Added: diff.patch
2016-04-08 19:33 pengbo Note Added: 0000766
2016-04-20 13:55 pengbo Status assigned => resolved