View Issue Details

IDProjectCategoryView StatusLast Update
0000296Pgpool-IIBugpublic2017-08-29 09:48
ReportermglubbAssigned ToMuhammad Usama 
PrioritynormalSeverityminorReproducibilityhave not tried
Status closedResolutionopen 
Platformx86-64OSCentOSOS Version7
Product Version3.6.2 
Target VersionFixed in Version 
Summary0000296: PGPool v3.6.2 terminated by systemd because the service Type has been set to 'forking'
DescriptionPLEASE NOTE: This bug applies to v3.6.2. It was not select that version as it did not appear in the product version list at the time of writing.

PGPool terminated by systemd because the service Type has been set to 'forking'. systemd waits a few minutes for the program to daemonize itself but not detect that it has. I believe (ie. I'm guessing) that forking should not be used as the service does not kill the original process, it just spawns child processes.

Changing the service type to simple, or removing the Type fixes the problem and pgpool starts correctly.

This was perhaps missed because whilst systemd is waiting a few minutes for the service to fork, PGPool runs correctly before it is terminated by systemd.
Steps To Reproduce* Install http://www.pgpool.net/yum/rpms/3.6/redhat/rhel-7-x86_64/pgpool-II-pg93-3.6.2-1pgdg.rhel7.x86_64.rpm
* Configure the service in master slave mode, no failover (the configuration may not have a material effect on this bug)
* Start the service

Additional Informationjournal log looks like this:

Mar 20 12:57:35 ip-10-54-110-133 systemd: Starting Pgpool-II...
Mar 20 12:57:35 ip-10-54-110-133 systemd: Reached target Network is Online.
Mar 20 12:57:35 ip-10-54-110-133 systemd: Starting Network is Online.
Mar 20 12:57:35 ip-10-54-110-133 pgpool[508]: [1-1] 2017-03-20 12:57:35: pid 508: LOG: Backend status file /tmp/pgpool_status does not exist
Mar 20 12:57:35 ip-10-54-110-133 pgpool: 2017-03-20 12:57:35: pid 508: LOG: Backend status file /tmp/pgpool_status does not exist
Mar 20 12:57:35 ip-10-54-110-133 pgpool[508]: [2-1] 2017-03-20 12:57:35: pid 508: LOG: Setting up socket for ::1:9999
Mar 20 12:57:35 ip-10-54-110-133 pgpool: 2017-03-20 12:57:35: pid 508: LOG: Setting up socket for ::1:9999
Mar 20 12:57:35 ip-10-54-110-133 pgpool: 2017-03-20 12:57:35: pid 508: LOG: Setting up socket for 127.0.0.1:9999
Mar 20 12:57:35 ip-10-54-110-133 pgpool[508]: [3-1] 2017-03-20 12:57:35: pid 508: LOG: Setting up socket for 127.0.0.1:9999
Mar 20 12:57:35 ip-10-54-110-133 pgpool[508]: [4-1] 2017-03-20 12:57:35: pid 508: LOG: pgpool-II successfully started. version 3.6.2 (subaruboshi)
Mar 20 12:57:35 ip-10-54-110-133 pgpool: 2017-03-20 12:57:35: pid 508: LOG: pgpool-II successfully started. version 3.6.2 (subaruboshi)
Mar 20 12:57:35 ip-10-54-110-133 pgpool: 2017-03-20 12:57:35: pid 508: LOG: find_primary_node: checking backend no 0
Mar 20 12:57:35 ip-10-54-110-133 pgpool[508]: [5-1] 2017-03-20 12:57:35: pid 508: LOG: find_primary_node: checking backend no 0
Mar 20 12:57:35 ip-10-54-110-133 pgpool[508]: [6-1] 2017-03-20 12:57:35: pid 508: LOG: find_primary_node: primary node id is 0
Mar 20 12:57:35 ip-10-54-110-133 pgpool: 2017-03-20 12:57:35: pid 508: LOG: find_primary_node: primary node id is 0
Mar 20 12:59:05 ip-10-54-110-133 systemd: pgpool.service start operation timed out. Terminating.
Mar 20 12:59:05 ip-10-54-110-133 pgpool[508]: [7-1] 2017-03-20 12:59:05: pid 508: LOG: received smart shutdown request
Mar 20 12:59:05 ip-10-54-110-133 pgpool: 2017-03-20 12:59:05: pid 508: LOG: received smart shutdown request
Mar 20 12:59:05 ip-10-54-110-133 pgpool: 2017-03-20 12:59:05: pid 508: LOG: shutdown request. closing listen socket
Mar 20 12:59:05 ip-10-54-110-133 pgpool[508]: [8-1] 2017-03-20 12:59:05: pid 508: LOG: shutdown request. closing listen socket
Mar 20 12:59:05 ip-10-54-110-133 systemd: Failed to start Pgpool-II.
Mar 20 12:59:05 ip-10-54-110-133 systemd: Unit pgpool.service entered failed state.
Mar 20 12:59:05 ip-10-54-110-133 systemd: pgpool.service failed.
Tagssystemd

Activities

t-ishii

2017-03-21 08:09

developer   ~0001381

Thank you for the report. Sorry, I forgot to update the version list when 3.6.2 was out. I have updated the "Product version" tag.

supp_k

2017-03-21 21:25

reporter   ~0001383

Pgpool Commnunity,

We have faced the same issue with 3.6.2. Described solution solves the problem.

Would it be possible to patch the 3.6.2 build? Otherwise it is not possible to use pgpool out of the box.

pengbo

2017-03-22 10:36

developer   ~0001386

It seems that "Type=forking" added in commit

https://git.postgresql.org/gitweb/?p=pgpool2.git;a=commit;h=8fa731a3eed7962b127710236823de9ab0379b44

is causing this problem. I am contacting the committer now.

Muhammad Usama

2017-03-23 06:39

developer   ~0001387

Since the service wants to run the Pgpool-II in daemon mode so "Type=forking" should be correct. But unfortunately the default Environment file (/etc/sysconfig/pgpool) assigns ' - n' to the start options (OPTS=" -n") which disables the daemon mode and is causing the problem.

You can also try by removing the commenting out the OPTS=" -n" in the /etc/sysconfig/pgpool file.

I am also attaching the patch and updated service configuration and environment files. Can you please verify if by using these files solves the problem.

Thanks

pgpool (184 bytes)
# Options for pgpool

# If you want to use '-n' in START_OPTS, change the service type to simple in
# the Pgpool-II service configuration file
#START_OPTS=" -d"

#STOP_OPTS=" -m fast"
pgpool (184 bytes)

Muhammad Usama

2017-03-23 06:40

developer  

pgpool.service (547 bytes)

supp_k

2017-03-23 07:34

reporter   ~0001388

Muhammad,

basically it works. But the systemd documentation also recommends to specify the "PIDfile" option. But I'm not sure how it can be coherent with the "pid_file_name" parameter in pgpool's conf file.

Need to investigate it. Can you please recommend what also we need to verify?

Mr mglubb, how do you think about the proposal?


Would it be possible to patch the newly put RPM file in pgpool's repository?

t-ishii

2017-03-23 09:02

developer   ~0001389

I have changed the assignment from Peng to Usama.

mglubb

2017-03-23 19:53

reporter   ~0001391

I'm not qualified to say whether the PIDFile option should be present.

I've tried the patch and it seems to fix the problem. Start/Stop/Restart works, and the service stays up. From the point of view of my use case, I'm a happy man.

Thanks, all.

supp_k

2017-03-23 20:38

reporter   ~0001392

Muhammad,

attached patch of pgpool.service a little bit contradicts with previous approach to configure the Pgpool. The previous approach allows to provide any configuration files to pgpool using the concrete OPTS variable defined in /etc/sysconfig/pgpool file.

The patch will damage previous users of pgpool. Don't you think it is better just remove "-n" option in the current /etc/sysconfig/pgpool file?

Muhammad Usama

2017-03-24 06:27

developer   ~0001393

supp_k,

Thanks for your input, and you have a valid point that service configuration should fix the values for hba_config and pcp_config files and leave it to the user to specify if through /etc/sysconfig/pgpool file, So I have committed the patch by omitting the
ExecStart changes from the patch.

On your point of "PIDfile" option, you are right that it is recommended with the service type=forking and if it is not specified, then systemd tries to guess main pid by itself (GuessMainPID=YES by default) which is not that reliable. But unfortunately with the current Pgpool-II I can't think of any simple way to provide "PIDfile" option while keeping it in-sync with the pid_file_name parameter.
One option could be to add a new command line option in Pgpool-II (may be --pid_file_name=file) which takes precedence over the pid_file_name configuration provided in the configuration file. This way we will be able to use the PIDfile option.

supp_k

2017-03-24 06:50

reporter   ~0001394

Muhammad,

thank you!

Would it be possible to patch the current 3.6.2 RPM? The version is fresh and unfortunately it already has this very painful error, which is not true error, but a damaged configuration.

t-ishii

2017-03-24 17:40

developer   ~0001395

I'm planning to release newer 3.6.2 RPMs in early April.

Issue History

Date Modified Username Field Change
2017-03-21 00:27 mglubb New Issue
2017-03-21 00:27 mglubb Tag Attached: systemd
2017-03-21 08:07 t-ishii Assigned To => pengbo
2017-03-21 08:07 t-ishii Status new => assigned
2017-03-21 08:07 t-ishii Product Version 3.6.1 => 3.6.2
2017-03-21 08:09 t-ishii Note Added: 0001381
2017-03-21 21:25 supp_k Note Added: 0001383
2017-03-22 10:36 pengbo Note Added: 0001386
2017-03-23 06:39 Muhammad Usama File Added: pgpool
2017-03-23 06:39 Muhammad Usama Note Added: 0001387
2017-03-23 06:40 Muhammad Usama File Added: pgpool.service
2017-03-23 06:41 Muhammad Usama Status assigned => feedback
2017-03-23 07:34 supp_k Note Added: 0001388
2017-03-23 09:02 t-ishii Note Added: 0001389
2017-03-23 09:02 t-ishii Assigned To pengbo => Muhammad Usama
2017-03-23 19:53 mglubb Note Added: 0001391
2017-03-23 19:53 mglubb Status feedback => assigned
2017-03-23 20:38 supp_k Note Added: 0001392
2017-03-24 06:27 Muhammad Usama Note Added: 0001393
2017-03-24 06:50 supp_k Note Added: 0001394
2017-03-24 17:40 t-ishii Note Added: 0001395
2017-08-29 09:48 pengbo Status assigned => closed