Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql Bugs > BUG #4092: init...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 2 Topic 3682 of 3896
Post > Topic >>

BUG #4092: initdb fails if the xlog directory is the same as [pg_data]/pg_xlog

by pjkoczan@[EMAIL PROTECTED] ("Peter Koczan") Apr 4, 2008 at 10:11 PM

The following bug has been logged online:

Bug reference:      4092
Logged by:          Peter Koczan
Email address:      pjkoczan@[EMAIL PROTECTED]
 version: 8.3.1
Operating system:   Red Hat Enterprise Linux 5
Description:        initdb fails if the xlog directory is the same as
[pg_data]/pg_xlog
Details: 

If you call initdb where you specify pg_xlog (-X option) to be in the
"normal" place, it fails when creating the symlink. For instance. 

$ initdb -X /local/postgres/pg_xlog /local/postgres
....
initdb: could not create symbolic link: File exists
initdb: removing data directory /local/postgres
(more cleanup)
....

This is a problem for people like me who use an auto-config tool to help
manage their database clusters. It would also be nice in the case that a
wrapper script (what I currently use) can't detect that the directories
would be the same, either from relative paths or existing symlinks.

Submitted for your approval is a patch to src/bin/initdb/initdb.c that
corrects this by looking at the errno generated from the symlink call. If
it's EEXIST, that means that it tried to symlink pg_xlog to itself (and
failed) and the existing pg_xlog directory remains. Basically, initdb runs
as if it ignored -X and politely informs the user that the symlink failed.

Peter

Index: src/bin/initdb/initdb.c
===================================================================
RCS file:
/s/postgresql-8.3.1/src/CVSROOT/postgresql-8.3.1/src/bin/initdb/initdb.c,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 initdb.c
*** src/bin/initdb/initdb.c     31 Mar 2008 20:26:30 -0000      1.1.1.1
--- src/bin/initdb/initdb.c     4 Apr 2008 21:19:45 -0000
***************
*** 3068,3076 ****
  #ifdef HAVE_SYMLINK
                if (symlink(xlog_dir, linkloc) != 0)
                {
!                       fprintf(stderr, _("%s: could not create symbolic
link \"%s\": %s\n"),
!                                       progname, linkloc,
strerror(errno));
!                       exit_nicely();
                }
  #else
                fprintf(stderr, _("%s: symlinks are not supported on this
platform"));
--- 3068,3083 ----
  #ifdef HAVE_SYMLINK
                if (symlink(xlog_dir, linkloc) != 0)
                {
!                       if (errno == EEXIST)
!                       {
!                               fprintf(stderr, _("%s: Attempted to
symlink
pg_xlog to itself...Skipping...\n"), progname);
!                       }
!                       else
!                       {
!                               fprintf(stderr, _("%s: could not create
symbolic link \"%s\": %s\n"),
!                                               progname, linkloc,
strerror(errno));
!                               exit_nicely();
!                       }
                }
  #else
                fprintf(stderr, _("%s: symlinks are not supported on this
platform"));

-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@[EMAIL PROTECTED]
)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs




 2 Posts in Topic:
BUG #4092: initdb fails if the xlog directory is the same as [pg
pjkoczan@[EMAIL PROTECTED  2008-04-04 22:11:25 
Re: BUG #4092: initdb fails if the xlog directory is the same as
tgl@[EMAIL PROTECTED] (T  2008-04-05 11:26:46 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan13V112 Fri Jul 4 14:09:39 CDT 2008.