At Thu, 06 Apr 2017 00:59:49 +0200, Pierre Ducroquet <p.p...@pinaraf.info> wrote in <2008148.rxBNyNRHPZ@peanuts2> > But it all gets messy when we want to create a streaming standby server using > pg_basebackup. When backuping Pg 9.5, there is no issue, but backuping Pg 9.6 > afterwards will say "directory "/mnt/ssd/postgres" exists but is not empty".
The documentation says as follows. https://www.postgresql.org/docs/9.6/static/manage-ag-tablespaces.html | The location must be an existing, empty directory that is owned | by the PostgreSQL operating system user. This explicitly prohibits to share one tablespace directory among multiple servers. The code is just missing the case of multiple servers with different versions. I think the bug is rather that Pg9.6 in the case allowed to create the tablespace. The current naming rule of tablespace directory was introduced as of 9.0 so that pg_upgrade (or pg_migrator at the time) can perform in-place migration. It is not intended to share a directory among multiple instances with different versions. That being said, an additional trick in the attached file will work for you. regards, -- Kyotaro Horiguchi NTT Open Source Software Center
--- reproduce-bug-tblspace.sh 2017-04-06 13:49:10.657803383 +0900 +++ reproduce-bug-tblspace.sh.new 2017-04-06 13:48:45.870024586 +0900 @@ -48,3 +48,14 @@ echo "************************ SECOND BASEBACKUP ************************" -echo "Expecting it to fail with 'directory \"/tmp/pg_bug_backup_tblspace/dest_server/tblspc\" exists but is not empty'" + +echo "stashing tablespace directories of the first backup" +cd .. +mv tblspc tblspc.tmp +mkdir tblspc +cd datas + $PG2/pg_basebackup -h /tmp -p $PORT2 -D pg2 --tablespace-mapping=/tmp/pg_bug_backup_tblspace/source_server/tblspc=/tmp/pg_bug_backup_tblspace/dest_server/tblspc + +echo "merging tablespace directories" +cd .. +mv tblspc.tmp/* tblspc/ +rmdir tblspc.tmp
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers