Thread: Trouble with initdb trying to run regression tests

Trouble with initdb trying to run regression tests

From
Isaac Morland
Date:
I've built Postgres inside a Ubuntu Vagrant VM. When I try to "make check", I get a complaint about the permissions on the data directory:

[....]
pg_regress: initdb failed
Examine /vagrant/src/test/regress/log/initdb.log for the reason.
Command was: "initdb" -D "/vagrant/src/test/regress/./tmp_check/data" --no-clean --no-sync > "/vagrant/src/test/regress/log/initdb.log" 2>&1
make[1]: *** [GNUmakefile:125: check] Error 2
make[1]: Leaving directory '/vagrant/src/test/regress'
make: *** [GNUmakefile:69: check] Error 2
vagrant@ubuntu-focal:/vagrant$ tail /vagrant/src/test/regress/log/initdb.log
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 20
selecting default shared_buffers ... 400kB
selecting default time zone ... Etc/UTC
creating configuration files ... ok
running bootstrap script ... 2021-03-30 21:38:32.746 UTC [23154] FATAL:  data directory "/vagrant/src/test/regress/./tmp_check/data" has invalid permissions
2021-03-30 21:38:32.746 UTC [23154] DETAIL:  Permissions should be u=rwx (0700) or u=rwx,g=rx (0750).
child process exited with exit code 1
initdb: data directory "/vagrant/src/test/regress/./tmp_check/data" not removed at user's request
vagrant@ubuntu-focal:/vagrant$ 

Has anybody had this problem? The directory in question is created by the make check activities so I would have thought that it would set the permissions; and if not, then everybody trying to run regression tests would bump into this.

Re: Trouble with initdb trying to run regression tests

From
Tom Lane
Date:
Isaac Morland <isaac.morland@gmail.com> writes:
> I've built Postgres inside a Ubuntu Vagrant VM. When I try to "make check",
> I get a complaint about the permissions on the data directory:

> vagrant@ubuntu-focal:/vagrant$ tail /vagrant/src/test/regress/log/initdb.log
> creating subdirectories ... ok
> selecting dynamic shared memory implementation ... posix
> selecting default max_connections ... 20
> selecting default shared_buffers ... 400kB
> selecting default time zone ... Etc/UTC
> creating configuration files ... ok
> running bootstrap script ... 2021-03-30 21:38:32.746 UTC [23154] FATAL:
>  data directory "/vagrant/src/test/regress/./tmp_check/data" has invalid
> permissions
> 2021-03-30 21:38:32.746 UTC [23154] DETAIL:  Permissions should be u=rwx
> (0700) or u=rwx,g=rx (0750).
> child process exited with exit code 1

Further up in initdb.log, there was probably some useful information
about whether it found an existing directory there or not.

            regards, tom lane



Re: Trouble with initdb trying to run regression tests

From
Isaac Morland
Date:
On Tue, 30 Mar 2021 at 18:39, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Isaac Morland <isaac.morland@gmail.com> writes:
> I've built Postgres inside a Ubuntu Vagrant VM. When I try to "make check",
> I get a complaint about the permissions on the data directory:
[....] 
Further up in initdb.log, there was probably some useful information
about whether it found an existing directory there or not.

Sorry for the noise. Turns out that directory creation in /vagrant does not respect umask:

vagrant@ubuntu-focal:/vagrant$ umask
0027
vagrant@ubuntu-focal:/vagrant$ mkdir test-umask
vagrant@ubuntu-focal:/vagrant$ ls -ld test-umask/
drwxr-xr-x 1 vagrant vagrant 64 Mar 31 01:12 test-umask/
vagrant@ubuntu-focal:/vagrant$ 

I knew that file ownership changes are not processed in /vagrant; and because I remembered that I checked whether permission mode changes were accepted, but didn't think to check whether umask worked. When I tried again (git clone, build, make check) in another directory it worked fine.

I was then able to get the tests to run (and pass) in /vagrant by changing the --temp-instance setting in src/Makefile.global (and looks like I should be able to edit src/Makefile.global.in and re-run configure) to a location outside of /vagrant. Is there a way to tell configure to override the setting? I ask mostly because src/Makefile.global.in says users shouldn't need to edit it. Otherwise my fix will most likely be to maintain a one-line update to this file in my checkout.