Re: pg_tablespace_location() failure with allow_in_place_tablespaces - Mailing list pgsql-hackers

From Thomas Munro
Subject Re: pg_tablespace_location() failure with allow_in_place_tablespaces
Date
Msg-id CA+hUKGKBDf09=drRsTWj-gTD7r-sFiVE1iWrwuKQJfMhZjRYoQ@mail.gmail.com
Whole thread Raw
In response to Re: pg_tablespace_location() failure with allow_in_place_tablespaces  (Kyotaro Horiguchi <horikyota.ntt@gmail.com>)
Responses Re: pg_tablespace_location() failure with allow_in_place_tablespaces
Re: pg_tablespace_location() failure with allow_in_place_tablespaces
List pgsql-hackers
On Fri, Mar 4, 2022 at 10:04 PM Kyotaro Horiguchi
<horikyota.ntt@gmail.com> wrote:
> And I made a quick hack on do_pg_start_backup.  And I found that
> pg_basebackup copies in-place tablespaces under the *current
> directory*, which is not ok at all:(

Hmm.  Which OS are you on?  Looks OK here -- the "in place" tablespace
gets copied as a directory under pg_tblspc, no symlink:

postgres=# set allow_in_place_tablespaces = on;
SET
postgres=# create tablespace ts1 location '';
CREATE TABLESPACE
postgres=# create table t (i int) tablespace ts1;
CREATE TABLE
postgres=# insert into t values (1), (2);
INSERT 0 2
postgres=# create user replication replication;
CREATE ROLE

$ pg_basebackup --user replication  -D pgdata2
$ ls -slaph pgdata/pg_tblspc/
total 4.0K
   0 drwx------  3 tmunro tmunro   19 Mar  4 23:16 ./
4.0K drwx------ 19 tmunro tmunro 4.0K Mar  4 23:16 ../
   0 drwx------  3 tmunro tmunro   29 Mar  4 23:16 16384/
$ ls -slaph pgdata2/pg_tblspc/
total 4.0K
   0 drwx------  3 tmunro tmunro   19 Mar  4 23:16 ./
4.0K drwx------ 19 tmunro tmunro 4.0K Mar  4 23:16 ../
   0 drwx------  3 tmunro tmunro   29 Mar  4 23:16 16384/
$ ls -slaph pgdata/pg_tblspc/16384/PG_15_202203031/5/
total 8.0K
   0 drwx------ 2 tmunro tmunro   19 Mar  4 23:16 ./
   0 drwx------ 3 tmunro tmunro   15 Mar  4 23:16 ../
8.0K -rw------- 1 tmunro tmunro 8.0K Mar  4 23:16 16385
$ ls -slaph pgdata2/pg_tblspc/16384/PG_15_202203031/5/
total 8.0K
   0 drwx------ 2 tmunro tmunro   19 Mar  4 23:16 ./
   0 drwx------ 3 tmunro tmunro   15 Mar  4 23:16 ../
8.0K -rw------- 1 tmunro tmunro 8.0K Mar  4 23:16 16385

The warning from readlink() while making the mapping file isn't ideal,
and perhaps we should suppress that with something like the attached.
Or does the missing map file entry break something on Windows?

Attachment

pgsql-hackers by date:

Previous
From: Bharath Rupireddy
Date:
Subject: Re: pg_walinspect - a new extension to get raw WAL data and WAL stats
Next
From: Michael Paquier
Date:
Subject: Re: pg_tablespace_location() failure with allow_in_place_tablespaces