Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kRARk-0001fa-11 for pgsql-general@arkaria.postgresql.org; Sat, 10 Oct 2020 08:41:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kRARi-0004Py-UK for pgsql-general@arkaria.postgresql.org; Sat, 10 Oct 2020 08:41:42 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kRARi-0004O1-Mp for pgsql-general@lists.postgresql.org; Sat, 10 Oct 2020 08:41:42 +0000 Received: from mail.hjp.at ([212.17.106.138] helo=rorschach.hjp.at) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kRARc-0008K2-Uf for pgsql-general@lists.postgresql.org; Sat, 10 Oct 2020 08:41:41 +0000 Received: by rorschach.hjp.at (Postfix, from userid 1000) id A11413AEF; Sat, 10 Oct 2020 10:41:33 +0200 (CEST) Date: Sat, 10 Oct 2020 10:41:33 +0200 From: "Peter J. Holzer" To: pgsql-general@lists.postgresql.org Subject: Re: Writing WAL files Message-ID: <20201010084133.GA25239@hjp.at> References: <20201004195224.GA14394@alvherre.pgsql> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="9jxsPFA5p3P2qPhR" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --9jxsPFA5p3P2qPhR Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2020-10-05 11:29:04 -0600, Michael Lewis wrote: >=20 > 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.=A0 >=20 >=20 > 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 c= hange > 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 s= eem > 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 --=20 _ | Peter J. Holzer | Story must make more sense than reality. |_|_) | | | | | hjp@hjp.at | -- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" --9jxsPFA5p3P2qPhR Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEETtJbRjyPwVTYGJ5k8g5IURL+KF0FAl+Bc7YACgkQ8g5IURL+ KF3Pjg//evGgHk2EU4AspZnuCZysZUPVKXvDitjCJHl1aaZ0Buw0PKXSXOnLckv6 i10Q2PH5P8+spYSHV/HRSORtCV9VpHx3Wm1fT8mn046Jl4NRgAfvktvZvWNVJtPG cUPD5cPdxFzX07W5y3//PSw5TocSE8foKg29SfK1m6tk34VCQ3YvJDHm8vGmzBjD hFC91LtTOKQcIyEKlOSVlM1njnBpa8WdgO5bKePPMuV96XUMxAbO22qrp3yQWUgq pXy/lG1qnM3ovKV/dDVk2N/B/gNGeIf3ehbpF7RzkZsSoBEQLlaT4h4l5W/nJ15k LbVxpogUuTugHuU/wOWVfe680tBhiaPC0TkIK4cnffs3jAnjrFOQ2rTNSQhy2X75 dpwOPcCc1HNVd+PTjWmW749Wg00Z1cHDcxLYT7WB0gTEEL97ZOoFuERScAN64Vlp Jr6dlBUuy1+khJ15bCua21rZPHdquqDMPtPGxkr3FRut/XyjC81/CxIRTy+H6TC4 mqkzbrT+ppbBApt6qgcp4mpRP0SEupdlkKUz+vRDiBYQ6ghy08n2kcvrJlgMjx6X Hcjfp8iLCL8ZpjLyZ74wk3paL79SVEJv7F68DNNez3eYuJ0vyPBzx9/skFBf6wvj JYbRJt9RugOmfUMuicASRwe3z76zrAS1lKnOdOZdTejgEqsS+OI= =GPBJ -----END PGP SIGNATURE----- --9jxsPFA5p3P2qPhR--