pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter J. Holzer <hjp-pgsql@hjp.at>
To: pgsql-general@lists.postgresql.org
Subject: Re: Writing WAL files
Date: Sat, 10 Oct 2020 10:41:33 +0200
Message-ID: <20201010084133.GA25239@hjp.at> (raw)
In-Reply-To: <CAHOFxGosVP6OKEgBHrt4gEuA5mcVUTsKhhjGMtYTaks6ojgx3g@mail.gmail.com>
References: <CAKqjJm83gnw2u0ugpkgc4bq58L=cLwbvmh69TwKKo83Y1CnANw@mail.gmail.com>
	<20201004195224.GA14394@alvherre.pgsql>
	<CAKqjJm9A1sJXzFYfp6HFYYHX9tnF56qck=wTxv_i0Rd+96ewKg@mail.gmail.com>
	<CAHOFxGosVP6OKEgBHrt4gEuA5mcVUTsKhhjGMtYTaks6ojgx3g@mail.gmail.com>

On 2020-10-05 11:29:04 -0600, Michael Lewis wrote:
> 
>         I suggest that in PG12 you can monitor the
>         "lag" of a standby server more directly by looking at columns
>         write_lag,
>         flush_lag, replay_lag in the pg_stat_replication view. 
> 
> 
>     And are those things updated when there are no changes to the master
>     database?

Probably not, as there is nothing to replicate, so no new data it
provided.


> If you setup a scripted process to update a single row with a timestamptz on
> the source/primary every minute, then you have a very simple consistent change
> and also a way to check on the replica what is current time vs
> last_scripted_update_time if you will and know the approx lag. It would seem
> like a simple albeit hacky solution to you wanting a file every X minutes
> regardless of server activity.

It also has the advantage that you don't have to wait for the WAL file
to be written. You can just check whether the change appears on the
replicas. About 2 years ago I wrote a Nagios/Icinga check that does
that: Update a timestamp in a table on the master, then connect to all
the replicas and wait for the change to show up on them. It then reports
the lag for each replica and a final status (OK, WARNING, CRITICAL)
based on the maximal lag.

I think I wrote it because the PostgreSQL version we were using at the
time didn't have the lag columns yet, but it does have the advantage of
providing an end to end check (do I really get the correct value?), not
the database's idea of whether replication is working.

(The check is written in Go and buried in a svn repo at work, but I
could publish it if there is interest)

        hp

-- 
   _  | Peter J. Holzer    | Story must make more sense than reality.
|_|_) |                    |
| |   | hjp@hjp.at         |    -- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |       challenge!"

Attachments:

  signature.asc (application/pgp-signature, 832B) download

view thread (13+ messages)  latest in thread

Message-ID: <20201010084133.GA25239@hjp.at>
Permalink:  ../20201010084133.GA25239@hjp.at/
Also on:    postgresql.org/message-id/20201010084133.GA25239@hjp.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 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: hjp-pgsql@hjp.at
  Subject: Re: Writing WAL files
  In-Reply-To: <20201010084133.GA25239@hjp.at>
  References: <CAKqjJm83gnw2u0ugpkgc4bq58L=cLwbvmh69TwKKo83Y1CnANw@mail.gmail.com> <20201004195224.GA14394@alvherre.pgsql> <CAKqjJm9A1sJXzFYfp6HFYYHX9tnF56qck=wTxv_i0Rd+96ewKg@mail.gmail.com> <CAHOFxGosVP6OKEgBHrt4gEuA5mcVUTsKhhjGMtYTaks6ojgx3g@mail.gmail.com> <20201010084133.GA25239@hjp.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