pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Phil Endecott <spam_from_pgsql_lists@chezphil.org>
To: David Steele <david@pgmasters.net>
To: pgsql-general@lists.postgresql.org
Subject: Re: During promotion, new master tries to archive same segment twice
Date: Thu, 16 Aug 2018 09:37:37 +0100
Message-ID: <1534408657322@dmwebmail.dmwebmail.chezphil.org> (raw)
In-Reply-To: <11b405a6-2176-9510-bf5b-ea9c0e860635@pgmasters.net>
References: <11b405a6-2176-9510-bf5b-ea9c0e860635@pgmasters.net>

David Steele wrote:
> On 8/15/18 4:25 PM, Phil Endecott wrote:
>> - Should my archive_command detect the case where it is asked to 
>> write the same file again with the same contents, and report 
>> success in that case?
>
> Yes.

> There are a number of cases where the same WAL
> segment can be pushed more than once, especially after failures where
> Postgres is not sure that the command completed.  The archive command
> should handle this gracefully.


Hmm, OK.  Here's what the current docs say:

Section 25.3.1:

"The archive command should generally be designed to refuse to
overwrite any pre-existing archive file. This is an important
safety feature to preserve the integrity of your archive in case
of administrator error (such as sending the output of two
different servers to the same archive directory).

It is advisable to test your proposed archive command to ensure
that it indeed does not overwrite an existing file, and that it
returns nonzero status in this case."

And section 26.2.9:

"When continuous WAL archiving is used in a standby, there
are two different scenarios: the WAL archive can be shared
between the primary and the standby, or the standby can
have its own WAL archive.  When the standby has its own WAL
archive, set archive_mode to always, and the standby will call
the archive command for every WAL segment it receives, whether
it's by restoring from the archive or by streaming replication.
The shared archive can be handled similarly, but the
archive_command must test if the file being archived exists
already, and if the existing file has identical contents.
This requires more care in the archive_command, as it must be
careful to not overwrite an existing file with different contents,
but return success if the exactly same file is archived twice.
And all that must be done free of race conditions, if two
servers attempt to archive the same file at the same time."


So you're saying that that's wrong, and that I must always
handle the case when the same WAL segment is written twice.

I'll file a bug against the documentation.


> pgBackRest has done this for years and it saves a *lot* of headaches.

The system to which I am sending the WAL files is a rsync.net
account.  I use it because of its reliability, but methods for
transferring files are limited largely to things like scp and
rsync.


Thanks, Phil.








view thread (9+ messages)  latest in thread

Message-ID: <1534408657322@dmwebmail.dmwebmail.chezphil.org>
Permalink:  ../1534408657322@dmwebmail.dmwebmail.chezphil.org/
Also on:    postgresql.org/message-id/1534408657322@dmwebmail.dmwebmail.chezphil.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: spam_from_pgsql_lists@chezphil.org, david@pgmasters.net
  Subject: Re: During promotion, new master tries to archive same segment twice
  In-Reply-To: <1534408657322@dmwebmail.dmwebmail.chezphil.org>
  References: <11b405a6-2176-9510-bf5b-ea9c0e860635@pgmasters.net> <1534408657322@dmwebmail.dmwebmail.chezphil.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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