pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Laurenz Albe <laurenz.albe@cybertec.at>
To: Nagy László Zsolt <gandalf@shopzeus.com>
To: pgsql-admin@postgresql.org
Subject: Re: Reliable WAL file shipping over unreliable network
Date: Wed, 28 Feb 2018 21:12:11 +0100
Message-ID: <1519848731.2350.5.camel@cybertec.at> (raw)
In-Reply-To: <dd116172-3ddf-ee56-57f3-6e18d49abf8e@shopzeus.com>
References: <dd116172-3ddf-ee56-57f3-6e18d49abf8e@shopzeus.com>

Nagy László Zsolt wrote:
> Let's suppose that a replication master is writting a WAL segment file
> into a directory. That directory is mounted on the replication slave. Is
> it possible that the slave will try to read a WAL segment file that is
> not yet fully flushed to disk? I did not find any requirement in the
> official documentation about this. How does it work? Do I have to copy
> segments to temp files, and rename them when they are fully flushed to
> disk? Or is it okay to have half complete files in the archive dir for a
> while?

I suppose you are talking about "archive_command" here.

If the file restored with "restore_command" is too small,
the operation fails, and you get a DEBUG1 message:

  archive file "..." has wrong size: ... instead of ...

So nothing can go wrong there.

> And finally: if I also enable streaming replication, then it seems that
> log file shipping is not needed at all. If I omit archive_command and
> restore_command from the configs, and setup the replication slots and
> primary_conninfo only, then it seems to be working just fine. But when
> the network goes down for a while, then the slave goes out of sync and
> it cannot recover. It was not clear for me from the documentation, but
> am I right in that I can combine log file shipping with streaming
> replication, and achieve small replication delays plus the ability to
> recover after a longer period if network outage?

If you use a replication slot, the standby will never get out of sync
because the primary will retain all WAL that the standby has not
received yet.

Streaming replication together with archive recovery is only useful
if you are *not* using replication slots.

Yours,
Laurenz Albe




view thread (59+ messages)  latest in thread

Message-ID: <1519848731.2350.5.camel@cybertec.at>
Permalink:  ../1519848731.2350.5.camel@cybertec.at/
Also on:    postgresql.org/message-id/1519848731.2350.5.camel@cybertec.at

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: laurenz.albe@cybertec.at, gandalf@shopzeus.com
  Subject: Re: Reliable WAL file shipping over unreliable network
  In-Reply-To: <1519848731.2350.5.camel@cybertec.at>

* 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