[pgpool-hackers: 2405] Re: Problems with the relative paths in daemon mode

Muhammad Usama m.usama at gmail.com
Tue Jun 20 18:15:33 JST 2017


On Tue, Jun 20, 2017 at 5:12 AM, Tatsuo Ishii <ishii at sraoss.co.jp> wrote:

> Usama,
>
> Thanks for the patch.
>
> I think this is good since we didn't define the behavior when a
> relative path is specified for pid_file_name anyway. Now it's defined,
> which is good.
>

Thanks


>
> Just out of curiosity, is there any use case to define the path of
> pid_file_name relative to the path of pgpool.conf? Since most users
> (and Linux systems) want to put pid_file_name under /var while they
> want to put pgpool.conf under /etc.
>

Well the main motivation behind this pid_file_name change was to solve the
confusion, since it has also confused me few times, and it is easy to get
it wrong.
And I was thinking it as a step towards making the pgpool configurations
self contained,
Like for example if we define the behaviour of each path related
configuration parameter in the pgpool.conf than we would be able to copy
paste the pgpool directory to different path or system and will be able to
run the pgpool without modifying the pgpool.conf file, This feature would
be useful in for certain lab /cloud environments, but yes its still someway
to go to achieve that.

And as for now, I think you are right most of the users use /var for pid
file and /etc for config and there may exist a very few use cases for this
currently.

Thanks
Best Regards
Muhammad Usama




> Best regards,
> --
> Tatsuo Ishii
> SRA OSS, Inc. Japan
> English: http://www.sraoss.co.jp/index_en.php
> Japanese:http://www.sraoss.co.jp
>
> > Hi Ishii-San
> >
> > Can you please have a look at the attached patch.
> > The reason I want your consent before committing it is because apart from
> > using the absolute paths for pgpool.conf, pcp.conf and pool_hba.conf
> files,
> > I have also modified the behaviour of pid_file_name configuration
> parameter.
> > Now when the relative path is specified for the pid file in pgpool.conf
> > file that relative path is calculated with reference to the location of
> > pgpool.conf file.
> >
> > For example:
> >
> > if pgpool.conf file sets pid_file_name parameter as
> >
> > pid_file_name = 'somedir/pgpool.pid'
> >
> > And pgpool.conf file is located in the "/etc/configurations/" directory
> > than the Pgpool-II will create the pgpool.pid file
> > in "/etc/configurations/somedir" directory
> >
> > While if absolute path is specified than it will work as it works before
> >
> > pid_file_name = '/etc/mydir/pgpool.pid' # this will create the pgpool.pid
> > in /etc/mydir/ directory
> >
> >
> > I have done this change because I think it will make the configuration of
> > pid_file_name more intuitive and less confusing.
> > P.S  The documentation changes are also part of the patch.
> >
> > Thoughts and comments?
> >
> >
> > Thanks
> > Best regards
> > Muhammad Usama
> >
> >
> >
> > On Wed, Jun 14, 2017 at 3:27 AM, Tatsuo Ishii <ishii at sraoss.co.jp>
> wrote:
> >
> >> Good catch! Please go ahead.
> >>
> >> Best regards,
> >> --
> >> Tatsuo Ishii
> >> SRA OSS, Inc. Japan
> >> English: http://www.sraoss.co.jp/index_en.php
> >> Japanese:http://www.sraoss.co.jp
> >>
> >> > Hi
> >> >
> >> > Pgpool-II does not properly handle the relative paths especially when
> the
> >> > pgpool.conf file is explicitly specified using the command line (-f
> >> switch)
> >> > while its patch is given relative to the current directory.
> >> >
> >> > For example:
> >> >
> >> > Suppose we invoke pgpool-II from "/home/work/installed/pgpool/bin"
> >> directory
> >> >
> >> > $ pwd
> >> > /home/work//installed/pgpool/bin
> >> > $ ./pgpool -f simple_conf/pgpool.conf
> >> >
> >> > Now we are expecting here is that the Pgpool-II will look for
> pgpool.conf
> >> > file in the
> >> > /home/work/installed/pgpool/bin/simple_conf/ directory, which it does
> >> > correctly :-), and also latter in the startup phase when it will
> require
> >> > the pool_passwd file it will look in the same (
> >> > /home/work/installed/pgpool/bin/simple_conf/)directory.
> >> > So in the code what Pgpool-II does is, it take out the directory
> portion
> >> > from the command line option provided to it for specifying the
> >> pgpool.conf
> >> > file and look for the pool_passwd file in that directory. which in
> this
> >> > case is just simple_conf/
> >> >
> >> > Now the problem here is since the pgpool.conf path used in the command
> >> line
> >> > option was a relative path, so it will only be able to go to the
> correct
> >> > directory location if the current directory of Pgpool-II remains the
> same
> >> > from where it was invoked from.
> >> >
> >> > And since we do not change the current directory when Pgpool-II is
> >> started
> >> > with "-n" switch ( non daemon mode) so everything works as expected in
> >> that
> >> > mode.
> >> > But when the Pgpool-II is started in the daemon mode the daemonize()
> >> > function changes the current directory to "/"
> >> >
> >> > main.c:380 if(chdir("/"))
> >> >
> >> > and after that all relative path becomes invalid and Pgpool-II will
> start
> >> > looking for files in invalid or non-existent location. which as per
> our
> >> > example in daemon mode it will try to find the pool_passwd file in
> >> >
> >> > /simple_conf/pool_passed
> >> >
> >> > instead of
> >> >
> >> > /home/work//installed/pgpool/bin/simple_conf/pool_passwd
> >> > The solution to this is to convert the relative path of the
> pgpool.conf
> >> to
> >> > the absolute path at the startup and later use that absolute path for
> all
> >> > other path calculations.
> >> >
> >> > If you do not have any reservation, than I will start working on the
> fix.
> >> >
> >> > Thanks
> >> > Best Regards
> >> > Muhammad Usama
> >>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.sraoss.jp/pipermail/pgpool-hackers/attachments/20170620/e6427488/attachment-0001.html>


More information about the pgpool-hackers mailing list