Re: [HACKERS] [patch] reorder tablespaces in basebackup tar streamfor backup_label - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: [HACKERS] [patch] reorder tablespaces in basebackup tar streamfor backup_label
Date
Msg-id CAB7nPqQXRVxrHX2=XFrx+7VGNxm9J1ka6HgD6Ou0xzB3iNdSHQ@mail.gmail.com
Whole thread Raw
In response to Re: [HACKERS] [patch] reorder tablespaces in basebackup tar streamfor backup_label  (Bernd Helmle <mailings@oopsware.de>)
Responses Re: [HACKERS] [patch] reorder tablespaces in basebackup tar streamfor backup_label
Re: [HACKERS] [patch] reorder tablespaces in basebackup tar streamfor backup_label
List pgsql-hackers
On Wed, Feb 22, 2017 at 9:23 PM, Bernd Helmle <mailings@oopsware.de> wrote:
> The comment in the code says explicitely to add the base directory to
> the end of the list, not sure if that is out of a certain reason.
>
> I'd say this is an oversight in the implementation. I'm currently
> working on a tool using the streaming protocol directly and i've
> understood it exactly the way, that the default tablespace is the first
> one in the stream.
>
> So +1 for the patch.

Commit 507069de has switched the main directory from the beginning to
the end of the list, and the thread about this commit is here:
https://www.postgresql.org/message-id/AANLkTikgmZRkBuQ%2B_hcwPBv7Cd7xW48Ev%3DUBHA-k4v0W%40mail.gmail.com

+       /* Add a node for the base directory at the beginning.  This way, the
+        * backup_label file is always the first file to be sent. */       ti = palloc0(sizeof(tablespaceinfo));
ti->size= opt->progress ? sendDir(".", 1, true, tablespaces,
 
true) : -1;
-       tablespaces = lappend(tablespaces, ti);
+       tablespaces = lcons(ti, tablespaces);
So, the main directory is located at the end on purpose. When using
--wal-method=fetch the WAL segments are part of the main tarball, so
if you send the main tarball first you would need to generate a second
tarball with the WAL segments that have been generated between the
moment the main tarball has finished until the end of the last
tablespace taken if you want to have a consistent backup. Your patch
would work with the stream mode though.
-- 
Michael



pgsql-hackers by date:

Previous
From: Fabien COELHO
Date:
Subject: Re: [HACKERS] \if, \elseif, \else, \endif (was Re: PSQL commands:\quit_if, \quit_unless)
Next
From: Corey Huinker
Date:
Subject: Re: [HACKERS] \if, \elseif, \else, \endif (was Re: PSQL commands:\quit_if, \quit_unless)