File tree Expand file tree Collapse file tree 3 files changed +3
-3
lines changed Expand file tree Collapse file tree 3 files changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ class Pool(object):
17
17
),
18
18
"replication_lag_slave_query" : (
19
19
"""
20
- SELECT CASE WHEN coalesce(pg_last_{1}(), '0/00000000') = coalesce(pg_last_{2}(), '0/00000000')
20
+ SELECT CASE WHEN NOT pg_is_in_recovery() OR coalesce(pg_last_{1}(), '0/00000000') = coalesce(pg_last_{2}(), '0/00000000')
21
21
THEN 0
22
22
ELSE extract (epoch FROM now() - coalesce(pg_last_xact_replay_timestamp(), now() - INTERVAL '{0} seconds'))
23
23
END;
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ class Xlog(Plugin):
23
23
"""
24
24
# get time of replication lag
25
25
query_agent_replication_lag = """
26
- SELECT CASE WHEN coalesce(pg_last_{1}(), '0/00000000') = coalesce(pg_last_{2}(), '0/00000000')
26
+ SELECT CASE WHEN NOT pg_is_in_recovery() OR coalesce(pg_last_{1}(), '0/00000000') = coalesce(pg_last_{2}(), '0/00000000')
27
27
THEN 0
28
28
ELSE extract (epoch FROM now() - coalesce(pg_last_xact_replay_timestamp(), now() - INTERVAL '{0} seconds'))
29
29
END;
Original file line number Diff line number Diff line change 49
49
CREATE OR REPLACE FUNCTION mamonsu.timestamp_get()
50
50
RETURNS double precision AS $$
51
51
SELECT
52
- CASE WHEN pg_last_{11}() = pg_last_{12}() THEN 0
52
+ CASE WHEN NOT pg_is_in_recovery() OR pg_last_{11}() = pg_last_{12}() THEN 0
53
53
ELSE extract (epoch FROM now() - coalesce(pg_last_xact_replay_timestamp(), to_timestamp(ts)))
54
54
END
55
55
FROM mamonsu.timestamp_master_{1}
You can’t perform that action at this time.
0 commit comments