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 1ot9rU-0002QI-0g for pgsql-admin@arkaria.postgresql.org; Thu, 10 Nov 2022 15:53:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ot9rS-0005wO-VW for pgsql-admin@arkaria.postgresql.org; Thu, 10 Nov 2022 15:53:02 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ot9rS-0005wE-LJ for pgsql-admin@lists.postgresql.org; Thu, 10 Nov 2022 15:53:02 +0000 Received: from jakobs.com ([85.214.83.89] helo=rs.plausibolo.de) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ot9rQ-0005Xh-JO for pgsql-admin@lists.postgresql.org; Thu, 10 Nov 2022 15:53:02 +0000 Received: from localhost (localhost [127.0.0.1]) by rs.plausibolo.de (Postfix) with ESMTP id 60FF438049C; Thu, 10 Nov 2022 16:52:59 +0100 (CET) Received: from rs.plausibolo.de ([IPv6:::1]) by localhost (h2367442.stratoserver.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id V_P-KufPcGTb; Thu, 10 Nov 2022 16:52:59 +0100 (CET) Received: from [192.168.0.178] (ip-109-43-241-97.web.vodafone.de [109.43.241.97]) by rs.plausibolo.de (Postfix) with ESMTPSA id 55DCB3802F0; Thu, 10 Nov 2022 16:52:58 +0100 (CET) Message-ID: <51397c23-b806-eb24-3bd0-986ef9c593c9@jakobs.com> Date: Thu, 10 Nov 2022 16:52:57 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.1 Subject: Re: How to test replication without doing a failover To: pgsql-admin@lists.postgresql.org References: From: Holger Jakobs In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------TseTWN4SLm0NDOMZTPoDymk4" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --------------TseTWN4SLm0NDOMZTPoDymk4 Content-Type: multipart/mixed; boundary="------------gnTEejdh5MzRv9h61WmLNBNQ"; protected-headers="v1" From: Holger Jakobs To: pgsql-admin@lists.postgresql.org Message-ID: <51397c23-b806-eb24-3bd0-986ef9c593c9@jakobs.com> Subject: Re: How to test replication without doing a failover References: In-Reply-To: --------------gnTEejdh5MzRv9h61WmLNBNQ Content-Type: multipart/alternative; boundary="------------Bn2LSn5UH5CjIxu6AX7Ujbk0" --------------Bn2LSn5UH5CjIxu6AX7Ujbk0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: base64 QW0gMTAuMTEuMjIgdW0gMTU6NTkgc2NocmllYiBFZHdpbiBVWToNCj4gTGlzdA0KPg0KPiBW ZXJ5IG5ld2JpZSBoZXJlIG9uIFBvc3RncmVTUUwgY29taW5nIGZyb20gYW4gT3JhY2xlIERC QSBiYWNrZ3JvdW5kIG1vc3RseQ0KPg0KPiBIb3cgZG8gSSB0ZXN0IGFuZCBjb25maXJtIHdo ZXRoZXIgcmVwbGljYXRpb24gaXMgd29ya2luZyBvciBub3QgDQo+IGJlc2lkZXMgZGVwZW5k aW5nIG9uIGp1c3QgcnVubmluZyB0aGUgU1FMIGJlbG93Pw0KPg0KPiBzZWxlY3QgcGdfaXNf aW5fcmVjb3ZlcnkoKSA7DQo+DQo+IHNlbGVjdCAqIGZyb20gcGdfc3RhdF9yZXBsaWNhdGlv biA7DQo+DQo+DQo+IElzIGl0IHBvc3NpYmxlIHRvIGZvcmNlL2luaXRpYXRlIGEgbG9nIHRy YW5z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pIG9uIHRoZSBzdGFu ZGJ5IHNob3dzIG5ldHdvcmsgY29uZ2VzdGlvbiBvciANCnRoYXQgdGhlIHN0YW5kYnkgaGFz IGhpZ2ggbG9hZC4NCg0KDQoNCg0KLS0gDQpIb2xnZXIgSmFrb2JzLCBCZXJnaXNjaCBHbGFk YmFjaCwgVGVsLiArNDktMTc4LTk3NTkwMTINCg0K --------------Bn2LSn5UH5CjIxu6AX7Ujbk0 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Am 10.11.22 um 15:59 schrieb Edwin UY:=
List

Very newbie here on PostgreSQL coming from an Oracle DBA background mostly

How do I test and confirm whether replication is working or not besides depending on just running the SQL below?

select pg_is_in_recovery() ;

select * from pg_stat_replication ;


Is it possible to force/initiate a log transaction and see if that gets replicated or not? I mean for example on Oracle we can do a switch logfile and check if that log gets shipped across and applied on the standby, is there something similar in PostgreSQL?
Maybe someone can refer me to an example if there is one somewhere?

Regards,
Ed


Monitoring the replication

Compare the WAL positions of primary and secondary: select pg_current_wal_lsn(); on the primary
select pg_last_wal_receive_lsn(); on the standby or in the ps output of WAL receiver process.

Using the view pg_stat_replication

Check the difference between pg_current_wal_lsn() and the column sent_lsn of the view shows high load of the primary.
Difference between the column sent_lsn of the view and pg_last_wal_receive_lsn() on the standby shows network congestion or that the standby has high load.




--=20
Holger Jakobs, Bergisch Gladbach, Tel. +49-178-9759012
--------------Bn2LSn5UH5CjIxu6AX7Ujbk0-- --------------gnTEejdh5MzRv9h61WmLNBNQ-- --------------TseTWN4SLm0NDOMZTPoDymk4 Content-Type: application/pgp-signature; name="OpenPGP_signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="OpenPGP_signature" -----BEGIN PGP SIGNATURE----- wmMEABEIACMWIQScuJCxWJK1p5BOebGKV5yTsxlhugUCY20eWQUDAAAAAAAKCRCKV5yTsxlhumzJ AKC59WCZWMTTjLe4hu6QYmULnLpK/wCgoWpIgfefL83QKYnpefa/cBOlZDk= =YGaK -----END PGP SIGNATURE----- --------------TseTWN4SLm0NDOMZTPoDymk4--