pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: At promotion, archive last segment from old timeline with .parti
5+ messages / 4 participants
[nested] [flat]

* pgsql: At promotion, archive last segment from old timeline with .parti
@ 2015-05-08 19:07  Heikki Linnakangas <heikki.linnakangas@iki.fi>
  0 siblings, 2 replies; 5+ messages in thread

From: Heikki Linnakangas @ 2015-05-08 19:07 UTC (permalink / raw)
  To: pgsql-committers

At promotion, archive last segment from old timeline with .partial suffix.

Previously, we would archive the possible-incomplete WAL segment with its
normal filename, but that causes trouble if the server owning that timeline
is still running, and tries to archive the same segment later. It's not nice
for the standby to trip up the master's archival like that. And it's pretty
confusing, anyway, to have an incomplete segment in the archive that's
indistinguishable from a normal, complete segment.

To avoid such confusion, add a .partial suffix to the file. Or to be more
precise, make a copy of the old segment under the .partial suffix, and
archive that instead of the original file. pg_receivexlog also uses the
.partial suffix for the same purpose, to tell apart incompletely streamed
files from complete ones.

There is no automatic mechanism to use the .partial files at recovery, so
they will go unused, unless the administrator manually copies to them to
the pg_xlog directory (and removes the .partial suffix). Recovery won't
normally need the WAL - when recovering to the new timeline, it will find
the same WAL on the first segment on the new timeline instead - but it
nevertheless feels better to archive the file with the .partial suffix, for
debugging purposes if nothing else.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/de7688442f5aaa03da60416a6aa3474738718803

