From: | Michael Paquier <michael(dot)paquier(at)gmail(dot)com> |
---|---|
To: | Michael Banck <michael(dot)banck(at)credativ(dot)de> |
Cc: | Bernd Helmle <mailings(at)oopsware(dot)de>, PostgreSQL Development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: [patch] reorder tablespaces in basebackup tar stream for backup_label |
Date: | 2017-03-17 01:50:32 |
Message-ID: | CAB7nPqQWVJnRQ2iJwLTVkE5mcH=W+EP5RV5Wsjm_GXJYKNgBGw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Fri, Mar 17, 2017 at 3:38 AM, Michael Banck
<michael(dot)banck(at)credativ(dot)de> wrote:
>> Your patch would work with the stream mode though.
>
> Or, if not requesting the "WAL" option of the replication protocol's
> BASE_BACKUP command.
>
> I agree it doesn't make sense to start messing with fetch mode, but I
> don't think we guarantee any ordering of tablespaces (to wit, Bernd was
> pretty sure it was the other way around all the time), neither do I
> think having the main tablespace be the first for non-WAL/stream and the
> last for WAL/fetch would be confusing personally, though I understand
> this is debatable.
From the docs:
https://www.postgresql.org/docs/9.6/static/protocol-replication.html
"After the second regular result set, one or more CopyResponse results
will be sent, one for the main data directory and one for each
additional tablespace other than pg_default and pg_global."
So yes there is no guarantee about the order tablespaces are sent.
> So I've updated the patch to only switch the main tablespace to be first
> in case WAL isn't included, please find it attached.
- /* Add a node for the base directory at the end */
+ /* Add a node for the base directory, either at the end or (if
+ * WAL is not included) at the beginning (if WAL is not
+ * included). This means the backup_label file is the first
+ * file to be sent in the latter case. */
ti = palloc0(sizeof(tablespaceinfo));
ti->size = opt->progress ? sendDir(".", 1, true, tablespaces,
true) : -1;
- tablespaces = lappend(tablespaces, ti);
+ if (opt->includewal)
+ tablespaces = lappend(tablespaces, ti);
+ else
+ tablespaces = lcons(ti, tablespaces);
The comment block format is incorrect. I would think as well that this
comment should say it is important to have the main tablespace listed
last it includes the WAL segments, and those need to contain all the
latest WAL segments for a consistent backup.
FWIW, I have no issue with changing the ordering of backups the way
you are proposing here as long as the comment of this code path is
clear.
--
Michael
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Haas | 2017-03-17 02:17:49 | Re: Renaming of pg_xlog and pg_clog |
Previous Message | Robert Haas | 2017-03-17 01:38:40 | Re: ANALYZE command progress checker |