pg.ddx.io pgsql-bugs@postgresql.org mailing list archivehelp / color / mirror / Atom feed
'pg_ctl restart' confused about pathname to postgresql.conf 4+ messages / 3 participants [nested] [flat]
* 'pg_ctl restart' confused about pathname to postgresql.conf @ 2011-10-21 21:51 Josh Kupershmidt <schmiddy@gmail.com> 0 siblings, 1 reply; 4+ messages in thread From: Josh Kupershmidt @ 2011-10-21 21:51 UTC (permalink / raw) To: pgsql-bugs I've noticed that I occasionally see errors from "pg_ctl restart" claiming: postgres cannot access the server configuration file ... No such file or directory depending on what directory I execute "pg_ctl restart" from, and where the postmaster was originally started from. I boiled this problem down to the attached test case. I've seen this problem on 9.1.1 and git head. The testcase was tried on OS X and Debian, with Postgres installed locally like this: ./configure --prefix=/home/postgres/runtime/ --with-python --enable-debug You can run the test case stand-alone, though it's probably easier to see what's going on if you just copy-paste into your terminal: at the end you should wind up with your current directory "/tmp/foo/". You should see that the last command, "pg_ctl -D $DATADIR restart" failed to start the server back up, complaining: postgres cannot access the server configuration file "/tmp/foo/baz/postgresql.conf": No such file or directory even though $DATADIR is clearly set to "/tmp/foo/bar/baz/" (N.B. directory "bar" has gone missing in the above error message). A "pg_ctl -D $DATADIR start" should work at this point, though. This seems like some bug in normalizing the absolute path to postgresql.conf. Josh Attachments: pg_ctl_weirdness.sh (application/x-sh, 846B) download ^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: 'pg_ctl restart' confused about pathname to postgresql.conf @ 2011-10-22 16:13 Tom Lane <tgl@sss.pgh.pa.us> parent: Josh Kupershmidt <schmiddy@gmail.com> 0 siblings, 1 reply; 4+ messages in thread From: Tom Lane @ 2011-10-22 16:13 UTC (permalink / raw) To: Josh Kupershmidt <schmiddy@gmail.com>; +Cc: pgsql-bugs Josh Kupershmidt <schmiddy@gmail.com> writes: > You can run the test case stand-alone, though it's probably easier to > see what's going on if you just copy-paste into your terminal: at the > end you should wind up with your current directory "/tmp/foo/". You > should see that the last command, "pg_ctl -D $DATADIR restart" failed > to start the server back up, complaining: > postgres cannot access the server configuration file > "/tmp/foo/baz/postgresql.conf": No such file or directory > even though $DATADIR is clearly set to "/tmp/foo/bar/baz/" (N.B. > directory "bar" has gone missing in the above error message). A > "pg_ctl -D $DATADIR start" should work at this point, though. This > seems like some bug in normalizing the absolute path to > postgresql.conf. I think the reason it has a problem is that this is what's left in postmaster.opts: /home/tgl/pgsql/bin/postgres "-D" "baz" (which is an accurate representation of the command line from startup) and that -D switch gets fed to the postmaster as-is during restart. By and large, I would not recommend using a relative pathname to start the postmaster, unless you plan to start it from the same working directory every time. We could possibly avoid this by having pg_ctl try to absolute-ify the -D setting during postmaster start, but I'm not convinced it's worth the trouble, or even that it's appropriate for pg_ctl to editorialize on the user's choice of absolute vs relative path. regards, tom lane ^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: 'pg_ctl restart' confused about pathname to postgresql.conf @ 2011-10-24 00:49 Josh Kupershmidt <schmiddy@gmail.com> parent: Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 1 reply; 4+ messages in thread From: Josh Kupershmidt @ 2011-10-24 00:49 UTC (permalink / raw) To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-bugs On Sat, Oct 22, 2011 at 12:13 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote: > I think the reason it has a problem is that this is what's left in > postmaster.opts: > > /home/tgl/pgsql/bin/postgres "-D" "baz" > > (which is an accurate representation of the command line from startup) > and that -D switch gets fed to the postmaster as-is during restart. I see. > By and large, I would not recommend using a relative pathname to start > the postmaster, unless you plan to start it from the same working > directory every time. Well, now I know. But that really seems like an annoying and arbitrary restriction, not to mention not being documented anywhere AFAICT. (I came upon this problem because I often set up servers with binaries, libraries, and $PGDATA all tucked away under /home/postgres/, and it seemed natural to use a relative pathname as my data directory argument to pg_ctl since my working directory will usually be /home/postgres/ when I'm poking at the server.) > We could possibly avoid this by having pg_ctl try to absolute-ify the -D > setting during postmaster start, but I'm not convinced it's worth the > trouble, or even that it's appropriate for pg_ctl to editorialize on the > user's choice of absolute vs relative path. I don't want to bikeshed on the mechanics of how exactly this should work, but it doesn't seem like it should be so hard to get this to DWIM. In the example I posted, the last step which fails is basically: pg_ctl -D /tmp/foo/bar/baz/ restart and it just seems totally broken for that to not work: pg_ctl knows exactly which data directory the user means when invoked here. Plus, these steps would work fine instead at that point: pg_ctl -D /tmp/foo/bar/baz/ stop pg_ctl -D /tmp/foo/bar/baz/ start and I was under the impression (supported by the pg_ctl doc page, which claims "restart mode effectively executes a stop followed by a start") that these sequences should be equivalent. Josh ^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: 'pg_ctl restart' confused about pathname to postgresql.conf @ 2012-08-16 22:16 Bruce Momjian <bruce@momjian.us> parent: Josh Kupershmidt <schmiddy@gmail.com> 0 siblings, 0 replies; 4+ messages in thread From: Bruce Momjian @ 2012-08-16 22:16 UTC (permalink / raw) To: Josh Kupershmidt <schmiddy@gmail.com>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; pgsql-bugs I have applied the attached doc patch to document the problem with relative paths and pg_ctl restart. --------------------------------------------------------------------------- On Sun, Oct 23, 2011 at 08:49:25PM -0400, Josh Kupershmidt wrote: > On Sat, Oct 22, 2011 at 12:13 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote: > > I think the reason it has a problem is that this is what's left in > > postmaster.opts: > > > > /home/tgl/pgsql/bin/postgres "-D" "baz" > > > > (which is an accurate representation of the command line from startup) > > and that -D switch gets fed to the postmaster as-is during restart. > > I see. > > > By and large, I would not recommend using a relative pathname to start > > the postmaster, unless you plan to start it from the same working > > directory every time. > > Well, now I know. But that really seems like an annoying and arbitrary > restriction, not to mention not being documented anywhere AFAICT. > > (I came upon this problem because I often set up servers with > binaries, libraries, and $PGDATA all tucked away under > /home/postgres/, and it seemed natural to use a relative pathname as > my data directory argument to pg_ctl since my working directory will > usually be /home/postgres/ when I'm poking at the server.) > > > We could possibly avoid this by having pg_ctl try to absolute-ify the -D > > setting during postmaster start, but I'm not convinced it's worth the > > trouble, or even that it's appropriate for pg_ctl to editorialize on the > > user's choice of absolute vs relative path. > > I don't want to bikeshed on the mechanics of how exactly this should > work, but it doesn't seem like it should be so hard to get this to > DWIM. In the example I posted, the last step which fails is basically: > > pg_ctl -D /tmp/foo/bar/baz/ restart > > and it just seems totally broken for that to not work: pg_ctl knows > exactly which data directory the user means when invoked here. Plus, > these steps would work fine instead at that point: > > pg_ctl -D /tmp/foo/bar/baz/ stop > pg_ctl -D /tmp/foo/bar/baz/ start > > and I was under the impression (supported by the pg_ctl doc page, > which claims "restart mode effectively executes a stop followed by a > start") that these sequences should be equivalent. -- Bruce Momjian <bruce@momjian.us> http://momjian.us EnterpriseDB http://enterprisedb.com + It's impossible for everything to be true. + Attachments:^ permalink raw reply [nested|flat] 4+ messages in threadpg_ctl.diff (text/x-diff, 822B) download
diff --git a/doc/src/sgml/ref/pg_ctl-ref.sgml b/doc/src/sgml/ref/pg_ctl-ref.sgml new file mode 100644 index 7a4c2be..3107514 *** a/doc/src/sgml/ref/pg_ctl-ref.sgml --- b/doc/src/sgml/ref/pg_ctl-ref.sgml *************** PostgreSQL documentation *** 188,194 **** <para> <option>restart</option> mode effectively executes a stop followed by a start. This allows changing the <command>postgres</command> ! command-line options. </para> <para> --- 188,196 ---- <para> <option>restart</option> mode effectively executes a stop followed by a start. This allows changing the <command>postgres</command> ! command-line options. <option>restart</option> might fail if ! relative paths specified were specified on the command-line during ! server start. </para> <para>
end of thread, other threads:[~2012-08-16 22:16 UTC | newest] Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2011-10-21 21:51 'pg_ctl restart' confused about pathname to postgresql.conf Josh Kupershmidt <schmiddy@gmail.com> 2011-10-22 16:13 ` Tom Lane <tgl@sss.pgh.pa.us> 2011-10-24 00:49 ` Josh Kupershmidt <schmiddy@gmail.com> 2012-08-16 22:16 ` Bruce Momjian <bruce@momjian.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox