Обсуждение: BUG #13853: initdb to UNC path

Поиск
Список
Период
Сортировка

BUG #13853: initdb to UNC path

От
NBoardman@idtus.com
Дата:
The following bug has been logged on the website:

Bug reference:      13853
Logged by:          Nuri Boardman
Email address:      NBoardman@idtus.com
PostgreSQL version: 9.4.2
Operating system:   Windows 7
Description:

when i run this command (initdb with UNC path)
pg_ctl initdb -D \\localhost\Users\nboardman\test

i get the following (error) output

The files belonging to this database system will be owned by user
"NBoardman".
This user must also own the server process.

The database cluster will be initialized with locale "English_United
States.1252
".
The default database encoding has accordingly been set to "WIN1252".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory //localhost/Users/nboardman/test
... ok

creating subdirectories ... initdb: could not create directory
"//localhost/User
s": File exists
initdb: removing contents of data directory
"//localhost/Users/nboardman/test"
pg_ctl: database system initialization failed

finally, if this is illegal, the documentation does not indicate the path
has to be a windows path
from http://www.postgresql.org/docs/9.4/static/app-initdb.html

-D directory
--pgdata=directory
This option specifies the directory where the database cluster should be
stored. This is the only information required by initdb, but you can avoid
writing it by setting the PGDATA environment variable, which can be
convenient since the database server (postgres) can find the database
directory later by the same variable.

Re: BUG #13853: initdb to UNC path

От
John R Pierce
Дата:
On 1/7/2016 8:14 AM, NBoardman@idtus.com wrote:
> The following bug has been logged on the website:
>
> Bug reference:      13853
> Logged by:          Nuri Boardman
> Email address:NBoardman@idtus.com
> PostgreSQL version: 9.4.2
> Operating system:   Windows 7
> Description:
>
> when i run this command (initdb with UNC path)
> pg_ctl initdb -D \\localhost\Users\nboardman\test
>
> i get the following (error) output
>
> The files belonging to this database system will be owned by user
> "NBoardman".
> This user must also own the server process.
>
> The database cluster will be initialized with locale "English_United
> States.1252
> ".
> The default database encoding has accordingly been set to "WIN1252".
> The default text search configuration will be set to "english".
>
> Data page checksums are disabled.
>
> fixing permissions on existing directory //localhost/Users/nboardman/test
> ... ok
>
> creating subdirectories ... initdb: could not create directory
> "//localhost/Users": File exists
> initdb: removing contents of data directory
> "//localhost/Users/nboardman/test"
> pg_ctl: database system initialization failed
>
> finally, if this is illegal, the documentation does not indicate the path
> has to be a windows path
> fromhttp://www.postgresql.org/docs/9.4/static/app-initdb.html

does it work if you leave out the \\localhost part?   using network
paths for database storage is NOT recommended.

the documentation is OS independent, things like 'paths' are OS specific

--
john r pierce, recycling bits in santa cruz

Re: BUG #13853: initdb to UNC path

От
Tom Lane
Дата:
John R Pierce <pierce@hogranch.com> writes:
> On 1/7/2016 8:14 AM, NBoardman@idtus.com wrote:
>> fixing permissions on existing directory //localhost/Users/nboardman/test
>> ... ok
>>
>> creating subdirectories ... initdb: could not create directory
>> "//localhost/Users": File exists

Hm.  AFAICS, this failure must have occurred inside pg_mkdir_p, and what
it implies is that stat(2) either failed entirely for "//localhost/Users",
or claimed it isn't a directory.  Either one seems more like a system
problem than our problem.

> does it work if you leave out the \\localhost part?   using network
> paths for database storage is NOT recommended.

This is true, and it's not an unreasonable bet that stat() is misbehaving
because it's a network path.

Having said that, I wonder why initdb is coded to use pg_mkdir_p rather
than plain mkdir for creating subdirectories after the datadir has been
created.  There is basically no advantage there, and there's certainly
scope for things to go wrong, as this example shows.

            regards, tom lane

Re: BUG #13853: initdb to UNC path

От
Nuri Boardman
Дата:
This command

pg_ctl.exe initdb -D localhost\Users\nboardman\test
just creates the whole DB locally starting at the current directory, and th=
en going .\localhost\Users\... etc

-----Original Message-----
From: Tom Lane [mailto:tgl@sss.pgh.pa.us]=20
Sent: Thursday, January 07, 2016 2:21 PM
To: John R Pierce
Cc: Nuri Boardman; pgsql-bugs@postgresql.org
Subject: Re: [BUGS] BUG #13853: initdb to UNC path

John R Pierce <pierce@hogranch.com> writes:
> On 1/7/2016 8:14 AM, NBoardman@idtus.com wrote:
>> fixing permissions on existing directory=20
>> //localhost/Users/nboardman/test ... ok
>>=20
>> creating subdirectories ... initdb: could not create directory
>> "//localhost/Users": File exists

Hm.  AFAICS, this failure must have occurred inside pg_mkdir_p, and what it=
 implies is that stat(2) either failed entirely for "//localhost/Users", or=
 claimed it isn't a directory.  Either one seems more like a system problem=
 than our problem.

> does it work if you leave out the \\localhost part?   using network=20
> paths for database storage is NOT recommended.

This is true, and it's not an unreasonable bet that stat() is misbehaving b=
ecause it's a network path.

Having said that, I wonder why initdb is coded to use pg_mkdir_p rather tha=
n plain mkdir for creating subdirectories after the datadir has been create=
d.  There is basically no advantage there, and there's certainly scope for =
things to go wrong, as this example shows.

            regards, tom lane