Unix Technical Forum

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

This is a discussion on BUG #4092: initdb fails if the xlog directory is the same as [pg_data]/pg_xlog within the pgsql Bugs forums, part of the PostgreSQL category; --> The following bug has been logged online: Bug reference: 4092 Logged by: Peter Koczan Email address: pjkoczan@gmail.com PostgreSQL version: ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Bugs

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-10-2008, 12:16 PM
Peter Koczan
 
Posts: n/a
Default BUG #4092: initdb fails if the xlog directory is the same as [pg_data]/pg_xlog


The following bug has been logged online:

Bug reference: 4092
Logged by: Peter Koczan
Email address: pjkoczan@gmail.com
PostgreSQL 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@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-10-2008, 12:16 PM
Tom Lane
 
Posts: n/a
Default Re: BUG #4092: initdb fails if the xlog directory is the same as [pg_data]/pg_xlog

"Peter Koczan" <pjkoczan@gmail.com> writes:
> 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


That conclusion seems both a leap of logic, and unportable. You might
get some other errno depending on the platform and filesystem.

> 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.


I don't really concur that ignoring a bogus switch specification is
a good idea.

regards, tom lane

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 12:58 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com