Postgresql – Detecting Logical Replication Error on Postgres v10 on AWS RDS CloudWatch metrics

amazon-cloudwatchamazon-rdsawspostgresql

https://www.postgresql.org/docs/10/logical-replication-restrictions.html
States:
"When the schema is changed on the publisher and replicated data starts arriving at the subscriber but does not fit into the table schema, replication will error until the schema is updated"

How do we detect/query for these errors on Postgres?

I tried

SELECT * FROM pg_stat_subscription;

but it shows that it received the publisher's message. It errored out when I changed publisher's schema and subcriber stopped getting updates.

on AWS, the RDS cloudwatch metrics related to it is:

OldestReplicationSlotLag (The lagging size of the replica lagging the most in terms of WAL data received. Applies to PostgreSQL)

but I don't think this is the right metric if I want to know if my updates have corrected applied to the subscriber replica database.

Best Answer

Through trial and error I found out that you can use OldestReplicationSlotLag.

If there are replication errors, it accumlates the slotlag bytes