[ZBX-19735] pgsql.replication.lag.sql Created: 2021 Jul 27  Updated: 2021 Dec 21  Resolved: 2021 Dec 21

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Templates (T)
Affects Version/s: 5.4.3
Fix Version/s: None

Type: Patch request Priority: Trivial
Reporter: Alexey Assignee: Vyacheslav Khaliev
Resolution: Fixed Votes: 0
Labels: PostgreSQL
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

/var/lib/zabbix/postgresql/pgsql.replication.lag.sql


Issue Links:
Sub-task
depends on ZBX-19897 Bug in template PostgreSQL by agent2 ... Closed

 Description   

Hi!
I have recovered from backup pgsql server (Point in time recovery).

postgres=# select pg_last_xact_replay_timestamp();
 pg_last_xact_replay_timestamp 
-------------------------------
 2021-06-26 22:11:23.259069+03

Item "Replication: lag in seconds":

pgsql.replication.lag.sec["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.DB}"]

And looks like trigger not working correctly for me.
I got errors event like

PostgreSQL: Streaming lag with {#MASTER} is too high (over {$PG.REPL_LAG.MAX.WARN} in 5m)

In my case I change user parameter SQL from

CASE WHEN pg_last_wal_receive_lsn() = pg_last_wal_replay_lsn()

to

CASE WHEN pg_last_wal_receive_lsn() is NULL or pg_last_wal_receive_lsn() = pg_last_wal_replay_lsn()

And it corrects the issue.

Hope you can update this script.
Thank you!



 Comments   
Comment by Alexey [ 2021 Jul 27 ]

I got Postgres 11, maybe you should change this for 10 version also.

Comment by Oleksii Zagorskyi [ 2021 Jul 29 ]

It's template "PostgreSQL"
Mentioned modified file is here https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/templates/db/postgresql/postgresql/pgsql.replication.lag.sql

Comment by Alexey [ 2021 Jul 29 ]

Exactly! Could you please correct it accordingly to my report?

Comment by Vyacheslav Khaliev [ 2021 Dec 02 ]

Resolved in ZBX-19897

Generated at Thu Apr 03 04:57:13 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.