Modified Files
--------------
src/backend/access/transam/xlog.c  |  133 +++++++++++++++++++++++++++---------
src/include/access/xlog_internal.h |    5 ++
src/include/postmaster/pgarch.h    |    2 +-
3 files changed, 107 insertions(+), 33 deletions(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: pgsql: At promotion, archive last segment from old timeline with .parti
@ 2015-05-22 09:35  Fujii Masao <masao.fujii@gmail.com>
  parent: Heikki Linnakangas <heikki.linnakangas@iki.fi>
  1 sibling, 1 reply; 5+ messages in thread

From: Fujii Masao @ 2015-05-22 09:35 UTC (permalink / raw)
  To: Heikki Linnakangas <heikki.linnakangas@iki.fi>; +Cc: pgsql-committers

On Sat, May 9, 2015 at 4:07 AM, Heikki Linnakangas
<heikki.linnakangas@iki.fi> wrote:
> At promotion, archive last segment from old timeline with .partial suffix.
>
> Previously, we would archive the possible-incomplete WAL segment with its
> normal filename, but that causes trouble if the server owning that timeline
> is still running, and tries to archive the same segment later. It's not nice
> for the standby to trip up the master's archival like that. And it's pretty
> confusing, anyway, to have an incomplete segment in the archive that's
> indistinguishable from a normal, complete segment.
>
> To avoid such confusion, add a .partial suffix to the file. Or to be more
> precise, make a copy of the old segment under the .partial suffix, and
> archive that instead of the original file. pg_receivexlog also uses the
> .partial suffix for the same purpose, to tell apart incompletely streamed
> files from complete ones.
>
> There is no automatic mechanism to use the .partial files at recovery, so
> they will go unused, unless the administrator manually copies to them to
> the pg_xlog directory (and removes the .partial suffix). Recovery won't
> normally need the WAL - when recovering to the new timeline, it will find
> the same WAL on the first segment on the new timeline instead - but it
> nevertheless feels better to archive the file with the .partial suffix, for
> debugging purposes if nothing else.

Doesn't this change break the case where we want to PITR to the recovery
target location in the last partial WAL file with the old timeline?
In this case, that partial WAL file needs to be read and replayed. But
since the suffix of its filename is .partial, unless DBA gets rid of the suffix,
the WAL file cannot be restored and PITR would fail. No?

Regards,

-- 
Fujii Masao


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: [COMMITTERS] pgsql: At promotion, archive last segment from old timeline with .parti
@ 2015-05-22 09:59  Heikki Linnakangas <hlinnaka@iki.fi>
  parent: Fujii Masao <masao.fujii@gmail.com>
  0 siblings, 1 reply; 5+ messages in thread

From: Heikki Linnakangas @ 2015-05-22 09:59 UTC (permalink / raw)
  To: Fujii Masao <masao.fujii@gmail.com>; +Cc: pgsql-hackers <pgsql-hackers@postgresql.org>

On 05/22/2015 12:35 PM, Fujii Masao wrote:
> Doesn't this change break the case where we want to PITR to the recovery
> target location in the last partial WAL file with the old timeline?
> In this case, that partial WAL file needs to be read and replayed. But
> since the suffix of its filename is .partial, unless DBA gets rid of the suffix,
> the WAL file cannot be restored and PITR would fail. No?

PITR to a specific location always requires manual intervention by the 
DBA anyway. It's not something you'd automate. Copying the .partial file 
manually into pg_xlog is just one small extra step.

Even if there are some downsides to this, I think it's just plain evil 
to archive a partial segment that looks indistinguishable from a 
complete one. We have had reports of that causing confusion in 
production systems. What if the master had already archived the complete 
version of the segment before dying? The standby will try to archive a 
partial version of the same, which will fail, or worse, overwrite the 
complete version with the partial one.

Note that PITR in that scenario was always hit-and-miss. First of all, 
if the master died, there is no guarantee that it archived all the 
previous segments successfully before dying. (archive_mode=always 
alleviates that in 9.5, as the standby will archive them even if the 
master didn't).

(See discussion on this point at 
http://www.postgresql.org/message-id/5535FE71.1010905@iki.fi)

- Heikki



-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: [COMMITTERS] pgsql: At promotion, archive last segment from old timeline with .parti
@ 2015-05-22 12:15  Fujii Masao <masao.fujii@gmail.com>
  parent: Heikki Linnakangas <hlinnaka@iki.fi>
  0 siblings, 0 replies; 5+ messages in thread

From: Fujii Masao @ 2015-05-22 12:15 UTC (permalink / raw)
  To: Heikki Linnakangas <hlinnaka@iki.fi>; +Cc: pgsql-hackers <pgsql-hackers@postgresql.org>

On Fri, May 22, 2015 at 6:59 PM, Heikki Linnakangas <hlinnaka@iki.fi> wrote:
> On 05/22/2015 12:35 PM, Fujii Masao wrote:
>>
>> Doesn't this change break the case where we want to PITR to the recovery
>> target location in the last partial WAL file with the old timeline?
>> In this case, that partial WAL file needs to be read and replayed. But
>> since the suffix of its filename is .partial, unless DBA gets rid of the
>> suffix,
>> the WAL file cannot be restored and PITR would fail. No?
>
>
> PITR to a specific location always requires manual intervention by the DBA
> anyway. It's not something you'd automate. Copying the .partial file
> manually into pg_xlog is just one small extra step.

We should document this? Otherwise no DBA can complete such PITR scenario.

Also as a safeguard, if the required WAL file is not found but the file with
.parital suffix found during recovery, maybe we should cause the recovery to
fail at that moment. Otherwise since the required file is not found, the server
would end the recovery before the .partial file and start normal processing.
DBA may not be able to notice this incompletion of the recovery.
Maybe this is overkill against the small use case, though.

> Even if there are some downsides to this, I think it's just plain evil to
> archive a partial segment that looks indistinguishable from a complete one.
> We have had reports of that causing confusion in production systems. What if
> the master had already archived the complete version of the segment before
> dying? The standby will try to archive a partial version of the same, which
> will fail, or worse, overwrite the complete version with the partial one.
>
> Note that PITR in that scenario was always hit-and-miss. First of all, if
> the master died, there is no guarantee that it archived all the previous
> segments successfully before dying. (archive_mode=always alleviates that in
> 9.5, as the standby will archive them even if the master didn't).

So we don't need to rename the last WAL file basically in archive recovery
case even if it's read from pg_xlog, i.e., it's partial. No?

Regards,

-- 
Fujii Masao


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: pgsql: At promotion, archive last segment from old timeline with .parti
@ 2015-05-22 16:05  Peter Eisentraut <peter_e@gmx.net>
  parent: Heikki Linnakangas <heikki.linnakangas@iki.fi>
  1 sibling, 0 replies; 5+ messages in thread

From: Peter Eisentraut @ 2015-05-22 16:05 UTC (permalink / raw)
  To: Heikki Linnakangas <heikki.linnakangas@iki.fi>; pgsql-committers

On 5/8/15 3:07 PM, Heikki Linnakangas wrote:
> At promotion, archive last segment from old timeline with .partial suffix.

There appears to be a mixup here:

+               char        origpath[MAXPGPATH];
+               char        partialfname[MAXFNAMELEN];
+               char        partialpath[MAXPGPATH];
+
+               XLogFilePath(origpath, EndOfLogTLI, endLogSegNo);
+               snprintf(partialfname, MAXPGPATH, "%s.partial", origfname);
+               snprintf(partialpath, MAXPGPATH, "%s.partial", origpath);

Some compilers are complaining that the snprintf(partialfname, ...)
could overflow.



-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers



^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2015-05-22 16:05 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2015-05-08 19:07 pgsql: At promotion, archive last segment from old timeline with .parti Heikki Linnakangas <heikki.linnakangas@iki.fi>
2015-05-22 09:35 ` Fujii Masao <masao.fujii@gmail.com>
2015-05-22 09:59   ` Heikki Linnakangas <hlinnaka@iki.fi>
2015-05-22 12:15     ` Fujii Masao <masao.fujii@gmail.com>
2015-05-22 16:05 ` Peter Eisentraut <peter_e@gmx.net>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox