BUG #5674: initdb failed if path contains symlink

Lists: pgsql-bugs
From: "Itagaki Takahiro" <itagaki(dot)takahiro(at)gmail(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #5674: initdb failed if path contains symlink
Date: 2010-09-24 06:01:38
Message-ID: 201009240601.o8O61cv5062227@wwwmaster.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs


The following bug has been logged online:

Bug reference: 5674
Logged by: Itagaki Takahiro
Email address: itagaki(dot)takahiro(at)gmail(dot)com
PostgreSQL version: 9.0.0 (32bit)
Operating system: Windows 7 (64bit)
Description: initdb failed if path contains symlink
Details:

Windows 7 supports symbolic links like UNIX,
but initdb cannot initialize a database cluster
if the path (-D) contains symlinks.

> mkdir D:\real
> mklink /D D:\link D:\real
> initdb -D D:\real\pgdata --encoding=UTF8 --locale=C
=> OK
> initdb -D D:\link\pgdata2 --encoding=UTF8 --locale=C
=> could not create directory "D:/link": File exists


From: Itagaki Takahiro <itagaki(dot)takahiro(at)gmail(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5674: initdb failed if path contains symlink
Date: 2010-09-27 10:05:21
Message-ID: AANLkTi=-h4VZGrQ5dn6m8kWmU4_bxyGLspU1Y56bnQ-v@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

On Fri, Sep 24, 2010 at 3:01 PM, Itagaki Takahiro
<itagaki(dot)takahiro(at)gmail(dot)com> wrote:
> Windows 7 supports symbolic links like UNIX,
> but initdb cannot initialize a database cluster
> if the path (-D) contains symlinks.

The bug might come from the following bug by Microsoft:
http://connect.microsoft.com/VisualStudio/feedback/details/595553/stat-function-returns-error-for-directory-symbolic-links

Note that initdb in 8.4 worked expectedly because it is built with MSVC 2005,
but initdb in 9.0 won't work because built with MSVC 2008 :-( .

--
Itagaki Takahiro


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Itagaki Takahiro <itagaki(dot)takahiro(at)gmail(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5674: initdb failed if path contains symlink
Date: 2010-09-27 12:26:32
Message-ID: AANLkTinnid7840ULm0wL2jzqHryeamAS95qEtA2QG0SU@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

On Mon, Sep 27, 2010 at 12:05, Itagaki Takahiro
<itagaki(dot)takahiro(at)gmail(dot)com> wrote:
> On Fri, Sep 24, 2010 at 3:01 PM, Itagaki Takahiro
> <itagaki(dot)takahiro(at)gmail(dot)com> wrote:
>> Windows 7 supports symbolic links like UNIX,
>> but initdb cannot initialize a database cluster
>> if the path (-D) contains symlinks.
>
> The bug might come from the following bug by Microsoft:
> http://connect.microsoft.com/VisualStudio/feedback/details/595553/stat-function-returns-error-for-directory-symbolic-links
>
> Note that initdb in 8.4 worked expectedly because it is built with MSVC 2005,
> but initdb in 9.0 won't work because built with MSVC 2008 :-( .

Ouch.

We could work around it in this place (we could specifically ignore
the "file exists" error on the mkdir call), I guess. But how likely is
that to bite us elsewhere then?

--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: Itagaki Takahiro <itagaki(dot)takahiro(at)gmail(dot)com>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5674: initdb failed if path contains symlink
Date: 2010-09-27 14:14:00
Message-ID: 13399.1285596840@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

Magnus Hagander <magnus(at)hagander(dot)net> writes:
> On Mon, Sep 27, 2010 at 12:05, Itagaki Takahiro
> <itagaki(dot)takahiro(at)gmail(dot)com> wrote:
>> The bug might come from the following bug by Microsoft:
>> http://connect.microsoft.com/VisualStudio/feedback/details/595553/stat-function-returns-error-for-directory-symbolic-links
>>
>> Note that initdb in 8.4 worked expectedly because it is built with MSVC 2005,
>> but initdb in 9.0 won't work because built with MSVC 2008 :-( .

> Ouch.

> We could work around it in this place (we could specifically ignore
> the "file exists" error on the mkdir call), I guess. But how likely is
> that to bite us elsewhere then?

That cure seems worse than the disease. We don't have to support
symlinks in the datadir path; we do have to be sure that we're not
overwriting an existing DB.

I think this is a Microsoft bug and it's their problem to fix, not ours.

regards, tom lane


From: Itagaki Takahiro <itagaki(dot)takahiro(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Magnus Hagander <magnus(at)hagander(dot)net>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5674: initdb failed if path contains symlink
Date: 2010-09-28 01:28:53
Message-ID: AANLkTi=RxTQR9aATNk3eyVJx5y254iRfmNoaiD6xJac-@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

> Magnus Hagander <magnus(at)hagander(dot)net> writes:
>> But how likely is that to bite us elsewhere then?

Initdb works well if the link is a junction (mklink /J).
We use junctions for tablespaces, but don't use symbolic links.
So, there are no problems unless users create symlinks by themselves.

On Mon, Sep 27, 2010 at 11:14 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> I think this is a Microsoft bug and it's their problem to fix, not ours.

OK, but bad news is that the bug is in VC 2008, but they have not
fixed it even in VC 2010. I'm not sure they will fix it in the future...

--
Itagaki Takahiro


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Itagaki Takahiro <itagaki(dot)takahiro(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5674: initdb failed if path contains symlink
Date: 2010-09-28 09:08:54
Message-ID: AANLkTikjmvE+m4NKu3E9_m576g2vtwtrA7Yo8JWa+qnv@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

On Tue, Sep 28, 2010 at 03:28, Itagaki Takahiro
<itagaki(dot)takahiro(at)gmail(dot)com> wrote:
>> Magnus Hagander <magnus(at)hagander(dot)net> writes:
>>> But how likely is that to bite us elsewhere then?
>
> Initdb works well if the link is a junction (mklink /J).
> We use junctions for tablespaces, but don't use symbolic links.
> So, there are no problems unless users create symlinks by themselves.

Right. But the whole thing isn o problem unless the user creates a
symlink by themself, no?

> On Mon, Sep 27, 2010 at 11:14 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> I think this is a Microsoft bug and it's their problem to fix, not ours.
>
> OK, but bad news is that the bug is in VC 2008, but they have not
> fixed it even in VC 2010. I'm not sure they will fix it in the future...

Yeah, that's always a problem with proprietary platforms :(

Should we publish a list of known issues that aren't in our hands
somewhere, like the wiki?

--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Itagaki Takahiro <itagaki(dot)takahiro(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5674: initdb failed if path contains symlink
Date: 2010-09-28 09:11:39
Message-ID: AANLkTik-r7jYwyPaKxFG6Gm1T12A--1-uX3A1wkkt1NL@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

On Tue, Sep 28, 2010 at 11:08, Magnus Hagander <magnus(at)hagander(dot)net> wrote:
> On Tue, Sep 28, 2010 at 03:28, Itagaki Takahiro
> <itagaki(dot)takahiro(at)gmail(dot)com> wrote:
>> On Mon, Sep 27, 2010 at 11:14 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>>> I think this is a Microsoft bug and it's their problem to fix, not ours.
>>
>> OK, but bad news is that the bug is in VC 2008, but they have not
>> fixed it even in VC 2010. I'm not sure they will fix it in the future...

Actually, looking at the bug page the bug seems to have been reported
on sep 6th (or is that june 9th? depends on what date style they're
using). It might be too early to say they won't fix it - I'm not sure
they've even had a release since then?

--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/