Skip to content

Commit 693dc21

Browse files
AlexandrAlexandr
authored andcommitted
fix(replication): bigint for larger lags
1 parent 8c1420d commit 693dc21

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

mamonsu/plugins/pgsql/driver/pool.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class Pool(object):
8686
"""
8787
SELECT application_name,
8888
{0}
89-
coalesce((pg_{1}_{2}_diff(pg_current_{1}_{2}(), replay_{2}))::int, 0) AS total_lag
89+
coalesce((pg_{1}_{2}_diff(pg_current_{1}_{2}(), replay_{2}))::bigint, 0) AS total_lag
9090
FROM pg_stat_replication;
9191
""",
9292
"""
@@ -99,7 +99,7 @@ class Pool(object):
9999
"wal_held_bytes_master": (
100100
"""
101101
SELECT slot_name,
102-
coalesce((pg_wal_lsn_diff(pg_current_wal_lsn(), restart_lsn))::int, 0) AS wal_held_bytes
102+
coalesce((pg_wal_lsn_diff(pg_current_wal_lsn(), restart_lsn))::bigint, 0) AS wal_held_bytes
103103
FROM pg_replication_slots;
104104
""",
105105
"""
@@ -111,7 +111,7 @@ class Pool(object):
111111
"wal_held_bytes_replica": (
112112
"""
113113
SELECT slot_name,
114-
coalesce((pg_wal_lsn_diff(pg_last_wal_replay_lsn(), restart_lsn))::int, 0) AS wal_held_bytes
114+
coalesce((pg_wal_lsn_diff(pg_last_wal_replay_lsn(), restart_lsn))::bigint, 0) AS wal_held_bytes
115115
FROM pg_replication_slots;
116116
""",
117117
"""

mamonsu/plugins/pgsql/replication.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ def run(self, zbx):
6969
if Pooler.server_version_greater("10.0") and (Pooler.is_superuser() or Pooler.is_bootstraped()):
7070
result_lags = Pooler.run_sql_type("wal_lag_lsn",
7171
args=[
72-
" coalesce((pg_wal_lsn_diff(pg_current_wal_lsn(), sent_lsn))::int, 0) AS send_lag, "
73-
"coalesce((pg_wal_lsn_diff(sent_lsn, flush_lsn))::int, 0) AS receive_lag, "
74-
"coalesce((pg_wal_lsn_diff(sent_lsn, write_lsn))::int, 0) AS write_lag, "
75-
"coalesce((pg_wal_lsn_diff(write_lsn, flush_lsn))::int, 0) AS flush_lag, "
76-
"coalesce((pg_wal_lsn_diff(flush_lsn, replay_lsn))::int, 0) AS replay_lag, " if not Pooler.is_bootstraped() else
72+
" coalesce((pg_wal_lsn_diff(pg_current_wal_lsn(), sent_lsn))::bigint, 0) AS send_lag, "
73+
"coalesce((pg_wal_lsn_diff(sent_lsn, flush_lsn))::bigint, 0) AS receive_lag, "
74+
"coalesce((pg_wal_lsn_diff(sent_lsn, write_lsn))::bigint, 0) AS write_lag, "
75+
"coalesce((pg_wal_lsn_diff(write_lsn, flush_lsn))::bigint, 0) AS flush_lag, "
76+
"coalesce((pg_wal_lsn_diff(flush_lsn, replay_lsn))::bigint, 0) AS replay_lag, " if not Pooler.is_bootstraped() else
7777
" send_lag, receive_lag, write_lag, flush_lag, replay_lag, ",
7878
"wal", "lsn"])
7979
if result_lags:

0 commit comments

Comments
 (0)