Re: pg_tablespace_location() failure with allow_in_place_tablespaces

From: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
To: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: pg_tablespace_location() failure with allow_in_place_tablespaces
Date: 2022-03-04 10:26:43
Message-ID: CA+hUKGKBDf09=drRsTWj-gTD7r-sFiVE1iWrwuKQJfMhZjRYoQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Mar 4, 2022 at 10:04 PM Kyotaro Horiguchi
<horikyota(dot)ntt(at)gmail(dot)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 Content-Type Size
0001-Fix-warning-in-basebackup-of-in-place-tablespaces.patch text/x-patch 1.3 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2022-03-04 10:40:51 Re: pg_tablespace_location() failure with allow_in_place_tablespaces
Previous Message Bharath Rupireddy 2022-03-04 10:23:59 Re: pg_walinspect - a new extension to get raw WAL data and WAL stats