Re: Sample archive_command is still problematic

From: Josh Berkus <josh(at)agliodbs(dot)com>
To: Kevin Grittner <kgrittn(at)ymail(dot)com>, "pgsql-docs(at)postgresql(dot)org" <pgsql-docs(at)postgresql(dot)org>
Subject: Re: Sample archive_command is still problematic
Date: 2014-08-11 17:59:36
Message-ID: 53E90488.9040103@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

On 08/11/2014 10:21 AM, Kevin Grittner wrote:
>> Is there some good reason why "test ! -f" was added to the
>> sample?
>
> In an environment with more than one cluster archiving, it is
> otherwise way too easy to copy a config file and have the WAL files
> of the two systems overwriting one another. I consider a check for
> an already existing file on the target to be very good practice.
> The errors in the log are a clue that something went wrong, and
> gives you a chance to fix things without data loss.

It depends on what you're guarding against. In the case I was dealing
with, the master crashed in the middle of an archive write. As a
result, the file existed, but was incomplete, and *needed* to be
overwritten. But because of 'test -f' archiving just kept failing.

> The problem with the recommended command is that cp is not atomic.
> The file can be read before the contents are materialized, causing
> early end to recovery. I have seen it happen. The right way to do
> this is to copy to a different name or directory and mv the file
> into place once it is complete -- or use software which does that
> automatically, like rsync does.

Yeah, realistically, I think we need to start supplying a script or two
in /contrib and referencing that. I'm not sure how to make it work for
the Windows users though.

--
Josh Berkus
PostgreSQL Experts Inc.
http://pgexperts.com

In response to

Responses

Browse pgsql-docs by date

  From Date Subject
Next Message Kevin Grittner 2014-08-11 18:36:28 Re: Sample archive_command is still problematic
Previous Message Kevin Grittner 2014-08-11 17:21:26 Re: Sample archive_command is still problematic